<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>45017</bug_id>
          
          <creation_ts>2010-08-31 21:28:05 -0700</creation_ts>
          <short_desc>CSS MediaQuery tests fail</short_desc>
          <delta_ts>2022-06-09 11:30:26 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc>http://www.w3.org/Style/CSS/Test/MediaQueries/20100726/media-queries-test.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>96752</dependson>
    
    <dependson>97006</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>alexander.shalamov</cc>
    
    <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>daniel</cc>
    
    <cc>donggwan.kim</cc>
    
    <cc>hyatt</cc>
    
    <cc>kenneth</cc>
    
    <cc>koivisto</cc>
    
    <cc>rune</cc>
    
    <cc>yael</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>272621</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2010-08-31 21:28:05 -0700</bug_when>
    <thetext>180 of the 190 tests in the url fail. Firefox passes them all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>273961</commentid>
    <comment_count>1</comment_count>
      <attachid>66503</attachid>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2010-09-03 08:57:02 -0700</bug_when>
    <thetext>Created attachment 66503
Reduced testcase

It seems that sheet.cssRules does not include the @media at-rules in WebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>274046</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2010-09-03 11:15:57 -0700</bug_when>
    <thetext>There are several issues here.

First, we don&apos;t keep around empty CSSRules, so an empty @media rule doesn&apos;t show in sheet.cssRules. This patch fixes that:


diff --git a/WebCore/css/CSSMediaRule.cpp b/WebCore/css/CSSMediaRule.cpp
index d1c220b..9f8bb4a 100644
--- a/WebCore/css/CSSMediaRule.cpp
+++ b/WebCore/css/CSSMediaRule.cpp
@@ -40,9 +40,11 @@ CSSMediaRule::~CSSMediaRule()
     if (m_lstMedia)
         m_lstMedia-&gt;setParent(0);
 
-    int length = m_lstCSSRules-&gt;length();
-    for (int i = 0; i &lt; length; i++)
-        m_lstCSSRules-&gt;item(i)-&gt;setParent(0);
+    if (m_lstCSSRules) {
+        int length = m_lstCSSRules-&gt;length();
+        for (int i = 0; i &lt; length; i++)
+            m_lstCSSRules-&gt;item(i)-&gt;setParent(0);
+    }
 }
 
 unsigned CSSMediaRule::append(CSSRule* rule)
diff --git a/WebCore/css/CSSParser.cpp b/WebCore/css/CSSParser.cpp
index e20537a..4b5f620 100644
--- a/WebCore/css/CSSParser.cpp
+++ b/WebCore/css/CSSParser.cpp
@@ -5344,7 +5344,7 @@ CSSRule* CSSParser::createImportRule(const CSSParserString&amp; url, MediaList* medi
 
 CSSRule* CSSParser::createMediaRule(MediaList* media, CSSRuleList* rules)
 {
-    if (!media || !rules || !m_styleSheet)
+    if (!media || !m_styleSheet)
         return 0;
     m_allowImportRules = m_allowNamespaceDeclarations = m_allowVariablesRules = false;
     RefPtr&lt;CSSMediaRule&gt; rule = CSSMediaRule::create(m_styleSheet, media, rules);


Secondly, the error handling described here:
http://dev.w3.org/csswg/css3-mediaqueries/#error-handling
is not implemented.

Even with that, I don&apos;t understand the test. It seems to test that:

@media screen, not(orientation)

(which does not parse)
should result in @media screen, but I don&apos;t see how that is correct behavior, from the spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>274050</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-09-03 11:21:36 -0700</bug_when>
    <thetext>&gt; First, we don&apos;t keep around empty CSSRules, so an empty @media rule doesn&apos;t show in sheet.cssRules.

I think that&apos;s bug 15649.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>274055</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2010-09-03 11:22:58 -0700</bug_when>
    <thetext>Bug 15649 is about empty sheets, not empty @ rules.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>274060</commentid>
    <comment_count>5</comment_count>
    <who name="Daniel Glazman">daniel</who>
    <bug_when>2010-09-03 11:29:06 -0700</bug_when>
    <thetext>&gt; @media screen, not(orientation)
&gt;
&gt; (which does not parse)
&gt; should result in @media screen, but I don&apos;t see how that is correct behavior, &gt; from the spec.

The prose says the error handling cares about media queries. Here you
have a group of two media queries... So not(orientation) is invalid and
thrown away and screen is valid and preserved.
This was also discussed recently inside the CSS WG.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>274350</commentid>
    <comment_count>6</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2010-09-04 01:58:19 -0700</bug_when>
    <thetext>It is turned into &quot;not all&quot; actually. See the bit about &quot;Malformed media query&quot; under error handling.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>550786</commentid>
    <comment_count>7</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2012-02-07 03:32:58 -0800</bug_when>
    <thetext>*** Bug 77958 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>860184</commentid>
    <comment_count>8</comment_count>
    <who name="Rune Lillesveen">rune</who>
    <bug_when>2013-03-21 03:42:14 -0700</bug_when>
    <thetext>I&apos;m working on a patch that&apos;s for Media Queries error handling that&apos;s nearly finished. The Media Queries tests suite is using the media attribute which is currently split at commas, supporting HTML4 error handling, before fed into the CSS parser, so that needs to be fixed too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1875021</commentid>
    <comment_count>9</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-06-09 09:25:36 -0700</bug_when>
    <thetext>I tested attached test case with Safari 15.5 on macOS 12.4 and it shows dialog box with &quot;sheet has 1 rules&quot; and all other browsers (Chrome Canary 104 and Firefox Nightly 103) also show same behavior. I think it is now fixed since 2010 and can be marked as &quot;RESOLVED CONFIGURATION CHANGED&quot;. If I am incorrect, please ignore. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1875056</commentid>
    <comment_count>10</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2022-06-09 11:30:26 -0700</bug_when>
    <thetext>AFAICT passing this test does mean that the issue is fixed. Thank you for testing!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>66503</attachid>
            <date>2010-09-03 08:57:02 -0700</date>
            <delta_ts>2010-09-03 08:57:02 -0700</delta_ts>
            <desc>Reduced testcase</desc>
            <filename>set-media-query.html</filename>
            <type>text/html</type>
            <size>688</size>
            <attacher name="Simon Fraser (smfr)">simon.fraser</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+Cgo8aHRtbD4KPGhlYWQ+CiAgPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFz
Y3JpcHQiIGNoYXJzZXQ9InV0Zi04Ij4KICAgIAogICAgZnVuY3Rpb24gZG9UZXN0KCkgewogICAg
ICB2YXIgc3R5bGVFbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3R5bGUiKTsKICAg
ICAgc3R5bGVFbGVtZW50LnR5cGUgPSAidGV4dC9jc3MiOwogICAgICAvLyBwYXJzZV90ZXN0X3N0
eWxlX2VsZW1lbnQuZGlzYWJsZWQgPSB0cnVlOyAvLyBmb3IgcGVyZm9ybWFuY2UsIGhvcGVmdWxs
eQogICAgICB2YXIgc3R5bGVDb250ZW50cyA9IGRvY3VtZW50LmNyZWF0ZVRleHROb2RlKCJAbWVk
aWEgc2NyZWVuIHsgfSIpOwogICAgICBzdHlsZUVsZW1lbnQuYXBwZW5kQ2hpbGQoc3R5bGVDb250
ZW50cyk7CiAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCJoZWFkIilbMF0uYXBw
ZW5kQ2hpbGQoc3R5bGVFbGVtZW50KTsKCiAgICAgIHZhciBzaGVldCA9IHN0eWxlRWxlbWVudC5z
aGVldDsKICAgICAgYWxlcnQoJ3NoZWV0IGhhcyAnICsgc2hlZXQuY3NzUnVsZXMubGVuZ3RoICsg
JyBydWxlcycpOwogICAgfQogICAgCiAgICB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcignbG9hZCcs
IGRvVGVzdCwgZmFsc2UpOwogIDwvc2NyaXB0Pgo8L2hlYWQ+Cjxib2R5PgoKPC9ib2R5Pgo8L2h0
bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>