Bug 814566 - Allow invalid syntax (with balanced parentheses) inside @supports conditions. (v1.1.1) r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Sun, 23 Dec 2012 13:30:55 +1100
changeset 126014 7023232a96f562588eec46a2a9908405107d1564
parent 126013 adbb1a174e93c85caec379d75a503cac42deb8a7
child 126015 4c295e120bccb84032e8997749b64d831fd6ed43
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs814566
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 814566 - Allow invalid syntax (with balanced parentheses) inside @supports conditions. (v1.1.1) r=dbaron
dom/locales/en-US/chrome/layout/css.properties
layout/reftests/w3c-css/submitted/conditional3/css-supports-015.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-022.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-023.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-031.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-032.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-033.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-034.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-035.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-036.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-037.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-038.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-039.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-040.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-041.xht
layout/reftests/w3c-css/submitted/conditional3/reftest.list
layout/style/nsCSSParser.cpp
--- a/dom/locales/en-US/chrome/layout/css.properties
+++ b/dom/locales/en-US/chrome/layout/css.properties
@@ -7,17 +7,17 @@ MimeNotCssWarn=The stylesheet %1$S was l
 
 PEUnexpEOF2=Unexpected end of file while searching for %1$S.
 PEParseRuleWSOnly=Whitespace-only string given to be parsed as rule.
 PEDeclDropped=Declaration dropped.
 PEDeclSkipped=Skipped to next declaration.
 PEUnknownProperty=Unknown property '%1$S'.
 PEValueParsingError=Error in parsing value for '%1$S'.
 PEExpectEndValue=Expected end of value but found '%1$S'.
-PESkipAtRuleEOF=end of unknown at-rule
+PESkipAtRuleEOF2=end of at-rule
 PEUnknownAtRule=Unrecognized at-rule or error parsing at-rule '%1$S'.
 PECharsetRuleEOF=charset string in @charset rule
 PECharsetRuleNotString=Expected charset string but found '%1$S'.
 PEGatherMediaEOF=end of media list in @import or @media rule
 PEGatherMediaNotComma=Expected ',' in media list but found '%1$S'.
 PEGatherMediaNotIdent=Expected identifier in media list but found '%1$S'.
 PEImportNotURI=Expected URI in @import rule but found '%1$S'.
 PEImportBadURI=Invalid URI in @import rule: '%1$S'.
@@ -110,16 +110,16 @@ PEMQExpressionEOF=contents of media quer
 PEMQExpectedFeatureName=Expected media feature name but found '%1$S'.
 PEMQExpectedFeatureNameEnd=Expected ':' or ')' after media feature name but found '%1$S'.
 PEMQNoMinMaxWithoutValue=Media features with min- or max- must have a value.
 PEMQExpectedFeatureValue=Found invalid value for media feature.
 PEBadFontBlockStart=Expected '{' to begin @font-face rule but found '%1$S'.
 PEBadFontBlockEnd=Expected '}' to end @font-face rule but found '%1$S'.
 PEAnonBoxNotAlone=Did not expect anonymous box.
 PEBadDirValue=Expected 'ltr' or 'rtl' in direction selector but found '%1$S'.
-PESupportsConditionStartEOF='not' or '('
-PESupportsConditionInParensStartEOF='not', '(' or identifier
+PESupportsConditionStartEOF2='not', '(', or function
+PESupportsConditionInParensEOF=')'
 PESupportsConditionNotEOF='not'
-PESupportsConditionExpectedOpenParen=Expected '(' while parsing supports condition but found '%1$S'.
+PESupportsConditionExpectedOpenParenOrFunction=Expected '(' or function while parsing supports condition but found '%1$S'.
 PESupportsConditionExpectedCloseParen=Expected ')' while parsing supports condition but found '%1$S'.
-PESupportsConditionExpectedStart=Expected 'not' or '(' while parsing supports condition but found '%1$S'.
+PESupportsConditionExpectedStart2=Expected 'not', '(', or function while parsing supports condition but found '%1$S'.
 PESupportsConditionExpectedNot=Expected 'not' while parsing supports condition but found '%1$S'.
 PESupportsGroupRuleStart=Expected '{' to begin @supports rule but found '%1$S'.
--- a/layout/reftests/w3c-css/submitted/conditional3/css-supports-015.xht
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-015.xht
@@ -1,16 +1,16 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
   <title>CSS Test: An @supports rule with valid syntax and a passing condition must apply rules inside it</title>
   <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
   <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
   <meta name="flags" content="" />
-  <meta name="assert" content="There need not be any white space between the '@supports' and open brace of the rule set, not between a declaration's property name and value."/>
+  <meta name="assert" content="There need not be any white space between the '@supports' and open brace of the rule set, nor between a declaration's property name and value."/>
   <link rel="match" href="support/pass.xht" />
   <style type="text/css"><![CDATA[
     @supports(color:green){
       html { background-color: green }
     }
   ]]></style>
  </head>
  <body>
--- a/layout/reftests/w3c-css/submitted/conditional3/css-supports-022.xht
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-022.xht
@@ -1,19 +1,19 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
-  <title>CSS Test: An @supports rule with invalid syntax must not apply rules inside it</title>
+  <title>CSS Test: An @supports rule with balanced invalid syntax within parentheses must evaluate to false</title>
   <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
   <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
-  <meta name="flags" content="invalid" />
-  <meta name="assert" content="An @supports conditions must fail to parse if a declaration has an empy property value."/>
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports condition must successfully parse even if a declaration has an empty property value."/>
   <link rel="match" href="support/pass.xht" />
   <style type="text/css"><![CDATA[
-    html { background-color: green }
+    html { background-color: red }
     @supports (unknown:) or (color: green) {
-      html { background-color: red }
+      html { background-color: green }
     }
   ]]></style>
  </head>
  <body>
  </body>
 </html>
--- a/layout/reftests/w3c-css/submitted/conditional3/css-supports-023.xht
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-023.xht
@@ -1,19 +1,19 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
-  <title>CSS Test: An @supports rule with invalid syntax must not apply rules inside it</title>
+  <title>CSS Test: An @supports rule with balanced invalid syntax within parentheses must evaluate to false</title>
   <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
   <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
-  <meta name="flags" content="invalid" />
-  <meta name="assert" content="A property declaration in an @supports declaration must not omit the colon between the property name and value."/>
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports condition must successfully parse a parenthesized expression that has invalid syntax with balanced parentheses."/>
   <link rel="match" href="support/pass.xht" />
   <style type="text/css"><![CDATA[
-    html { background-color: green }
+    html { background-color: red }
     @supports (unknown) or (color: green) {
-      html { background-color: red }
+      html { background-color: green }
     }
   ]]></style>
  </head>
  <body>
  </body>
 </html>
--- a/layout/reftests/w3c-css/submitted/conditional3/css-supports-031.xht
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-031.xht
@@ -1,19 +1,19 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
-  <title>CSS Test: An @supports rule with invalid syntax must not apply rules inside it</title>
+  <title>CSS Test: An @supports rule with balanced invalid syntax within parentheses must evaluate to false</title>
   <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
   <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
-  <meta name="flags" content="invalid" />
-  <meta name="assert" content="An @supports conditions must fail to parse if a declaration has an empy property value."/>
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports condition must successfully parse a parenthesized expression that has invalid syntax with balanced parentheses."/>
   <link rel="match" href="support/pass.xht" />
   <style type="text/css"><![CDATA[
-    html { background-color: green }
+    html { background-color: red }
     @supports (color:) or (color: green) {
-      html { background-color: red }
+      html { background-color: green }
     }
   ]]></style>
  </head>
  <body>
  </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-032.xht
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: An @supports rule with balanced invalid syntax must evaluate to false</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports condition must successfully parse and evaluate to false a parenthesized expression has invalid syntax."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    html { background-color: red }
+    @supports not (@page) {
+      html { background-color: green }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-033.xht
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: An @supports rule with balanced invalid syntax must evaluate to false</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports condition must successfully parse a parenthesized expression that has invalid syntax with balanced parentheses."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    html { background-color: red }
+    @supports not ({ something @with [ balanced ] parens }) {
+      html { background-color: green }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-034.xht
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: An @supports rule with balanced invalid syntax must evaluate to false</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports condition must successfully parse a parenthesized expression that has invalid syntax with balanced parentheses."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    html { background-color: red }
+    @supports not ({ something @with [ balanced ] parens }) {
+      html { background-color: green }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-035.xht
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: An @supports rule with unbalanced invalid syntax must fail to parse</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="invalid" />
+  <meta name="assert" content="An @supports condition with a parenthesized expression that has unbalanced parentheses must fail to parse."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    html { background-color: green }
+    @supports not ({ something @with (unbalanced parens }) {
+      html { background-color: red }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-036.xht
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: An @supports rule with an unrecognized condition using functional notation must evaluate to false</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports condition with an unrecognized condition using functional notation must evaluate to false."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    html { background-color: red }
+    @supports an-extension(of some kind) or (color: green) {
+      html { background-color: green }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-037.xht
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: An @supports rule with an unrecognized condition using functional notation with unbalanced parentheses must fail to parse</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="invalid" />
+  <meta name="assert" content="An @supports condition with an unrecognized condition using functional notation with unbalanced parentheses must fail to parse."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    html { background-color: green }
+    @supports (color: green) or an-extension(that is [unbalanced) {
+      html { background-color: red }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-038.xht
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: In an @supports rule "not(" must be parsed as a FUNCTION</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports condition with 'not(' must parse be parsed as a FUNCTION token."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    html { background-color: green }
+    @supports not(unknown: unknown) {
+      html { background-color: red }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-039.xht
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: In an @supports rule "or(" must be parsed as a FUNCTION</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="invalid" />
+  <meta name="assert" content="An @supports condition with 'or(' must parse be parsed as a FUNCTION token."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    html { background-color: green }
+    @supports (color: green) or(color: blue) {
+      html { background-color: red }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-040.xht
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: An @supports rule condition with empty parentheses should evaluates to false</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports rule condition that consists just of a pair of parentheses should evaluate to false."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    @supports not () {
+      html { background-color: green }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-041.xht
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+  <title>CSS Test: An @supports rule condition with empty parentheses should evaluates to false</title>
+  <link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au" />
+  <link rel="help" href="http://www.w3.org/TR/css3-conditional/#at-supports" />
+  <meta name="flags" content="" />
+  <meta name="assert" content="An @supports rule condition that consists just of a pair of parentheses should evaluate to false."/>
+  <link rel="match" href="support/pass.xht" />
+  <style type="text/css"><![CDATA[
+    @supports () or (color: green) {
+      html { background-color: green }
+    }
+  ]]></style>
+ </head>
+ <body>
+ </body>
+</html>
--- a/layout/reftests/w3c-css/submitted/conditional3/reftest.list
+++ b/layout/reftests/w3c-css/submitted/conditional3/reftest.list
@@ -26,8 +26,18 @@ default-preferences pref(layout.css.supp
 == css-supports-024.xht support/pass.xht
 == css-supports-025.xht support/pass.xht
 == css-supports-026.xht support/pass.xht
 == css-supports-027.xht support/pass.xht
 == css-supports-028.xht support/pass.xht
 == css-supports-029.xht support/pass.xht
 == css-supports-030.xht support/pass.xht
 == css-supports-031.xht support/pass.xht
+== css-supports-032.xht support/pass.xht
+== css-supports-033.xht support/pass.xht
+== css-supports-034.xht support/pass.xht
+== css-supports-035.xht support/pass.xht
+== css-supports-036.xht support/pass.xht
+== css-supports-037.xht support/pass.xht
+== css-supports-038.xht support/pass.xht
+== css-supports-039.xht support/pass.xht
+== css-supports-040.xht support/pass.xht
+== css-supports-041.xht support/pass.xht
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -337,18 +337,21 @@ protected:
   // FUNCTION ... ')').
   // Note that this function WILL WRITE TO aURL IN SOME FAILURE CASES.
   bool GetURLInParens(nsString& aURL);
 
   bool ExpectSymbol(PRUnichar aSymbol, bool aSkipWS);
   bool ExpectEndProperty();
   bool CheckEndProperty();
   nsSubstring* NextIdent();
-  void SkipUntil(PRUnichar aStopSymbol);
+
+  // returns true when the stop symbol is found, and false for EOF
+  bool SkipUntil(PRUnichar aStopSymbol);
   void SkipUntilOneOf(const PRUnichar* aStopSymbolChars);
+
   void SkipRuleSet(bool aInsideBraces);
   bool SkipAtRule(bool aInsideBlock);
   bool SkipDeclaration(bool aCheckForBraces);
 
   void PushGroup(css::GroupRule* aRule);
   void PopGroup();
 
   bool ParseRuleSet(RuleAppendFunc aAppendFunc, void* aProcessData,
@@ -1500,17 +1503,17 @@ CSSParserImpl::NextIdent()
   return &mToken.mIdent;
 }
 
 bool
 CSSParserImpl::SkipAtRule(bool aInsideBlock)
 {
   for (;;) {
     if (!GetToken(true)) {
-      REPORT_UNEXPECTED_EOF(PESkipAtRuleEOF);
+      REPORT_UNEXPECTED_EOF(PESkipAtRuleEOF2);
       return false;
     }
     if (eCSSToken_Symbol == mToken.mType) {
       PRUnichar symbol = mToken.mSymbol;
       if (symbol == ';') {
         break;
       }
       if (aInsideBlock && symbol == '}') {
@@ -2455,23 +2458,26 @@ CSSParserImpl::ParseSupportsRule(RuleApp
 // supports_condition
 //   : supports_condition_in_parens supports_condition_terms
 //   | supports_condition_negation
 //   ;
 bool
 CSSParserImpl::ParseSupportsCondition(bool& aConditionMet)
 {
   if (!GetToken(true)) {
-    REPORT_UNEXPECTED_EOF(PESupportsConditionStartEOF);
+    REPORT_UNEXPECTED_EOF(PESupportsConditionStartEOF2);
     return false;
   }
 
   UngetToken();
 
-  if (mToken.IsSymbol('(')) {
+  if (mToken.IsSymbol('(') ||
+      mToken.mType == eCSSToken_Function ||
+      mToken.mType == eCSSToken_URL ||
+      mToken.mType == eCSSToken_Bad_URL) {
     return ParseSupportsConditionInParens(aConditionMet) &&
            ParseSupportsConditionTerms(aConditionMet);
   }
 
   if (mToken.mType == eCSSToken_Ident &&
       mToken.mIdent.LowerCaseEqualsLiteral("not")) {
     return ParseSupportsConditionNegation(aConditionMet);
   }
@@ -2502,28 +2508,54 @@ CSSParserImpl::ParseSupportsConditionNeg
     return true;
   }
 
   return false;
 }
 
 // supports_condition_in_parens
 //   : '(' S* supports_condition_in_parens_inside_parens ')' S*
+//   | general_enclosed
 //   ;
 bool
 CSSParserImpl::ParseSupportsConditionInParens(bool& aConditionMet)
 {
-  if (!ExpectSymbol('(', true)) {
-    REPORT_UNEXPECTED_TOKEN(PESupportsConditionExpectedOpenParen);
+  if (!GetToken(true)) {
+    REPORT_UNEXPECTED_EOF(PESupportsConditionInParensStartEOF);
+    return false;
+  }
+
+  if (mToken.mType == eCSSToken_URL) {
+    aConditionMet = false;
+    return true;
+  }
+
+  if (mToken.mType == eCSSToken_Function ||
+      mToken.mType == eCSSToken_Bad_URL) {
+    if (!SkipUntil(')')) {
+      REPORT_UNEXPECTED_EOF(PESupportsConditionInParensEOF);
+      return false;
+    }
+    aConditionMet = false;
+    return true;
+  }
+
+  if (!mToken.IsSymbol('(')) {
+    REPORT_UNEXPECTED_TOKEN(PESupportsConditionExpectedOpenParenOrFunction);
+    UngetToken();
     return false;
   }
 
   if (!ParseSupportsConditionInParensInsideParens(aConditionMet)) {
-    SkipUntil(')');
-    return false;
+    if (!SkipUntil(')')) {
+      REPORT_UNEXPECTED_EOF(PESupportsConditionInParensEOF);
+      return false;
+    }
+    aConditionMet = false;
+    return true;
   }
 
   if (!(ExpectSymbol(')', true))) {
     REPORT_UNEXPECTED_TOKEN(PESupportsConditionExpectedCloseParen);
     SkipUntil(')');
     return false;
   }
 
@@ -2534,30 +2566,27 @@ CSSParserImpl::ParseSupportsConditionInP
 //   : core_declaration
 //   | supports_condition_negation
 //   | supports_condition_in_parens supports_condition_terms
 //   ;
 bool
 CSSParserImpl::ParseSupportsConditionInParensInsideParens(bool& aConditionMet)
 {
   if (!GetToken(true)) {
-    REPORT_UNEXPECTED_EOF(PESupportsConditionInParensStartEOF);
     return false;
   }
 
   if (mToken.mType == eCSSToken_Ident) {
     if (!mToken.mIdent.LowerCaseEqualsLiteral("not")) {
       nsAutoString propertyName = mToken.mIdent;
       if (!ExpectSymbol(':', true)) {
-        REPORT_UNEXPECTED_TOKEN(PEParseDeclarationNoColon);
         return false;
       }
 
       if (ExpectSymbol(')', true)) {
-        REPORT_UNEXPECTED_P(PEValueParsingError, propertyName);
         UngetToken();
         return false;
       }
 
       nsCSSProperty propID = nsCSSProps::LookupProperty(propertyName,
                                                         nsCSSProps::eEnabled);
       if (propID == eCSSProperty_UNKNOWN) {
         aConditionMet = false;
@@ -2638,33 +2667,33 @@ CSSParserImpl::ParseSupportsConditionTer
     if (mToken.mType != eCSSToken_Ident ||
         !mToken.mIdent.LowerCaseEqualsASCII(token)) {
       UngetToken();
       return true;
     }
   }
 }
 
-void
+bool
 CSSParserImpl::SkipUntil(PRUnichar aStopSymbol)
 {
   nsCSSToken* tk = &mToken;
   nsAutoTArray<PRUnichar, 16> stack;
   stack.AppendElement(aStopSymbol);
   for (;;) {
     if (!GetToken(true)) {
-      break;
+      return false;
     }
     if (eCSSToken_Symbol == tk->mType) {
       PRUnichar symbol = tk->mSymbol;
       uint32_t stackTopIndex = stack.Length() - 1;
       if (symbol == stack.ElementAt(stackTopIndex)) {
         stack.RemoveElementAt(stackTopIndex);
         if (stackTopIndex == 0) {
-          break;
+          return true;
         }
 
       // Just handle out-of-memory by parsing incorrectly.  It's
       // highly unlikely we're dealing with a legitimate style sheet
       // anyway.
       } else if ('{' == symbol) {
         stack.AppendElement('}');
       } else if ('[' == symbol) {