Index: LayoutTests/fast/dom/compare-document-position-disconnected-nodes.html |
diff --git a/LayoutTests/fast/dom/compare-document-position-disconnected-nodes.html b/LayoutTests/fast/dom/compare-document-position-disconnected-nodes.html |
index c3abef951fc138ea7c55ec2b093307ee8a735eb0..96aa209f7d3d9efd6fc4ac895b811485efac4760 100644 |
--- a/LayoutTests/fast/dom/compare-document-position-disconnected-nodes.html |
+++ b/LayoutTests/fast/dom/compare-document-position-disconnected-nodes.html |
@@ -3,15 +3,36 @@ |
<head> |
<script src="../js/resources/js-test-pre.js"></script> |
<script> |
- window.a = document.createElement('a'); |
- window.b = document.createElement('b'); |
+ var a; |
+ var b; |
- shouldBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_DISCONNECTED', 'Node.DOCUMENT_POSITION_DISCONNECTED'); |
- shouldBe('b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_DISCONNECTED', 'Node.DOCUMENT_POSITION_DISCONNECTED'); |
- shouldBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC', 'Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC'); |
- shouldBe('b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC', 'Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC'); |
- shouldNotBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_PRECEDING', 'b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING'); |
- shouldNotBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING', 'b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_FOLLOWING'); |
+ function testElements(_a, _b) { |
+ a = _a; |
+ b = _b; |
+ |
+ shouldBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_DISCONNECTED', 'Node.DOCUMENT_POSITION_DISCONNECTED'); |
+ shouldBe('b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_DISCONNECTED', 'Node.DOCUMENT_POSITION_DISCONNECTED'); |
+ shouldBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC', 'Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC'); |
+ shouldBe('b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC', 'Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC'); |
+ shouldNotBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_PRECEDING', 'b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING'); |
+ shouldNotBe('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING', 'b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_FOLLOWING'); |
+ shouldBeNonZero('a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_PRECEDING || a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING'); |
+ shouldBeNonZero('b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING || b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_FOLLOWING'); |
+ // Make sure the returned result is consistent. |
+ shouldBe('a.compareDocumentPosition(b)', 'a.compareDocumentPosition(b)'); |
+ shouldBe('b.compareDocumentPosition(a)', 'b.compareDocumentPosition(a)'); |
+ } |
+ |
+ debug("* Test with 2 disconnected elements"); |
+ testElements(document.createElement('a'), document.createElement('b')); |
+ debug("* Test with document and a disconnected element"); |
+ testElements(document, document.createElement('b')); |
+ debug("* Test with document and a disconnected attribute"); |
+ testElements(document, document.createAttribute('b')); |
+ debug("* Test with 2 disconnected attributes"); |
+ testElements(document.createAttribute("a"), document.createAttribute("b")); |
+ debug("* Test with disconnected attribute and element"); |
+ testElements(document.createAttribute("a"), document.createElement("b")); |
</script> |
<script src="../js/resources/js-test-post.js"></script> |
</head> |