Bug 780337 - @supports rule should not parse if property value is empty. r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Sat, 04 Aug 2012 17:07:03 +1000
changeset 101423 c9564834bfe1183d537b445b86b25e348043b02a
parent 101422 a8c1c8501141ea8e36d2f0e9de0c9507231c1691
child 101424 efe20b02bab164a0a1520e867e04b3a935f84655
push id23232
push useremorley@mozilla.com
push dateSat, 04 Aug 2012 18:12:50 +0000
treeherdermozilla-central@0a17cde2a4b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs780337
milestone17.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 780337 - @supports rule should not parse if property value is empty. r=dbaron
layout/reftests/w3c-css/submitted/conditional3/css-supports-022.xht
layout/reftests/w3c-css/submitted/conditional3/css-supports-031.xht
layout/reftests/w3c-css/submitted/conditional3/reftest.list
layout/style/nsCSSParser.cpp
--- a/layout/reftests/w3c-css/submitted/conditional3/css-supports-022.xht
+++ b/layout/reftests/w3c-css/submitted/conditional3/css-supports-022.xht
@@ -1,18 +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 valid syntax but a failing condition must not apply rules inside it</title>
+  <title>CSS Test: An @supports rule with invalid syntax must not 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/#at-supports" />
   <meta name="flags" content="" />
-  <meta name="assert" content="A disjunction of two @supports conditions must cause the @supports condition to pass if one condition passes and the other fails due to being an unsupported property with an empty property value."/>
+  <meta name="assert" content="An @supports conditions must fail to parse if a declaration has an empy property value."/>
   <link rel="match" href="pass.html" />
   <style type="text/css"><![CDATA[
+    html { background-color: green }
     @supports (unknown:) or (color: green) {
-      html { background-color: green }
+      html { background-color: red }
     }
   ]]></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,20 +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: {{ brief but unique descriptive title of what's being tested }}</title>
+  <title>CSS Test: An @supports rule with invalid syntax must not 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/#at-supports" />
   <meta name="flags" content="" />
-  <meta name="assert" content="{{ explain precisely what is asserted when the test passes;
-                                  optional but helps coordination and review }}" />
+  <meta name="assert" content="An @supports conditions must fail to parse if a declaration has an empy property value."/>
   <link rel="match" href="pass.html" />
   <style type="text/css"><![CDATA[
     html { background-color: green }
-    @supports (not (color: rainbow) and (color: green)) {
+    @supports (color:) or (color: green) {
       html { background-color: red }
     }
   ]]></style>
  </head>
  <body>
  </body>
 </html>
--- a/layout/reftests/w3c-css/submitted/conditional3/reftest.list
+++ b/layout/reftests/w3c-css/submitted/conditional3/reftest.list
@@ -23,8 +23,9 @@
 == css-supports-023.xht pass.html
 == css-supports-024.xht pass.html
 == css-supports-025.xht pass.html
 == css-supports-026.xht pass.html
 == css-supports-027.xht pass.html
 == css-supports-028.xht pass.html
 == css-supports-029.xht pass.html
 == css-supports-030.xht pass.html
+== css-supports-031.xht pass.html
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -2482,16 +2482,25 @@ CSSParserImpl::ParseSupportsConditionInP
   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)) {
+        const PRUnichar *params[] = {
+          propertyName.get()
+        };
+        REPORT_UNEXPECTED_P(PEValueParsingError, params);
+        UngetToken();
+        return false;
+      }
+
       nsCSSProperty propID = nsCSSProps::LookupProperty(propertyName,
                                                         nsCSSProps::eEnabled);
       if (propID == eCSSProperty_UNKNOWN) {
         aConditionMet = false;
         SkipUntil(')');
         UngetToken();
       } else {
         aConditionMet = ParseProperty(propID) &&