OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <title>Node.prototype.isSameNode</title> |
| 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-node-issamenode"> |
| 5 <script src="../../../../resources/testharness.js"></script> |
| 6 <script src="../../../../resources/testharnessreport.js"></script> |
| 7 <script> |
| 8 "use strict"; |
| 9 |
| 10 test(function() { |
| 11 |
| 12 var doctype1 = document.implementation.createDocumentType("qualifiedName", "pu
blicId", "systemId"); |
| 13 var doctype2 = document.implementation.createDocumentType("qualifiedName", "pu
blicId", "systemId"); |
| 14 |
| 15 assert_true(doctype1.isSameNode(doctype1), "self-comparison"); |
| 16 assert_false(doctype1.isSameNode(doctype2), "same properties"); |
| 17 assert_false(doctype1.isSameNode(null), "with null other node"); |
| 18 }, "doctypes should be comapred on reference"); |
| 19 |
| 20 test(function() { |
| 21 |
| 22 var element1 = document.createElementNS("namespace", "prefix:localName"); |
| 23 var element2 = document.createElementNS("namespace", "prefix:localName"); |
| 24 |
| 25 assert_true(element1.isSameNode(element1), "self-comparison"); |
| 26 assert_false(element1.isSameNode(element2), "same properties"); |
| 27 assert_false(element1.isSameNode(null), "with null other node"); |
| 28 |
| 29 }, "elements should be compared on reference"); |
| 30 |
| 31 test(function() { |
| 32 |
| 33 var element1 = document.createElement("element"); |
| 34 element1.setAttributeNS("namespace", "prefix:localName", "value"); |
| 35 |
| 36 var element2 = document.createElement("element"); |
| 37 element2.setAttributeNS("namespace", "prefix:localName", "value"); |
| 38 |
| 39 assert_true(element1.isSameNode(element1), "self-comparison"); |
| 40 assert_false(element1.isSameNode(element2), "same properties"); |
| 41 assert_false(element1.isSameNode(null), "with null other node"); |
| 42 |
| 43 }, "elements should be compared on reference"); |
| 44 |
| 45 test(function() { |
| 46 |
| 47 var pi1 = document.createProcessingInstruction("target", "data"); |
| 48 var pi2 = document.createProcessingInstruction("target", "data"); |
| 49 |
| 50 assert_true(pi1.isSameNode(pi1), "self-comparison"); |
| 51 assert_false(pi1.isSameNode(pi2), "different target"); |
| 52 assert_false(pi1.isSameNode(null), "with null other node"); |
| 53 |
| 54 }, "processing instructions should be compared on reference"); |
| 55 |
| 56 test(function() { |
| 57 |
| 58 var text1 = document.createTextNode("data"); |
| 59 var text2 = document.createTextNode("data"); |
| 60 |
| 61 assert_true(text1.isSameNode(text1), "self-comparison"); |
| 62 assert_false(text1.isSameNode(text2), "same properties"); |
| 63 assert_false(text1.isSameNode(null), "with null other node"); |
| 64 |
| 65 }, "text nodes should be compared on reference"); |
| 66 |
| 67 test(function() { |
| 68 |
| 69 var comment1 = document.createComment("data"); |
| 70 var comment2 = document.createComment("data"); |
| 71 |
| 72 assert_true(comment1.isSameNode(comment1), "self-comparison"); |
| 73 assert_false(comment1.isSameNode(comment2), "same properties"); |
| 74 assert_false(comment1.isSameNode(null), "with null other node"); |
| 75 |
| 76 }, "comments should be compared on reference"); |
| 77 |
| 78 test(function() { |
| 79 |
| 80 var documentFragment1 = document.createDocumentFragment(); |
| 81 var documentFragment2 = document.createDocumentFragment(); |
| 82 |
| 83 assert_true(documentFragment1.isSameNode(documentFragment1), "self-comparison"
); |
| 84 assert_false(documentFragment1.isSameNode(documentFragment2), "same properties
"); |
| 85 assert_false(documentFragment1.isSameNode(null), "with null other node"); |
| 86 |
| 87 }, "document fragments should be compared on reference"); |
| 88 |
| 89 test(function() { |
| 90 |
| 91 var document1 = document.implementation.createDocument("", ""); |
| 92 var document2 = document.implementation.createDocument("", ""); |
| 93 |
| 94 assert_true(document1.isSameNode(document1), "self-comparison"); |
| 95 assert_false(document1.isSameNode(document2), "another empty XML document"); |
| 96 assert_false(document1.isSameNode(null), "with null other node"); |
| 97 |
| 98 }, "documents should not be compared on reference"); |
| 99 |
| 100 </script> |
OLD | NEW |