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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/viewless-document.html

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 years, 11 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: third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/viewless-document.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/viewless-document.html b/third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/viewless-document.html
index 386e9d434170635df63b3a3490752d667d39296c..953a24e0f59c2e60a2cc0832e0998228b7456f6b 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/viewless-document.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/SelectorAPI/viewless-document.html
@@ -4,6 +4,33 @@
<script src="../../../resources/js-test.js"></script>
</head>
<body>
-<script src="script-tests/viewless-document.js"></script>
+<script>
+description(
+"This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) don't crash when used in a viewless document."
+);
+
+var testDoc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "html");
+testDoc.documentElement.appendChild(testDoc.createElement("body"));
+testDoc.body.appendChild(testDoc.createElement("p")).id = "p1";
+testDoc.getElementById("p1").appendChild(testDoc.createElement("span")).id = "s1";
+testDoc.body.appendChild(testDoc.createElement("span")).id = "s2";
+testDoc.body.appendChild(testDoc.createElement("div")).className = "d1";
+
+var p1 = testDoc.getElementById("p1");
+var s1 = testDoc.getElementById("s1");
+var s2 = testDoc.getElementById("s2");
+var d1 = testDoc.body.lastChild;
+
+shouldBe("testDoc.querySelector('p')", "p1");
+shouldBe("testDoc.querySelectorAll('span').length", "2");
+shouldBe("testDoc.querySelectorAll('span').item(1)", "s2");
+shouldBe("testDoc.querySelector('.d1')", "d1");
+shouldBe("testDoc.querySelectorAll('p span').length", "1");
+
+shouldBeTrue("p1.webkitMatchesSelector('p')");
+shouldBeTrue("s1.webkitMatchesSelector('p span')");
+shouldBeTrue("s2.webkitMatchesSelector('#s2')");
+shouldBeTrue("d1.webkitMatchesSelector('.d1')");
+</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698