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 23 matching lines...) Expand all Loading... |
34 assert_readonly(iterator, 'whatToShow'); | 34 assert_readonly(iterator, 'whatToShow'); |
35 assert_readonly(iterator, 'filter'); | 35 assert_readonly(iterator, 'filter'); |
36 assert_idl_attribute(iterator, 'nextNode'); | 36 assert_idl_attribute(iterator, 'nextNode'); |
37 assert_idl_attribute(iterator, 'previousNode'); | 37 assert_idl_attribute(iterator, 'previousNode'); |
38 assert_idl_attribute(iterator, 'detach'); | 38 assert_idl_attribute(iterator, 'detach'); |
39 }, 'Construct a NodeIterator by document.createNodeIterator().'); | 39 }, 'Construct a NodeIterator by document.createNodeIterator().'); |
40 | 40 |
41 test(function () | 41 test(function () |
42 { | 42 { |
43 assert_throws(new TypeError(), function () { document.createNodeIterator();
}); | 43 assert_throws(new TypeError(), function () { document.createNodeIterator();
}); |
44 assert_throws('NOT_SUPPORTED_ERR', function () { document.createNodeIterator
(null); }); | 44 assert_throws(new TypeError(), function () { document.createNodeIterator(nul
l); }); |
45 assert_throws('NOT_SUPPORTED_ERR', function () { document.createNodeIterator
(undefined); }); | 45 assert_throws(new TypeError(), function () { document.createNodeIterator(und
efined); }); |
46 assert_throws('NOT_SUPPORTED_ERR', function () { document.createNodeIterator
(new Object()); }); | 46 assert_throws(new TypeError(), function () { document.createNodeIterator(new
Object()); }); |
47 assert_throws('NOT_SUPPORTED_ERR', function () { document.createNodeIterator
(1); }); | 47 assert_throws(new TypeError(), function () { document.createNodeIterator(1);
}); |
48 }, 'Give an invalid root node to document.createNodeIterator().'); | 48 }, 'Give an invalid root node to document.createNodeIterator().'); |
49 | 49 |
50 // |expected| should be an object indicating the expected type of node. | 50 // |expected| should be an object indicating the expected type of node. |
51 function assert_node(actual, expected) | 51 function assert_node(actual, expected) |
52 { | 52 { |
53 assert_true(actual instanceof expected.type, | 53 assert_true(actual instanceof expected.type, |
54 'Node type mismatch: actual = ' + actual.nodeType + ', expected
= ' + expected.nodeType); | 54 'Node type mismatch: actual = ' + actual.nodeType + ', expected
= ' + expected.nodeType); |
55 if (typeof(expected.id) !== 'undefined') | 55 if (typeof(expected.id) !== 'undefined') |
56 assert_equals(actual.id, expected.id); | 56 assert_equals(actual.id, expected.id); |
57 if (typeof(expected.nodeValue) !== 'undefined') | 57 if (typeof(expected.nodeValue) !== 'undefined') |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 [true, false].forEach(function (expandEntityReferences) { | 189 [true, false].forEach(function (expandEntityReferences) { |
190 var iterator = document.createNodeIterator(createSampleDOM(), NodeFilter
.SHOW_ALL, filter, expandEntityReferences); | 190 var iterator = document.createNodeIterator(createSampleDOM(), NodeFilter
.SHOW_ALL, filter, expandEntityReferences); |
191 assert_true(iterator instanceof NodeIterator); | 191 assert_true(iterator instanceof NodeIterator); |
192 assert_false(iterator.expandEntityReferences); | 192 assert_false(iterator.expandEntityReferences); |
193 testIteratorForwardAndBackward(iterator, expectedAll); | 193 testIteratorForwardAndBackward(iterator, expectedAll); |
194 }); | 194 }); |
195 }, 'Test that the fourth argument (expandEntityReferences) is ignored.'); | 195 }, 'Test that the fourth argument (expandEntityReferences) is ignored.'); |
196 </script> | 196 </script> |
197 </body> | 197 </body> |
198 </html> | 198 </html> |
OLD | NEW |