Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: LayoutTests/fast/dom/compare-document-position-disconnected-nodes.html

Issue 20042003: compareDocumentPosition() should report PRECEEDING or FOLLOWING information even if nodes are disco… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add failing test to TestExpectations Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698