Title: [175432] trunk
Revision
175432
Author
[email protected]
Date
2014-10-31 16:10:04 -0700 (Fri, 31 Oct 2014)

Log Message

Pseudo classes with an escaped parenthesis generate invalid rules
https://bugs.webkit.org/show_bug.cgi?id=138266

Patch by Benjamin Poulain <[email protected]> on 2014-10-31
Reviewed by Antti Koivisto.

Source/WebCore:

Since the functional pseudo classes are part of the list of PseudoClassAndCompatibilityElement,
they could be created by the rule
     pseudo:
         ':' IDENT
if the parenthesis is escaped. For example, with ":not\\(", the IDENT would be
"not(", CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector would
find a pseudo class type of PseudoClassNot, and the action would create an invalid
CSSSelector for a :not() without nested selector.

This patch fixes the issue by detecting the function case in
CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector().

An other solution would be to split PseudoClassAndCompatibilityElement into simple pseudo class
and functional pseudo classes. We may do that some day but at the moment it is a lot of work with
a little benefit.

Tests: fast/css/crash-on-incomplete-webkit-any.html
       fast/css/pseudo-escaped-parenthesis.html
       fast/selectors/invalid-functional-pseudo-class.html

* css/CSSParserValues.cpp:
(WebCore::CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector):

LayoutTests:

* fast/selectors/invalid-functional-pseudo-class-expected.txt: Added.
* fast/selectors/invalid-functional-pseudo-class.html: Added.
New test for all the functional pseudo classes.

* fast/css/crash-on-incomplete-webkit-any-expected.txt: Added.
* fast/css/crash-on-incomplete-webkit-any.html: Added.
* fast/css/pseudo-escaped-parenthesis-expected.txt: Added.
* fast/css/pseudo-escaped-parenthesis.html: Added.
Those tests come from blink. Rune solved the same problem a year ago on blink
in https://chromiumcodereview.appspot.com/23710067
The patch is quite different because blink uses an ancient code base, but the tests
can still be useful so I included them here.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (175431 => 175432)


--- trunk/LayoutTests/ChangeLog	2014-10-31 23:09:14 UTC (rev 175431)
+++ trunk/LayoutTests/ChangeLog	2014-10-31 23:10:04 UTC (rev 175432)
@@ -1,3 +1,23 @@
+2014-10-31  Benjamin Poulain  <[email protected]>
+
+        Pseudo classes with an escaped parenthesis generate invalid rules
+        https://bugs.webkit.org/show_bug.cgi?id=138266
+
+        Reviewed by Antti Koivisto.
+
+        * fast/selectors/invalid-functional-pseudo-class-expected.txt: Added.
+        * fast/selectors/invalid-functional-pseudo-class.html: Added.
+        New test for all the functional pseudo classes.
+
+        * fast/css/crash-on-incomplete-webkit-any-expected.txt: Added.
+        * fast/css/crash-on-incomplete-webkit-any.html: Added.
+        * fast/css/pseudo-escaped-parenthesis-expected.txt: Added.
+        * fast/css/pseudo-escaped-parenthesis.html: Added.
+        Those tests come from blink. Rune solved the same problem a year ago on blink
+        in https://chromiumcodereview.appspot.com/23710067
+        The patch is quite different because blink uses an ancient code base, but the tests
+        can still be useful so I included them here.
+
 2014-10-31  Said Abou-Hallawa  <[email protected]>
 
         Remove webkit prefix from CSS columns.

Added: trunk/LayoutTests/fast/css/crash-on-incomplete-webkit-any-expected.txt (0 => 175432)


--- trunk/LayoutTests/fast/css/crash-on-incomplete-webkit-any-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/crash-on-incomplete-webkit-any-expected.txt	2014-10-31 23:10:04 UTC (rev 175432)
@@ -0,0 +1 @@
+PASS if not crashed.

Added: trunk/LayoutTests/fast/css/crash-on-incomplete-webkit-any.html (0 => 175432)


--- trunk/LayoutTests/fast/css/crash-on-incomplete-webkit-any.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/crash-on-incomplete-webkit-any.html	2014-10-31 23:10:04 UTC (rev 175432)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>:-webkit-any\( should not crash</title>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+    </script>
+    <style>:-webkit-any\( {}</style>
+</head>
+<body>
+    <p>PASS if not crashed.</p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/css/pseudo-escaped-parenthesis-expected.txt (0 => 175432)


--- trunk/LayoutTests/fast/css/pseudo-escaped-parenthesis-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-escaped-parenthesis-expected.txt	2014-10-31 23:10:04 UTC (rev 175432)
@@ -0,0 +1,13 @@
+
+PASS All stylesheets present 
+PASS Drop ":-webkit-any\( {}" 
+PASS Drop ":nth-child\( {}" 
+PASS Drop ":nth-of-type\( {}" 
+PASS Drop ":nth-last-child\( {}" 
+PASS Drop ":nth-last-of-type\( {}" 
+PASS Drop ":lang\( {}" 
+PASS Drop ":not\( {}" 
+PASS Drop ":cue\( {}" 
+PASS Drop ":part\( {}" 
+PASS Drop ":host\( {}" 
+

Added: trunk/LayoutTests/fast/css/pseudo-escaped-parenthesis.html (0 => 175432)


--- trunk/LayoutTests/fast/css/pseudo-escaped-parenthesis.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/pseudo-escaped-parenthesis.html	2014-10-31 23:10:04 UTC (rev 175432)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Pseudo classes with escaped start parenthesis</title>
+    <script src=""
+    <script src=""
+    <style>:-webkit-any\( {}</style>
+    <style>:nth-child\( {}</style>
+    <style>:nth-of-type\( {}</style>
+    <style>:nth-last-child\( {}</style>
+    <style>:nth-last-of-type\( {}</style>
+    <style>:lang\( {}</style>
+    <style>:not\( {}</style>
+    <style>:cue\( {}</style>
+    <style>:part\( {}</style>
+    <style>:host\( {}</style>
+</head>
+<body>
+    <p id="log"></p>
+    <script>
+        var sheets = document.styleSheets;
+
+        test(function(){
+            assert_equals(sheets.length, 10, "StyleSheets.length");
+        }, "All stylesheets present")
+
+        for (var i=0; i<sheets.length; i++) {
+            test(function(){
+                assert_equals(sheets[i].cssRules.length, 0, "cssRules.length");
+            }, "Drop \"" + sheets[i].ownerNode.firstChild.data + "\"");
+        }
+    </script>
+</body>
+</html>

Added: trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class-expected.txt (0 => 175432)


--- trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class-expected.txt	2014-10-31 23:10:04 UTC (rev 175432)
@@ -0,0 +1,441 @@
+Verify the never generates a valid selector for an invalid functional pseudo class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.querySelectorAll(":-webkit-any\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":-webkit-any\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":-webkit-any\\\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":-webkit-any\\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.querySelectorAll(":lang\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":lang\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":lang\\\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":lang\\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.querySelectorAll(":not\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":not\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":not\\\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":not\\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.querySelectorAll(":nth-child\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":nth-child\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":nth-child\\\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-child\\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.querySelectorAll(":nth-last-child\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":nth-last-child\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":nth-last-child\\\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-child\\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.querySelectorAll(":nth-last-of-type\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":nth-last-of-type\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":nth-last-of-type\\\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-last-of-type\\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.querySelectorAll(":nth-of-type\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":nth-of-type\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":nth-of-type\\\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":nth-of-type\\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.querySelectorAll(":matches\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":matches\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\").length threw exception SyntaxError: Unexpected EOF.
+PASS document.querySelectorAll(":matches\\\\").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\\(").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\\ .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\\( .foo").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\\()").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\\ .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.querySelectorAll(":matches\\\\( .foo)").length threw exception Error: SyntaxError: DOM Exception 12.
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS document.styleSheets[1].cssRules.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class.html (0 => 175432)


--- trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/invalid-functional-pseudo-class.html	2014-10-31 23:10:04 UTC (rev 175432)
@@ -0,0 +1,77 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<style id="style-target"></style>
+</head>
+<body>
+<script>
+description('Verify the never generates a valid selector for an invalid functional pseudo class.');
+
+function invalidRules(functonalPseudoClassName) {
+    return [':' + functonalPseudoClassName + '\\',
+            ':' + functonalPseudoClassName + '\\\\',
+            ':' + functonalPseudoClassName + '\\\\\\',
+            ':' + functonalPseudoClassName + '\\\\\\\\',
+            ':' + functonalPseudoClassName + '\\(',
+            ':' + functonalPseudoClassName + '\\\\(',
+            ':' + functonalPseudoClassName + '\\\\\\(',
+            ':' + functonalPseudoClassName + '\\\\\\\\(',
+            ':' + functonalPseudoClassName + '\\ .foo',
+            ':' + functonalPseudoClassName + '\\\\ .foo',
+            ':' + functonalPseudoClassName + '\\\\\\ .foo',
+            ':' + functonalPseudoClassName + '\\\\\\\\ .foo',
+            ':' + functonalPseudoClassName + '\\( .foo',
+            ':' + functonalPseudoClassName + '\\\\( .foo',
+            ':' + functonalPseudoClassName + '\\\\\\( .foo',
+            ':' + functonalPseudoClassName + '\\\\\\\\( .foo',
+            ':' + functonalPseudoClassName + '\\()',
+            ':' + functonalPseudoClassName + '\\\\()',
+            ':' + functonalPseudoClassName + '\\\\\\()',
+            ':' + functonalPseudoClassName + '\\\\\\\\()',
+            ':' + functonalPseudoClassName + '\\ .foo)',
+            ':' + functonalPseudoClassName + '\\\\ .foo)',
+            ':' + functonalPseudoClassName + '\\\\\\ .foo)',
+            ':' + functonalPseudoClassName + '\\\\\\\\ .foo)',
+            ':' + functonalPseudoClassName + '\\\\( .foo)',
+            ':' + functonalPseudoClassName + '\\\\\\( .foo)',
+            ':' + functonalPseudoClassName + '\\\\\\\\( .foo)'];
+}
+
+function testQuerySelector(functonalPseudoClassName) {
+    for (var testCase of invalidRules(functonalPseudoClassName))
+        shouldThrow('document.querySelectorAll("' + testCase + '").length');
+}
+
+function testStyling(functonalPseudoClassName) {
+    var styleElement = document.getElementById("style-target");
+
+    for (var testCase of invalidRules(functonalPseudoClassName)) {
+        styleElement.textContent = testCase + " { background-color: red; }";
+        shouldBe("document.styleSheets[1].cssRules.length", "0");
+    }
+    styleElement.textContent = "";
+}
+
+function test(functonalPseudoClassName) {
+    testQuerySelector(functonalPseudoClassName);
+    testStyling(functonalPseudoClassName);
+}
+
+var functionalPseudoClasses = [
+    "-webkit-any",
+    "lang",
+    "not",
+    "nth-child",
+    "nth-last-child",
+    "nth-last-of-type",
+    "nth-of-type",
+    "matches",
+];
+
+for (var functionalPseudoClass of functionalPseudoClasses)
+    test(functionalPseudoClass);
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (175431 => 175432)


--- trunk/Source/WebCore/ChangeLog	2014-10-31 23:09:14 UTC (rev 175431)
+++ trunk/Source/WebCore/ChangeLog	2014-10-31 23:10:04 UTC (rev 175432)
@@ -1,3 +1,33 @@
+2014-10-31  Benjamin Poulain  <[email protected]>
+
+        Pseudo classes with an escaped parenthesis generate invalid rules
+        https://bugs.webkit.org/show_bug.cgi?id=138266
+
+        Reviewed by Antti Koivisto.
+
+        Since the functional pseudo classes are part of the list of PseudoClassAndCompatibilityElement,
+        they could be created by the rule
+             pseudo:
+                 ':' IDENT
+        if the parenthesis is escaped. For example, with ":not\\(", the IDENT would be
+        "not(", CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector would
+        find a pseudo class type of PseudoClassNot, and the action would create an invalid
+        CSSSelector for a :not() without nested selector.
+
+        This patch fixes the issue by detecting the function case in
+        CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector().
+
+        An other solution would be to split PseudoClassAndCompatibilityElement into simple pseudo class
+        and functional pseudo classes. We may do that some day but at the moment it is a lot of work with
+        a little benefit.
+
+        Tests: fast/css/crash-on-incomplete-webkit-any.html
+               fast/css/pseudo-escaped-parenthesis.html
+               fast/selectors/invalid-functional-pseudo-class.html
+
+        * css/CSSParserValues.cpp:
+        (WebCore::CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector):
+
 2014-10-31  Chris Dumez  <[email protected]>
 
         Make CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement() faster

Modified: trunk/Source/WebCore/css/CSSParserValues.cpp (175431 => 175432)


--- trunk/Source/WebCore/css/CSSParserValues.cpp	2014-10-31 23:09:14 UTC (rev 175431)
+++ trunk/Source/WebCore/css/CSSParserValues.cpp	2014-10-31 23:10:04 UTC (rev 175432)
@@ -208,6 +208,9 @@
 
 CSSParserSelector* CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector(CSSParserString& pseudoTypeString)
 {
+    if (pseudoTypeString.length() && pseudoTypeString[pseudoTypeString.length() - 1] == '(')
+        return nullptr;
+
     PseudoClassOrCompatibilityPseudoElement pseudoType = parsePseudoClassAndCompatibilityElementString(pseudoTypeString);
     if (pseudoType.pseudoClass != CSSSelector::PseudoClassUnknown) {
         auto selector = std::make_unique<CSSParserSelector>();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to