Files
palemoon27/testing/web-platform/tests/dom/nodes/Node-isEqualNode.xhtml
T

61 lines
2.1 KiB
HTML

<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.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="data:application/xml,&lt;!DOCTYPE foo [ &lt;!ELEMENT foo (%23PCDATA)> ]>&lt;foo/>" />
<iframe id="subset2" onload="iframeLoaded()" src="data:application/xml,&lt;!DOCTYPE foo [ &lt;!ELEMENT foo EMPTY> ]>&lt;foo/>" />
</body>
</html>