Add a test case for Element.matches() with :scope
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Sep 2014 21:25:08 +0000 (21:25 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Sep 2014 21:25:08 +0000 (21:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136475

Reviewed by Andreas Kling.

There was not test for this use case. Looks like everything works fine.

* fast/selectors/matches-scope-expected.txt: Added.
* fast/selectors/matches-scope.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173227 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/selectors/matches-scope-expected.txt [new file with mode: 0644]
LayoutTests/fast/selectors/matches-scope.html [new file with mode: 0644]

index 6e214cc..4d849b6 100644 (file)
@@ -1,3 +1,15 @@
+2014-09-03  Benjamin Poulain  <benjamin@webkit.org>
+
+        Add a test case for Element.matches() with :scope
+        https://bugs.webkit.org/show_bug.cgi?id=136475
+
+        Reviewed by Andreas Kling.
+
+        There was not test for this use case. Looks like everything works fine.
+
+        * fast/selectors/matches-scope-expected.txt: Added.
+        * fast/selectors/matches-scope.html: Added.
+
 2014-09-03  David Hyatt  <hyatt@apple.com>
 
         Add support for the initial-letter CSS property to first-letter
diff --git a/LayoutTests/fast/selectors/matches-scope-expected.txt b/LayoutTests/fast/selectors/matches-scope-expected.txt
new file mode 100644 (file)
index 0000000..f1b1a63
--- /dev/null
@@ -0,0 +1,27 @@
+This test makes sure that :scope works correctly with the matches() API.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS theTarget.matches(":scope") is true
+PASS theTarget.matches(":not(:scope)") is false
+PASS theTarget.matches("body :scope") is true
+PASS theTarget.matches("body>:scope") is true
+PASS theTarget.matches("sibling + :scope") is true
+PASS theTarget.matches("sibling ~ :scope") is true
+PASS theTarget.matches("#theTarget:scope") is true
+PASS theTarget.matches(":scope#theTarget") is true
+PASS theTarget.matches("[webkit]:scope#theTarget") is true
+PASS theTarget.matches(":not([webkit=fast]):scope#theTarget") is false
+PASS theTarget.matches(":scope target") is false
+PASS theTarget.matches(":scope > target") is false
+PASS theTarget.matches(":scope + target") is false
+PASS theTarget.matches(":scope ~ target") is false
+PASS theTarget.matches(":scope *") is false
+PASS theTarget.matches(":scope > *") is false
+PASS theTarget.matches(":scope + *") is false
+PASS theTarget.matches(":scope ~ *") is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/selectors/matches-scope.html b/LayoutTests/fast/selectors/matches-scope.html
new file mode 100644 (file)
index 0000000..e6a1f86
--- /dev/null
@@ -0,0 +1,44 @@
+<!doctype html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.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 matches() API.');
+
+var theTarget = document.getElementById('theTarget');
+shouldBeTrue('theTarget.matches(":scope")');
+shouldBeFalse('theTarget.matches(":not(:scope)")');
+
+shouldBeTrue('theTarget.matches("body :scope")');
+shouldBeTrue('theTarget.matches("body>:scope")');
+
+shouldBeTrue('theTarget.matches("sibling + :scope")');
+shouldBeTrue('theTarget.matches("sibling ~ :scope")');
+
+shouldBeTrue('theTarget.matches("#theTarget:scope")');
+shouldBeTrue('theTarget.matches(":scope#theTarget")');
+
+shouldBeTrue('theTarget.matches("[webkit]:scope#theTarget")');
+shouldBeFalse('theTarget.matches(":not([webkit=fast]):scope#theTarget")');
+
+shouldBeFalse('theTarget.matches(":scope target")');
+shouldBeFalse('theTarget.matches(":scope > target")');
+shouldBeFalse('theTarget.matches(":scope + target")');
+shouldBeFalse('theTarget.matches(":scope ~ target")');
+
+shouldBeFalse('theTarget.matches(":scope *")');
+shouldBeFalse('theTarget.matches(":scope > *")');
+shouldBeFalse('theTarget.matches(":scope + *")');
+shouldBeFalse('theTarget.matches(":scope ~ *")');
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</html>