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

Unified Diff: LayoutTests/fast/selectors/element-closest-scope.html

Issue 701723007: Adding Element.closest() API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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/selectors/element-closest-scope.html
diff --git a/LayoutTests/fast/selectors/element-closest-scope.html b/LayoutTests/fast/selectors/element-closest-scope.html
new file mode 100644
index 0000000000000000000000000000000000000000..68f9cb095d55b7620315429a440f94613d8b0f3f
--- /dev/null
+++ b/LayoutTests/fast/selectors/element-closest-scope.html
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+<script>
+if (window.testRunner)
+ testRunner.dumpAsText();
+</script>
+</head>
+<body>
+ <sibling></sibling>
+ <target id="theTarget" webkit="fast"></target>
+</body>
+<script>
+description('This test makes sure that :scope works correctly with the closest() API.');
+
+var theTarget = document.getElementById('theTarget');
+var body = document.body;
+
+shouldBe('theTarget.closest(":scope")', 'theTarget');
+shouldBe('theTarget.closest(":not(:scope)")', 'body');
+
+shouldBe('theTarget.closest("body :scope")', 'theTarget');
+shouldBe('theTarget.closest("body > :scope")', 'theTarget');
+shouldBeNull('theTarget.closest("body:scope")');
+
+shouldBe('theTarget.closest("sibling + :scope")', 'theTarget');
+shouldBe('theTarget.closest("sibling ~ :scope")', 'theTarget');
+
+shouldBe('theTarget.closest("#theTarget:scope")', 'theTarget');
+shouldBe('theTarget.closest(":scope#theTarget")', 'theTarget');
+
+shouldBe('theTarget.closest("[webkit]:scope#theTarget")', 'theTarget');
+shouldBeNull('theTarget.closest(":not([webkit=fast]):scope#theTarget")');
+
+shouldBeNull('theTarget.closest(":scope target")');
+shouldBeNull('theTarget.closest(":scope > target")');
+shouldBeNull('theTarget.closest(":scope + target")');
+shouldBeNull('theTarget.closest(":scope ~ target")');
+
+shouldBeNull('theTarget.closest(":scope *")');
+shouldBeNull('theTarget.closest(":scope > *")');
+shouldBeNull('theTarget.closest(":scope + *")');
+shouldBeNull('theTarget.closest(":scope ~ *")');
+</script>
+</html>

Powered by Google App Engine
This is Rietveld 408576698