diff options
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/Node-isEqualNode-xhtml.xhtml')
-rw-r--r-- | testing/web-platform/tests/dom/nodes/Node-isEqualNode-xhtml.xhtml | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/Node-isEqualNode-xhtml.xhtml b/testing/web-platform/tests/dom/nodes/Node-isEqualNode-xhtml.xhtml new file mode 100644 index 000000000..3170643d2 --- /dev/null +++ b/testing/web-platform/tests/dom/nodes/Node-isEqualNode-xhtml.xhtml @@ -0,0 +1,84 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Node.isEqualNode</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id="log"/> +<script> +function testNullHandling(node) { + test(function() { + assert_false(node.isEqualNode(null)) + assert_false(node.isEqualNode(undefined)) + }) +} +[ + document.createElement("foo"), + document.createTextNode("foo"), + document.createProcessingInstruction("foo", "bar"), + document.createComment("foo"), + document, + document.implementation.createDocumentType("html", "", ""), + document.createDocumentFragment() +].forEach(testNullHandling) + +test(function() { + var a = document.createElement("foo") + a.setAttribute("a", "bar") + a.setAttribute("b", "baz") + var b = document.createElement("foo") + b.setAttribute("b", "baz") + b.setAttribute("a", "bar") + assert_true(a.isEqualNode(b)) +}, "isEqualNode should return true when the attributes are in a different order") + +test(function() { + var a = document.createElementNS("ns", "prefix:foo") + var b = document.createElementNS("ns", "prefix:foo") + assert_true(a.isEqualNode(b)) +}, "isEqualNode should return true if elements have same namespace, prefix, and local name") + +test(function() { + var a = document.createElementNS("ns1", "prefix:foo") + var b = document.createElementNS("ns2", "prefix:foo") + assert_false(a.isEqualNode(b)) +}, "isEqualNode should return false if elements have different namespace") + +test(function() { + var a = document.createElementNS("ns", "prefix1:foo") + var b = document.createElementNS("ns", "prefix2:foo") + assert_false(a.isEqualNode(b)) +}, "isEqualNode should return false if elements have different prefix") + +test(function() { + var a = document.createElementNS("ns", "prefix:foo1") + var b = document.createElementNS("ns", "prefix:foo2") + assert_false(a.isEqualNode(b)) +}, "isEqualNode should return false if elements have different local name") + +test(function() { + var a = document.createElement("foo") + a.setAttributeNS("ns", "x:a", "bar") + var b = document.createElement("foo") + b.setAttributeNS("ns", "y:a", "bar") + assert_true(a.isEqualNode(b)) +}, "isEqualNode should return true when the attributes have different prefixes") +var internalSubset = async_test("isEqualNode should return true when only the internal subsets of DocumentTypes differ.") +var wait = 2; +function iframeLoaded() { + if (!--wait) { + internalSubset.step(function() { + var doc1 = document.getElementById("subset1").contentDocument + var doc2 = document.getElementById("subset2").contentDocument + assert_true(doc1.doctype.isEqualNode(doc2.doctype), "doc1.doctype.isEqualNode(doc2.doctype)") + assert_true(doc1.isEqualNode(doc2), "doc1.isEqualNode(doc2)") + }) + internalSubset.done() + } +} +</script> +<iframe id="subset1" onload="iframeLoaded()" src="Node-isEqualNode-iframe1.xml" /> +<iframe id="subset2" onload="iframeLoaded()" src="Node-isEqualNode-iframe2.xml" /> +</body> +</html> |