Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / traversal / moz-mutations-3.html
blob173f4b2ab8e4b7c72176e4fbc097c3e2f9ff5847
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>DOM Traversal: NodeIterator: Mutations (3/x)</title>
5 </head>
6 <p id="display"></p>
7 <div id="content" style="display: none">
8 <span id=root><span id=B></span><span id=C></span><span id=D></span><span id=E><span id=E1><span id=E11></span></span></span></span>
9 </div>
10 <pre id="test">
11 Results available in the JavaScript console
12 Test adapted from http://mxr.mozilla.org/mozilla-central/source/content/base/test/test_NodeIterator_mutations_3.html
13 <script class="testbody" type="text/javascript">
14 if (window.testRunner)
15 testRunner.dumpAsText();
17 function $(id) {
18 return document.getElementById(id);
21 function removeNode(n) {
22 n.parentNode.removeChild(n);
24 var initInner = $('content').innerHTML;
25 var content = $('content');
27 function resetContent() {
28 content.innerHTML = initInner;
29 var checkIt = document.createNodeIterator(content, NodeFilter.SHOW_ELEMENT, testNodeFilter, false);
30 var node;
31 while ((node = checkIt.nextNode()) != null) {
32 if (node.id) {
33 window[node.id] = node;
38 function makeSpan(id) {
39 var e = document.createElement('span');
40 e.id = id;
41 return e;
44 function testNodeFilter(n) {
45 if (n.tagName == 'SPAN')
46 return NodeFilter.FILTER_ACCEPT;
47 return NodeFilter.FILTER_SKIP;
50 function checkseq(it, root, expect) {
51 var checkIt = document.createNodeIterator(root, NodeFilter.SHOW_ELEMENT, testNodeFilter, false);
52 var printedPointer = (it.referenceNode == undefined);
53 var string = '';
54 var node;
55 while ((node = checkIt.nextNode()) != null) {
56 if (!printedPointer && it.referenceNode == node) {
57 printedPointer = true;
58 var s = '[' + node.id + '] ';
59 if (it.pointerBeforeReferenceNode)
60 string += "* " + s;
61 else
62 string += s + "* ";
63 } else {
64 string += node.id + " ";
67 console.log("sequence check:");
68 console.log(string.slice(0, -1) + " (actual)");
69 console.log(expect + " (expected)");
72 resetContent();
73 var it = document.createNodeIterator(E, NodeFilter.SHOW_ELEMENT,
74 testNodeFilter, false);
75 checkseq(it, root, "root B C D * [E] E1 E11");
77 removeNode(C);
78 checkseq(it, root, "root B D * [E] E1 E11");
80 it.nextNode();
81 removeNode(D);
82 checkseq(it, root, "root B [E] * E1 E11");
84 it.nextNode();
85 removeNode(B);
86 checkseq(it, root, "root E [E1] * E11");
88 it.nextNode();
89 checkseq(it, root, "root E E1 [E11] *");
91 it.nextNode();
92 checkseq(it, root, "root E E1 [E11] *");
94 it.previousNode();
95 it.previousNode();
96 it.previousNode();
97 it.previousNode();
98 it.previousNode();
99 checkseq(it, root, "root * [E] E1 E11");
101 resetContent();
102 it = document.createNodeIterator(E, NodeFilter.SHOW_ELEMENT,
103 testNodeFilter, false);
104 checkseq(it, root, "root B C D * [E] E1 E11");
106 it.nextNode();
107 it.nextNode();
108 checkseq(it, root, "root B C D E [E1] * E11");
110 it.previousNode();
111 it.previousNode();
112 checkseq(it, root, "root B C D * [E] E1 E11");
114 removeNode(D);
115 removeNode(B);
116 checkseq(it, root, "root C * [E] E1 E11");
118 n = makeSpan('n');
119 root.insertBefore(n, E);
120 checkseq(it, root, "root C n * [E] E1 E11");
122 n2 = makeSpan('n2');
123 root.insertBefore(n2, C);
124 checkseq(it, root, "root n2 C n * [E] E1 E11");
126 resetContent();
127 it = document.createNodeIterator(E, NodeFilter.SHOW_ELEMENT,
128 testNodeFilter, false);
129 checkseq(it, root, "root B C D * [E] E1 E11");
131 removeNode(root);
132 checkseq(it, root, "root B C D * [E] E1 E11");
134 removeNode(B);
135 checkseq(it, root, "root C D * [E] E1 E11");
137 removeNode(D);
138 checkseq(it, root, "root C * [E] E1 E11");
140 it.nextNode();
141 it.nextNode();
142 it.nextNode();
143 checkseq(it, root, "root C E E1 [E11] *");
145 removeNode(E1);
146 checkseq(it, root, "root C [E] *");
148 n = makeSpan('n');
149 root.insertBefore(n, E);
150 checkseq(it, root, "root C n [E] *");
152 n2 = makeSpan('n2');
153 E.appendChild(n2);
154 checkseq(it, root, "root C n [E] * n2");
156 it.nextNode();
157 checkseq(it, root, "root C n E [n2] *");
159 removeNode(E);
160 checkseq(it, root, "root C n");
163 </script>
164 </pre>
165 </body>
166 </html>