| OLD | NEW |
| (Empty) | |
| 1 <html xmlns="http://www.w3.org/1999/xhtml"> |
| 2 <head> |
| 3 <title>Node.isEqualNode</title> |
| 4 <script src="../../../../resources/testharness.js"></script> |
| 5 <script src="../../../../resources/testharnessreport.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <div id="log"/> |
| 9 <script> |
| 10 function testNullHandling(node) { |
| 11 test(function() { |
| 12 assert_false(node.isEqualNode(null)) |
| 13 assert_false(node.isEqualNode(undefined)) |
| 14 }) |
| 15 } |
| 16 [ |
| 17 document.createElement("foo"), |
| 18 document.createTextNode("foo"), |
| 19 document.createProcessingInstruction("foo", "bar"), |
| 20 document.createComment("foo"), |
| 21 document, |
| 22 document.implementation.createDocumentType("html", "", ""), |
| 23 document.createDocumentFragment() |
| 24 ].forEach(testNullHandling) |
| 25 |
| 26 test(function() { |
| 27 var a = document.createElement("foo") |
| 28 a.setAttribute("a", "bar") |
| 29 a.setAttribute("b", "baz") |
| 30 var b = document.createElement("foo") |
| 31 b.setAttribute("b", "baz") |
| 32 b.setAttribute("a", "bar") |
| 33 assert_true(a.isEqualNode(b)) |
| 34 }, "isEqualNode should return true when the attributes are in a different order"
) |
| 35 |
| 36 test(function() { |
| 37 var a = document.createElementNS("ns", "prefix:foo") |
| 38 var b = document.createElementNS("ns", "prefix:foo") |
| 39 assert_true(a.isEqualNode(b)) |
| 40 }, "isEqualNode should return true if elements have same namespace, prefix, and
local name") |
| 41 |
| 42 test(function() { |
| 43 var a = document.createElementNS("ns1", "prefix:foo") |
| 44 var b = document.createElementNS("ns2", "prefix:foo") |
| 45 assert_false(a.isEqualNode(b)) |
| 46 }, "isEqualNode should return false if elements have different namespace") |
| 47 |
| 48 test(function() { |
| 49 var a = document.createElementNS("ns", "prefix1:foo") |
| 50 var b = document.createElementNS("ns", "prefix2:foo") |
| 51 assert_false(a.isEqualNode(b)) |
| 52 }, "isEqualNode should return false if elements have different prefix") |
| 53 |
| 54 test(function() { |
| 55 var a = document.createElementNS("ns", "prefix:foo1") |
| 56 var b = document.createElementNS("ns", "prefix:foo2") |
| 57 assert_false(a.isEqualNode(b)) |
| 58 }, "isEqualNode should return false if elements have different local name") |
| 59 |
| 60 test(function() { |
| 61 var a = document.createElement("foo") |
| 62 a.setAttributeNS("ns", "x:a", "bar") |
| 63 var b = document.createElement("foo") |
| 64 b.setAttributeNS("ns", "y:a", "bar") |
| 65 assert_true(a.isEqualNode(b)) |
| 66 }, "isEqualNode should return true when the attributes have different prefixes") |
| 67 var internalSubset = async_test("isEqualNode should return true when only the in
ternal subsets of DocumentTypes differ.") |
| 68 var wait = 2; |
| 69 function iframeLoaded() { |
| 70 if (!--wait) { |
| 71 internalSubset.step(function() { |
| 72 var doc1 = document.getElementById("subset1").contentDocument |
| 73 var doc2 = document.getElementById("subset2").contentDocument |
| 74 assert_true(doc1.doctype.isEqualNode(doc2.doctype), "doc1.doctype.isEqualN
ode(doc2.doctype)") |
| 75 assert_true(doc1.isEqualNode(doc2), "doc1.isEqualNode(doc2)") |
| 76 }) |
| 77 internalSubset.done() |
| 78 } |
| 79 } |
| 80 </script> |
| 81 <iframe id="subset1" onload="iframeLoaded()" src="Node-isEqualNode-iframe1.xml"
/> |
| 82 <iframe id="subset2" onload="iframeLoaded()" src="Node-isEqualNode-iframe2.xml"
/> |
| 83 </body> |
| 84 </html> |
| OLD | NEW |