This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23188 - Validator / test suite CSS media query bugs
Summary: Validator / test suite CSS media query bugs
Status: RESOLVED FIXED
Alias: None
Product: HTML Checker
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael[tm] Smith
QA Contact: qa-dev tracking
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-09 16:33 UTC by Mark Rogers
Modified: 2013-09-16 21:35 UTC (History)
1 user (show)

See Also:


Attachments

Description Mark Rogers 2013-09-09 16:33:51 UTC
There are a couple of test suite problems related to white space in CSS media queries:

1) Validator.nu (and media-queries/018-novalid.html) expects media='screen and (device-aspect-ratio: 16 / 9)' to be a failure due to whitespace in "16 / 9". My reading of the spec is that whitespace is allowed in the ratio:
http://www.w3.org/TR/css3-mediaqueries/#aspect-ratio
(The media query from the test failure passes in jigsaw.w3.org)

2) Validator.nu (and media-queries/012-novalid.html) expects "screen and (min-width: 400px)and (max-width: 600px)" to fail due to missing whitespace before the 'and'. My reading of the spec is that whitespace (the S* production) is optional:
http://www.w3.org/TR/css3-mediaqueries/#syntax
(The media query from the test failure passes in jigsaw.w3.org)

PS Have a few more like this - I'll probably report them over the next few weeks.

Best Regards
Mark

Mark Rogers - mark.rogers@powermapper.com
PowerMapper Software Ltd - www.powermapper.com 
Registered in Scotland No 362274 Quartermile 2 Edinburgh EH3 9GL
Comment 1 Michael[tm] Smith 2013-09-10 07:17:27 UTC
(In reply to Mark Rogers from comment #0)
> There are a couple of test suite problems related to white space in CSS
> media queries:
> 
> 1) Validator.nu (and media-queries/018-novalid.html) expects media='screen
> and (device-aspect-ratio: 16 / 9)' to be a failure due to whitespace in "16
> / 9". My reading of the spec is that whitespace is allowed in the ratio:
> http://www.w3.org/TR/css3-mediaqueries/#aspect-ratio
> (The media query from the test failure passes in jigsaw.w3.org)

Yeah, the current spec does say:

http://www.w3.org/TR/css3-mediaqueries/#values
"The <ratio> value is a positive (not zero or negative) <integer> followed by optional whitespace, followed by a solidus (‘/’), followed by optional whitespace, followed by a positive <integer>."

So we'll need to update the media-queries checker in the validator to match that.

At the time the media-queries checker was implemented in the validator, the spec said, "The value consists of two positive integers separated by a ‘/’." (nothing about whitespace).

But that was a long time ago:
http://www.w3.org/TR/2007/CR-css3-mediaqueries-20070606/#device-aspect-ratio

So it's likely there are other places where we're not up to date with the current spec.

Anyway, I'll fix the <ratio> case as soon as possible.


> 2) Validator.nu (and media-queries/012-novalid.html) expects "screen and
> (min-width: 400px)and (max-width: 600px)" to fail due to missing whitespace
> before the 'and'. My reading of the spec is that whitespace (the S*
> production) is optional:
> http://www.w3.org/TR/css3-mediaqueries/#syntax

Yeah, agreed. The BNF there says:

media_query
 : [ONLY | NOT]? S* media_type S* [ AND S* expression ]*
 | expression [ AND S* expression ]*
 ;
expression
 : '(' S* media_feature S* [ ':' S* expr ]? ')' S*
 ;

...which seems to clearly define the whitespace before the "and" as optional everywhere, as well as the whitespace after the "and" (right?).

> (The media query from the test failure passes in jigsaw.w3.org)

Yeah. Though I note that the following doesn't pass on jigsaw.w3.org:

  @media screen and (min-width: 400px) and(max-width: 600px) {}

...I guess because jigsaw expects whitespace after the "and" there.
 
> PS Have a few more like this - I'll probably report them over the next few
> weeks.

Please do keep 'em coming. In the mean time, I'll try to fix these two.
Comment 2 Michael[tm] Smith 2013-09-10 11:17:03 UTC
(In reply to Michael[tm] Smith from comment #1)
> (In reply to Mark Rogers from comment #0)
> > 2) Validator.nu (and media-queries/012-novalid.html) expects "screen and
> > (min-width: 400px)and (max-width: 600px)" to fail due to missing whitespace
> > before the 'and'. My reading of the spec is that whitespace (the S*
> > production) is optional:
> > http://www.w3.org/TR/css3-mediaqueries/#syntax
> 
> Yeah, agreed. The BNF there says:
> 
> media_query
>  : [ONLY | NOT]? S* media_type S* [ AND S* expression ]*
>  | expression [ AND S* expression ]*
>  ;
> expression
>  : '(' S* media_feature S* [ ':' S* expr ]? ')' S*
>  ;

Actually, I'm wrong. We should pretty much never use any documents in http://www.w3.org/TR/ as the latest authority for requirements. The TR drafts for most Web-platform technologies are almost always out of date. In this case it's been pointed out to me that the latest media-queries spec is at http://dev.w3.org/csswg/mediaqueries4/

And if you look at http://dev.w3.org/csswg/mediaqueries4/#syntax you'll see that says:

media_query
 : [ONLY S+ | NOT S+]? media_type [ S+ AND S+ expression ]* S*
 | expression [ S+ AND S+ expression ]* S*
 ;

So the whitespace around "and" is now (again) required, both before "and" and after it.

So the existing validator behavior (still) conforms to the latest media-queries spec for this case, and the media-queries/012-novalid.html document is in the test suite is till not valid.


> 
> ...which seems to clearly define the whitespace before the "and" as optional
> everywhere, as well as the whitespace after the "and" (right?).
> 
> > (The media query from the test failure passes in jigsaw.w3.org)
> 
> Yeah. Though I note that the following doesn't pass on jigsaw.w3.org:
> 
>   @media screen and (min-width: 400px) and(max-width: 600px) {}
> 
> ...I guess because jigsaw expects whitespace after the "and" there.
>  
> > PS Have a few more like this - I'll probably report them over the next few
> > weeks.
> 
> Please do keep 'em coming. In the mean time, I'll try to fix these two.
Comment 3 Michael[tm] Smith 2013-09-10 11:21:13 UTC
(In reply to Michael[tm] Smith from comment #2)
> And if you look at http://dev.w3.org/csswg/mediaqueries4/#syntax you'll see
> the whitespace around "and" is now (again) required, both before "and"
> and after it.

See also http://www.w3.org/Style/2012/REC-mediaqueries-20120619-errata.html
Comment 4 Michael[tm] Smith 2013-09-16 21:35:49 UTC
(In reply to Mark Rogers from comment #0)
> There are a couple of test suite problems related to white space in CSS
> media queries:
> 
> 1) Validator.nu (and media-queries/018-novalid.html) expects media='screen
> and (device-aspect-ratio: 16 / 9)' to be a failure due to whitespace in "16
> / 9". My reading of the spec is that whitespace is allowed in the ratio:

I've fixed that now in the code and pushed the change to the W3C validator.

> 2) Validator.nu (and media-queries/012-novalid.html) expects "screen and
> (min-width: 400px)and (max-width: 600px)" to fail due to missing whitespace
> before the 'and'. My reading of the spec is that whitespace (the S*
> production) is optional:

As I noted in earlier comments, the latest MQ spec once again makes that whitespace required, not optional. So I'm going ahead and closing this bug. To report other issues with MQ checking in validator, please raise other bugs.