(function() { module("tinymce.html.DomParser"); var schema = new tinymce.html.Schema({valid_elements: '*[class|title]'}); var serializer = new tinymce.html.Serializer({}, schema); var parser, root; function countNodes(node, counter) { var sibling; if (!counter) { counter = {}; } if (node.name in counter) { counter[node.name]++; } else { counter[node.name] = 1; } for (sibling = node.firstChild; sibling; sibling = sibling.next) { countNodes(sibling, counter); } return counter; } schema.addValidChildren('+body[style]'); test('Parse element', function() { var parser, root; expect(7); parser = new tinymce.html.DomParser({}, schema); root = parser.parse('test'); equal(serializer.serialize(root), 'test', 'Inline element'); equal(root.firstChild.type, 1, 'Element type'); equal(root.firstChild.name, 'b', 'Element name'); deepEqual(root.firstChild.attributes, [{name: 'title', value: 'title'}, {name: 'class', value: 'class'}], 'Element attributes'); deepEqual(countNodes(root), {body:1, b:1, '#text':1}, 'Element attributes (count)'); parser = new tinymce.html.DomParser({}, schema); root = parser.parse(' \t\r\n