-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test computed styles from user agent stylesheet? #5625
Comments
There are some normative statements about default UA rules in CSS specs as well. Typically new stuff that isn't stable enough yet to ask HTML to add to its stylesheet, or stuff that goes into SVG's style sheet rather than HTML's. |
The CSS Working Group just discussed The full IRC log of that discussion<astearns> topic: testing user agent stylesheets<astearns> https://github.com//issues/5625 <TabAtkins> GitHub topic: https://github.com//issues/5625 <surma> astearns: Should we have tests for UA stylesheets? <surma> dbaron: It’s a good idea. But some results might be an issue against the HTML spec rather than the UA <surma> fantasai: Maybe the UA stylesheet tests should migrate to HTML <fantasai> s/tests/statements/ <dbaron> xidorn: test cascade level? <dbaron> dbaron: There are a lot of known issues where what's in the UA level vs. the preshint level doesn't match the spec, since the reverse engineering didn't really consider that, I don't think. <surma> astearns: so general agreement? <surma> [yes] |
@dbaron HTML's rendering section differentiates UA styles and preshints. I'm not sure if they all match implementations, and it's a bit annoying to test since you need a user stylesheet to tell the difference I believe. |
I'd like to ask the WPT/CSS community's opinion on how to write tests for this sort of thing. I have two ideas so far:
I am leaning toward the second option here. |
Note: I realized that computedStyleMap() tests are better for this purpose than getComputedStyle() tests. |
I've tried to attempt this several times in the past, but hadn't found a way that would scale usefully. But now I might be on to something. Check this out: The CSS can be taken verbatim from the spec (or imported to wpt like IDL files are). Then the The test includes the HTML elements we want to test. A script clones those elements, where the clones have the bogus namespace, and thus the CSS only apply to the clones, and any CSS property not included will have the CSS initial value. The test could then compare all of the CSS properties that we're interested in comparing. Problems:
|
That's a pretty neat trick! To be clear, 70b4ec4 only tests a subset of properties, but you'd be proposing testing them all, right? Cf. Lines 14 to 38 in b8cdc9b
wpt/std-toast/resources/helpers.js Lines 73 to 85 in b8cdc9b
Post-processing seems reasonable, or just manually fixing the tests up as necessary. |
Yes, the test I wrote now is a small subset, but I think the approach can scale to all or almost all of the CSS rules in the HTML Rendering section, and all HTML elements (across multiple test files, to not end up with too many tests in one file). |
Inspired by whatwg/html#2561 (comment).
The HTML Standard contains a supposedly-normative user agent stylesheet. I've also seen non-normative appendices in various CSS specs; not sure what that's about.
In theory this should be testable by using getComputedStyle() on various elements.
In practice I know Blink's UA stylesheet doesn't match the spec super-great. I can't imagine others do either (maybe Servo?). In a large part this is because some of the stuff the spec specifies in CSS is implemented in non-CSS ways. (See one attempt to align in whatwg/html#2298; I should probably get back to that...)
Is this an area worth investing in tests for, and trying to align browsers?
The text was updated successfully, but these errors were encountered: