Skip to content

Parsing tests for CSS UI Level 3 - #10700

Merged
ewilligers merged 2 commits into
web-platform-tests:masterfrom
ewilligers:css-ui3-parsing
May 2, 2018
Merged

ewilligers merged 2 commits into
web-platform-tests:masterfrom
ewilligers:css-ui3-parsing

Conversation

Comment thread css/css-ui/parsing/outline-valid.html Outdated
test_valid_value("outline", "rgba(10, 20, 30, 0.4)");

test_valid_value("outline", "auto");
test_valid_value("outline", "none", ["none", "invert"]); // Edge serializes as "invert"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think serializing as invert should pass this test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if it does, please leave a comment with the reasoning from the spec text.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now omitted "invert" as an accepted serialization.

Comment thread css/css-ui/parsing/outline-valid.html Outdated
test_valid_value("outline", "1px");
test_valid_value("outline", "calc(2em + 3ex)");
test_valid_value("outline", "thin");
test_valid_value("outline", "medium", ["medium", "invert"]); // Edge serializes as "invert"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 28, 2018
This is going to be tested in
web-platform-tests/wpt#10700.

MozReview-Commit-ID: 7Oi1it70YFw

--HG--
extra : rebase_source : 4c4e738ceaec32750ae0c5aa0308c17346806b3a
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 28, 2018
emilio added a commit to emilio/servo that referenced this pull request Apr 29, 2018
This is going to be tested in
web-platform-tests/wpt#10700.

Bug: 1457652
Reviewed-by: xidorn
MozReview-Commit-ID: 7Oi1it70YFw

@frivoal frivoal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I thought that this looks good (modulo the few minor fixes I've requested).

That said, separately from evaluating the correctness of these tests, I have a little bit of concern about the effects of testing syntax only, as this series of tests does.

Quite a lot of this (most of the *-valid.html) tests are redundant with existing tests, as the existing ones couldn't pass if valid syntax wasn't supported (exceptions for things like checking calc(), which may not have full coverage in the existing test suite). But a fair amount of the existing tests are also manual (and hard/impossible to convert), and there's value in automated checking.

However, in the past, browsers have on occasion added parsing support for some property/values without actually adding the corresponding behavior:

  • implement syntax first, behavior later
  • make a syntax improvement that affects several properties, implement the behavior only in some of them (this is a subcase of the previous point)
  • implement both syntax and behavior, maintain the parsing well but let the behavior bitrot and eventually fall apart

That sort of things makes it hard for web developers to provide fallbacks, either using the cascade or @supports, since they cannot reliably detect whether the feature is actually supported.

Because of this, I am a little concerned about syntax-only tests, which make it looks like implementing syntax only is an improvement, while it is actually a source of problems.

Those that test for invalid syntax are fine, as this concern does not apply, and those that are known to catch actual browser bugs are especially useful.

But for those that test for valid syntax, I am a little less sure:

  • if the effects of the property/value can be automatically tested, aren't those tests enough and more safe?
  • if the effects of the property/value cannot be automatically tested, how do we avoid turning this into a temptation to support syntax without behavior?

Here's one example of how things could go wrong here: a browser who has no interest in supporting actual inverted color outlines implements support for parsing outline:invert without the behavior, just to make a test go green. The acceptable behaviors (parse and do it, or fail to parse) are already covered in outline-006.html, so maybe that test provides the necessary safety. At the same time, given that that test exists, do we need parsing-only tests for invert?

I wonder what's the best approach. Here are a few suggestions:

  1. the parts of of *-valid tests that check that things are not serialized to some known-to-be incorrect value are useful, (e.g. test_valid_value("outline", "none"); // Edge serializes as "invert", or the tests that mozilla fails due to incorrect ordering or not using the shortest serialization), but they could be changed from "assert equals the correct thing" to "assert not equal the known-to-be-wrong thing".
  2. make reftests for the parts of *-valid tests that can and that that are not already covered in the test suite (e.g. calc in outline)
  3. drop the rest of -valid tests

(we should probably do 2. anyway, and possibly also 1., even if we don't plan to do 3.)

I know this isn't very satisfying, because this series of test is nice on its own, and some parts that would be dropped are only covered in manual tests. But the concern remains.

We could add warnings in the tests ("if this fails, don't fix it unless you also make sure that <a href="...">other test&lt:/a> also passes"), but I am far from sure this would be effective.

Or maybe we just trust that reason will prevail and browser developers will not do the bad things I'm worried about. But as it has happened in the past, I am a little nervous about providing incentives (in the form of failing tests) for the unfortunate behavior.

Or maybe I'm just paranoid, and this is fine. Feedback appreciated.

CCing a few CSS tests gurus for opinions: @fantasai @gsnedders @dbaron @Ms2ger

<body>
<script>
test_valid_value("outline-color", "rgba(10, 20, 30, 0.4)");
test_valid_value("outline-color", "invert");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the spec, support for the "invert" value is not mandatory:

Conformant UAs may ignore the invert value on platforms that do not support color inversion of the pixels on the screen.

If the UA does not support the invert value then it must reject that value at parse-time, and the initial value of the outline-color property is the currentColor keyword.

I suggest splitting this test in two: outline-color-valid-mandatory.html and outline-color-valid-optional.html, with the later having <meta name="flags" content="may">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<title>CSS UI Level 3: parsing outline with valid values</title>
<link rel="author" title="Eric Willigers" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-ui-3/#outline">
<meta name="assert" content="outline supports the full grammar '<outline-color> || <outline> || <outline>'.">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does a more that checking if the full grammar is supported, it also checks if the serialization follows the principles of https://drafts.csswg.org/cssom/#serializing-css-values (canonical order, shortest possible serialization).

Can you update the assert to say so, and add
<link rel="help" href="https://drafts.csswg.org/cssom/#serializing-css-values">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, but that applies applies to nearly all the -valid tests.

Comment thread css/css-ui/parsing/outline-valid.html Outdated
</head>
<body>
<script>
test_valid_value("outline", "invert");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for outline-color-valid.html:

Per the spec, support for the "invert" value is not mandatory:

Conformant UAs may ignore the invert value on platforms that do not support color inversion of the pixels on the screen.

If the UA does not support the invert value then it must reject that value at parse-time, and the initial value of the outline-color property is the currentColor keyword.

I suggest splitting this test in two: outline-valid-mandatory.html and outline-valid-optional.html, with the later having <meta name="flags" content="may">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@frivoal frivoal added the wg-css label Apr 30, 2018
@ewilligers

Copy link
Copy Markdown
Contributor Author

@fantasai has made a similar comment about the dangers of parsing tests.

However, these parsing/serialization tests have been finding bugs in all implementations and have prompted fixes in a couple. This suggests their value.

@emilio

emilio commented Apr 30, 2018

Copy link
Copy Markdown
Contributor

I don't think any browser implementer would seriously consider shipping syntax first without any behavior, is there any precedent for that?

@emilio

emilio commented Apr 30, 2018

Copy link
Copy Markdown
Contributor

(Apart from WebKit shipping parsing of display: contents but only honoring it on <slot>s, but that had a lot of other implications).

@gsnedders

Copy link
Copy Markdown
Member

@frivoal

Because of this, I am a little concerned about syntax-only tests, which make it looks like implementing syntax only is an improvement, while it is actually a source of problems.

Note we essentially have the same issue with everything using idlharness.js: you get thousands of tests passing if you dump the IDL file in your tree and your binding generation is correct.

It's never been the case that number of tests passed has ever been meaningful (because we have both extremes in various places: ones where you can have 99.9% of the spec correct and fail almost everything, and ones where you can have 0.1% of the spec correct and pass almost everything), and I don't think we should start worrying about it now.

Ideally, we'd have something analogue to idlharness.js for CSS (where you give the property value definition and it generates however many tests for the syntax being supported), which is #9113.

We know these tests catch issues, so we absolutely should have them.

@FremyCompany

FremyCompany commented Apr 30, 2018 •

Copy link
Copy Markdown
Contributor

how do we avoid turning this into a temptation to support syntax without behavior?

I think this is a valid concern in theory, but not really an issue in practice. Speaking for Edge here, tests aren't ever going to be the reason we would do this. There is nothing worse than gaining a few points on a test suite with a fake implementation that later causes you to have a bug on a real website. No user is ever looking at test suites, users look at real sites.

Now, it's totally possible that Edge would ship syntax even if it doesn't support its behavior, for instance if we face real websites being broken (we have shipped getMatchedCssRules as a function returning null because some website called it and crashed if the function didn't exist but never actually used the results for anything, and from that day on we have been working with Chrome to have them remove this feature, and they finally did, so we will be able to remove this shim from our code too, yeah!). But as horrible as these kind of stories are, I don't think anyone here would consider passing a wpt test important enough to actually ship a broken feature. Broken behaviors can break real sites, we don't want to take that risk.

FWIW though, I was doing exactly this right now in a prototype pull request because Edge does not parse cursor: url(...) <number> <number>, fallback because we don't support cursors that are not of the *.cur format which doesn't need these numbers; however since we don't parse it, we don't even get the fallback value in Edge, so it's worth parsing these numbers even if we don't use them; these tests made me realize I hadn't thought about parsing calc() for a number so I'd say they were actually useful.

@frivoal

frivoal commented May 1, 2018

Copy link
Copy Markdown
Contributor

side discussion
@FremyCompany Your case with cursor and numbers is interesting. For non .cur cursors, this is an improvements and gives a better fallback. For .cur, in theory the two numbers allow authors to override the embedded hotspot, and your fix prevents them from being able to detect that this won't work. But I guess this is sufficiently rare that it's worth doing anyway. I'd be nice if you fully supported the explicit hotspot coordinate, though. Also, don't you support the .ico format in addition to .cur, and this doesn't have built-in coordinates?

@frivoal

frivoal commented May 1, 2018

Copy link
Copy Markdown
Contributor

@gsnedders

It's never been the case that number of tests passed has ever been meaningful [...] and I don't think we should start worrying about it now.

I agree it's never been meaningful, but that's different from saying that nobody is every influenced by them.

[there are specs where] you can have 99.9% of the spec correct and fail almost everything, and ones where you can have 0.1% of the spec correct and pass almost everything

Right, but I argue parsing-only tests are worse. They tests mean that on the same spec and test suite, you can make things worse by increasing the pass rate.

Now, @fantasai said

Please don't add tests for any CSS features that detect only parsing-level [...] unless there's a corresponding test for functional support

As far as I can tell, except those that test for invalid syntax (which are fine), almost all the rest does have corresponding tests for functional support, even though some of these tests are manual. ("almost all": I think the only exception are tests involving calc).

CSS-UI is a bit special, given the large amount of non-automatable tests that it has. So I guess that the automated syntax tests are valuable there.

But for the other tests that cover things already covered by a ref-test, I am unsure what the value is.

@frivoal

frivoal commented May 1, 2018

Copy link
Copy Markdown
Contributor

I think this is a valid concern in theory, but not really an issue in practice.

I am not sure (I mean, literally, I don't mean that I am sure of the opposite).

Multiple browsers have in the past made parsing only implementations (and I am not talking about the deliberate kind of things like parsing the hotspot of the cursor, which can be argued for).

Multiple browsers have, on occasion, made races out of completing a test suite or having the highest pass percentage or score.

Should people know better? Totally. Do people still fall for it on occasion? I don't know for sure, but I'd guess so. Maybe junior developers. Maybe not-so-junior developers under pressure from a marketing team.

I wouldn't go as far as to say parsing-only tests should never exist, but I don't think they should be routine, and we need to weight the pros and cons each time.

Here, I'm thinking the ones that correspond to things that can only be tested manually are probably good ideas. The rest, I am less sure.

@frivoal frivoal mentioned this pull request May 1, 2018
@csnardi

csnardi commented May 1, 2018

Copy link
Copy Markdown
Member

I echo others who have already stated that these tests are useful. Similar tests have exposed bugs in implementations such as https://crbug.com/776208, where Chrome allowed syntax that was explicitly rejected by the spec, and areas where serialization differs between browsers (due to implementations or the spec being unclear). While testing that output via content is important, testing interoperability of syntax and serialization through CSSOM/Typed OM is additionally important, and thus both types of tests are needed.

@frivoal frivoal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, given that lots of people find these useful, and given the unique situation of css-ui (many manual tests), I'll stop complaining about these :) Approved.

I'll redirect my energy about this concern to #9113

@ewilligers
ewilligers merged commit c83c53e into web-platform-tests:master May 2, 2018
@ewilligers
ewilligers deleted the css-ui3-parsing branch May 2, 2018 03:30
Moggers pushed a commit to Moggers/servo that referenced this pull request Jun 13, 2018
This is going to be tested in
web-platform-tests/wpt#10700.

Bug: 1457652
Reviewed-by: xidorn
MozReview-Commit-ID: 7Oi1it70YFw
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 2, 2019
This is going to be tested in
web-platform-tests/wpt#10700.

MozReview-Commit-ID: 7Oi1it70YFw

UltraBlame original commit: 2a03e9effe84d574a0dfdaaefd9bde2f69df6d0e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 2, 2019
This is going to be tested in
web-platform-tests/wpt#10700.

MozReview-Commit-ID: 7Oi1it70YFw

UltraBlame original commit: 807e94988d9a9563504d6b3751562fdbbde13084
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
This is going to be tested in
web-platform-tests/wpt#10700.

MozReview-Commit-ID: 7Oi1it70YFw

UltraBlame original commit: 2a03e9effe84d574a0dfdaaefd9bde2f69df6d0e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
This is going to be tested in
web-platform-tests/wpt#10700.

MozReview-Commit-ID: 7Oi1it70YFw

UltraBlame original commit: 807e94988d9a9563504d6b3751562fdbbde13084
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
This is going to be tested in
web-platform-tests/wpt#10700.

MozReview-Commit-ID: 7Oi1it70YFw

UltraBlame original commit: 2a03e9effe84d574a0dfdaaefd9bde2f69df6d0e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
This is going to be tested in
web-platform-tests/wpt#10700.

MozReview-Commit-ID: 7Oi1it70YFw

UltraBlame original commit: 807e94988d9a9563504d6b3751562fdbbde13084
bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this pull request May 1, 2025
bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this pull request May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants