4 <script src=
"../../resources/js-test.js"></script>
9 function testElements(_a
, _b
) {
13 shouldBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_DISCONNECTED', 'Node.DOCUMENT_POSITION_DISCONNECTED');
14 shouldBe('b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_DISCONNECTED', 'Node.DOCUMENT_POSITION_DISCONNECTED');
15 shouldBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC', 'Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC');
16 shouldBe('b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC', 'Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC');
17 shouldNotBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_PRECEDING', 'b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING');
18 shouldNotBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING', 'b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_FOLLOWING');
19 shouldBeNonZero('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_PRECEDING || a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING');
20 shouldBeNonZero('b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING || b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_FOLLOWING');
21 // Make sure the returned result is consistent.
22 shouldBe('a.compareDocumentPosition(b)', 'a.compareDocumentPosition(b)');
23 shouldBe('b.compareDocumentPosition(a)', 'b.compareDocumentPosition(a)');
26 debug("* Test with 2 disconnected elements");
27 testElements(document
.createElement('a'), document
.createElement('b'));
28 debug("* Test with document and a disconnected element");
29 testElements(document
, document
.createElement('b'));
30 debug("* Test with document and a disconnected attribute");
31 testElements(document
, document
.createAttribute('b'));
32 debug("* Test with 2 disconnected attributes");
33 testElements(document
.createAttribute("a"), document
.createAttribute("b"));
34 debug("* Test with disconnected attribute and element");
35 testElements(document
.createAttribute("a"), document
.createElement("b"));
39 <p>Comparing the positions of two disconnected nodes should result in DOCUMENT_POSITION_DISCONNECTED.
</p>