OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>TreeWalker: Basic test</title> | 4 <title>TreeWalker: 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 TreeWalker.</p> | 10 <p>This test checks the basic functionality of TreeWalker.</p> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 assert_idl_attribute(walker, 'lastChild'); | 52 assert_idl_attribute(walker, 'lastChild'); |
53 assert_idl_attribute(walker, 'previousSibling'); | 53 assert_idl_attribute(walker, 'previousSibling'); |
54 assert_idl_attribute(walker, 'nextSibling'); | 54 assert_idl_attribute(walker, 'nextSibling'); |
55 assert_idl_attribute(walker, 'previousNode'); | 55 assert_idl_attribute(walker, 'previousNode'); |
56 assert_idl_attribute(walker, 'nextNode'); | 56 assert_idl_attribute(walker, 'nextNode'); |
57 }, 'Construct a TreeWalker by document.createTreeWalker().'); | 57 }, 'Construct a TreeWalker by document.createTreeWalker().'); |
58 | 58 |
59 test(function () | 59 test(function () |
60 { | 60 { |
61 assert_throws(new TypeError(), function () { document.createTreeWalker(); })
; | 61 assert_throws(new TypeError(), function () { document.createTreeWalker(); })
; |
62 assert_throws('NOT_SUPPORTED_ERR', function () { document.createTreeWalker(n
ull); }); | 62 assert_throws(new TypeError(), function () { document.createTreeWalker(null)
; }); |
63 assert_throws('NOT_SUPPORTED_ERR', function () { document.createTreeWalker(u
ndefined); }); | 63 assert_throws(new TypeError(), function () { document.createTreeWalker(undef
ined); }); |
64 assert_throws('NOT_SUPPORTED_ERR', function () { document.createTreeWalker(n
ew Object()); }); | 64 assert_throws(new TypeError(), function () { document.createTreeWalker(new O
bject()); }); |
65 assert_throws('NOT_SUPPORTED_ERR', function () { document.createTreeWalker(1
); }); | 65 assert_throws(new TypeError(), function () { document.createTreeWalker(1); }
); |
66 }, 'Give an invalid root node to document.createTreeWalker().'); | 66 }, 'Give an invalid root node to document.createTreeWalker().'); |
67 | 67 |
68 // |expected| should be an object indicating the expected type of node. | 68 // |expected| should be an object indicating the expected type of node. |
69 function assert_node(actual, expected) | 69 function assert_node(actual, expected) |
70 { | 70 { |
71 assert_true(actual instanceof expected.type, | 71 assert_true(actual instanceof expected.type, |
72 'Node type mismatch: actual = ' + actual.nodeType + ', expected
= ' + expected.nodeType); | 72 'Node type mismatch: actual = ' + actual.nodeType + ', expected
= ' + expected.nodeType); |
73 if (typeof(expected.id) !== 'undefined') | 73 if (typeof(expected.id) !== 'undefined') |
74 assert_equals(actual.id, expected.id); | 74 assert_equals(actual.id, expected.id); |
75 if (typeof(expected.nodeValue) !== 'undefined') | 75 if (typeof(expected.nodeValue) !== 'undefined') |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 }; | 115 }; |
116 [true, false].forEach(function (expandEntityReferences) { | 116 [true, false].forEach(function (expandEntityReferences) { |
117 var walker = document.createTreeWalker(createSampleDOM(), NodeFilter.SHO
W_ALL, filter, expandEntityReferences); | 117 var walker = document.createTreeWalker(createSampleDOM(), NodeFilter.SHO
W_ALL, filter, expandEntityReferences); |
118 assert_true(walker instanceof TreeWalker); | 118 assert_true(walker instanceof TreeWalker); |
119 assert_false(walker.expandEntityReferences); | 119 assert_false(walker.expandEntityReferences); |
120 }); | 120 }); |
121 }, 'Test that the fourth argument (expandEntityReferences) is ignored.'); | 121 }, 'Test that the fourth argument (expandEntityReferences) is ignored.'); |
122 </script> | 122 </script> |
123 </body> | 123 </body> |
124 </html> | 124 </html> |
OLD | NEW |