| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>NodeIterator: Basic test</title> | 4 <title>NodeIterator: Basic test</title> |
| 5 <script src="../../../resources/testharness.js"></script> | 5 <script src="../../../resources/testharness.js"></script> |
| 6 <script src="../../../resources/testharnessreport.js"></script> | 6 <script src="../../../resources/testharnessreport.js"></script> |
| 7 <link rel="stylesheet" href="../../../resources/testharness.css"> | 7 <link rel="stylesheet" href="../../../resources/testharness.css"> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <p>This test checks the basic functionality of NodeIterator.</p> | 10 <p>This test checks the basic functionality of NodeIterator.</p> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 assert_equals(iterator.pointerBeforeReferenceNode, true); | 87 assert_equals(iterator.pointerBeforeReferenceNode, true); |
| 88 --index; | 88 --index; |
| 89 } | 89 } |
| 90 | 90 |
| 91 assert_equals(index, -1); | 91 assert_equals(index, -1); |
| 92 assert_equals(node, null); | 92 assert_equals(node, null); |
| 93 assert_node(iterator.referenceNode, expectedNodes[0]); | 93 assert_node(iterator.referenceNode, expectedNodes[0]); |
| 94 assert_equals(iterator.pointerBeforeReferenceNode, true); | 94 assert_equals(iterator.pointerBeforeReferenceNode, true); |
| 95 } | 95 } |
| 96 | 96 |
| 97 var expectedAll = [ |
| 98 { type: Element, id: 'a' }, |
| 99 { type: Text, nodeValue: 'b' }, |
| 100 { type: Element, id: 'c' }, |
| 101 { type: Element, id: 'd' }, |
| 102 { type: Text, nodeValue: 'e' }, |
| 103 { type: Element, id: 'f' }, |
| 104 { type: Text, nodeValue: 'g' }, |
| 105 { type: Comment, nodeValue: 'h' }, |
| 106 { type: Text, nodeValue: 'i' }, |
| 107 { type: Comment, nodeValue: 'j' }, |
| 108 ]; |
| 109 |
| 97 test(function () | 110 test(function () |
| 98 { | 111 { |
| 99 var expected = [ | |
| 100 { type: Element, id: 'a' }, | |
| 101 { type: Text, nodeValue: 'b' }, | |
| 102 { type: Element, id: 'c' }, | |
| 103 { type: Element, id: 'd' }, | |
| 104 { type: Text, nodeValue: 'e' }, | |
| 105 { type: Element, id: 'f' }, | |
| 106 { type: Text, nodeValue: 'g' }, | |
| 107 { type: Comment, nodeValue: 'h' }, | |
| 108 { type: Text, nodeValue: 'i' }, | |
| 109 { type: Comment, nodeValue: 'j' }, | |
| 110 ]; | |
| 111 var iterator = document.createNodeIterator(createSampleDOM()); | 112 var iterator = document.createNodeIterator(createSampleDOM()); |
| 112 testIteratorForwardAndBackward(iterator, expected); | 113 testIteratorForwardAndBackward(iterator, expectedAll); |
| 113 }, 'Iterate over all nodes forward then backward.'); | 114 }, 'Iterate over all nodes forward then backward.'); |
| 114 | 115 |
| 115 test(function () | 116 test(function () |
| 116 { | 117 { |
| 117 var expected = [ | 118 var expected = [ |
| 118 { type: Element, id: 'a' }, | 119 { type: Element, id: 'a' }, |
| 119 { type: Element, id: 'c' }, | 120 { type: Element, id: 'c' }, |
| 120 { type: Element, id: 'd' }, | 121 { type: Element, id: 'd' }, |
| 121 { type: Element, id: 'f' }, | 122 { type: Element, id: 'f' }, |
| 122 ]; | 123 ]; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 if (node.nodeType === Node.ELEMENT_NODE && node.id === 'f' || | 173 if (node.nodeType === Node.ELEMENT_NODE && node.id === 'f' || |
| 173 node.nodeType === Node.TEXT_NODE && node.nodeValue === 'e' || | 174 node.nodeType === Node.TEXT_NODE && node.nodeValue === 'e' || |
| 174 node.nodeType === Node.COMMENT_NODE && node.nodeValue === 'j') { | 175 node.nodeType === Node.COMMENT_NODE && node.nodeValue === 'j') { |
| 175 return NodeFilter.FILTER_ACCEPT; | 176 return NodeFilter.FILTER_ACCEPT; |
| 176 } | 177 } |
| 177 return NodeFilter.FILTER_REJECT; | 178 return NodeFilter.FILTER_REJECT; |
| 178 }; | 179 }; |
| 179 var iterator = document.createNodeIterator(createSampleDOM(), NodeFilter.SHO
W_ALL, filter); | 180 var iterator = document.createNodeIterator(createSampleDOM(), NodeFilter.SHO
W_ALL, filter); |
| 180 testIteratorForwardAndBackward(iterator, expected); | 181 testIteratorForwardAndBackward(iterator, expected); |
| 181 }, 'Test the behavior of NodeIterator when NodeFilter is specified.'); | 182 }, 'Test the behavior of NodeIterator when NodeFilter is specified.'); |
| 183 |
| 184 test(function () |
| 185 { |
| 186 var filter = function (node) { |
| 187 return NodeFilter.FILTER_ACCEPT; |
| 188 }; |
| 189 [true, false].forEach(function (expandEntityReferences) { |
| 190 var iterator = document.createNodeIterator(createSampleDOM(), NodeFilter
.SHOW_ALL, filter, expandEntityReferences); |
| 191 assert_true(iterator instanceof NodeIterator); |
| 192 assert_false(iterator.expandEntityReferences); |
| 193 testIteratorForwardAndBackward(iterator, expectedAll); |
| 194 }); |
| 195 }, 'Test that the fourth argument (expandEntityReferences) is ignored.'); |
| 182 </script> | 196 </script> |
| 183 </body> | 197 </body> |
| 184 </html> | 198 </html> |
| OLD | NEW |