-
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
Rewrite css/cssom-1/index-003 from generate_tests syntax #5263
Rewrite css/cssom-1/index-003 from generate_tests syntax #5263
Conversation
Notifying @dbaron, @lilles, @plinss, @rune-opera, @therealglazou, and @zcorpan. (Learn how reviewing works.) |
Firefox (nightly channel)Testing web-platform-tests at revision 1b4e7ca |
Chrome (unstable channel)Testing web-platform-tests at revision 1b4e7ca |
w3c-test:mirror |
css/cssom-1/cssom-ruleOrder.html
Outdated
@@ -16,6 +17,7 @@ | |||
<style id="s-2"> | |||
h1 { background: indianred; } | |||
</style> | |||
<!-- Unsure why the second of 2 rules is the test subject in #s-3 --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you unsure about here? To test namespace selectors it needs to define the namespace, hence if it wants to test how a namespace selector is serialised it needs a rule before it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless, the comment should go. Maybe with an explanation somewhere. Or both here and in the test function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The svg namespace is already defined in stylesheet #s-0
, was thinking that it didn't need to be declared again. But this may be my test-writing-newness showing, perhaps it needs to be directly in this stylesheet to be accurately tested?
css/cssom-1/cssom-ruleOrder.html
Outdated
for (var i = 0; i < stylesheets.length; i++) { | ||
test( function () { | ||
if (i === 3) { | ||
var cssType = stylesheets[i].cssRules.length > 0 && stylesheets[i].cssRules[1] ? stylesheets[i].cssRules[1].type : 11; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems overly complex (I realise this is pre-existing!); can it not just be stylesheets[i].cssRules.length > 1 ? stylesheets[i].cssRules[1].type : 11
?
Actually, I'm not sure why we have the conditional operator there at all. It just seems to be providing a default value so it has something to push to the old results
array and the check for the length is only needed to make sure it doesn't throw in case it fails (which we need in the generate_tests
case because otherwise it won't run any tests, which is the whole reason why it is far too fragile).
I think we can actually literally just do stylesheets[i].cssRules[1].type
(and similar, but 0, below), and accept that'll throw if for some reason we don't get the cssRules
we expect, but that'll be caught by the test and then it doesn't hide that problem.
As such, this seems like simplification worth doing while getting rid of generate_tests
.
css/cssom-1/cssom-ruleType.html
Outdated
}; | ||
|
||
for (var i = 0; i < stylesheets.length; i++) { | ||
test( function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems entirely identical to the test in cssom-ruleOrder.html
? Apart from renaming expectedRuleOrder
to expectedTypes
and changing the test name, it seems like nothing has changed here? As such, they're not actually testing anything different?
I don't really know what it's meant to be doing with rule order in the other, so should that be doing something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see a couple paths forward here. The original test is looking at 2 different things: 1) that the stylesheets are applied in the correct order and 2) that the evaluated types are correct. However, to test ORDER, it's actually checking to see if the evaluated TYPES are in the expected order, given the rules in the stylesheets. I think there could be a better way to test order, but that would be out of the scope of this particular PR.
Knowing this, the 2 options forward in my mind:
- Keep the tests separate, and in future find a better way to test order (maybe check to see that
.cssText
returns the expected rule?) - Recombine and not worry too much about update the rule order functionality; other fish to fry etc.
@gsnedders thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melanierichards However, the two things that are being tested essentially end up being tested in equivalent ways: to test the order, it's looking at the types; to test the types, it's looking at the order. As such, it seems kinda silly to make them separate. (I agree there's probably a better way but that's out-of-scope.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Word!
css/cssom-1/cssom-ruleOrder.html
Outdated
var expectedRuleOrder = [10, 3, 1, 1, 5, 4, 6]; | ||
|
||
var typesText = { | ||
1: 'style Rule', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be style rule
, all lowercase
css/cssom-1/cssom-ruleOrder.html
Outdated
<link rel="author" title="Divya Manian" href="mailto:manian@adobe.com"> | ||
<link rel="author" title="Melanie Richards" href="mailto:Melanie.Richards@microsoft.com"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to maintain author links (we have them all in git history, except in the case of old contributors who didn't have VCS access when the CSS testsuite was in CVS/SVN), and we have Divya as the original author in the file's history, so you're just as well off deleting it.
These tests are now available on w3c-test.org |
I suppose this now needs a rebase to move to /cssom/ |
Firefox (nightly)Testing web-platform-tests at revision 63afe441ce6f237c3eed0efdcfcdc41fc44b2070 All results1 test ran/cssom/cssom-ruleTypeAndOrder.html
|
Sauce (safari)Testing web-platform-tests at revision bd8e248 All results1 test ran/cssom/cssom-ruleTypeAndOrder.html
|
Chrome (unstable)Testing web-platform-tests at revision bd8e248 All results1 test ran/cssom/cssom-ruleTypeAndOrder.html
|
Sauce (MicrosoftEdge)Testing web-platform-tests at revision bd8e248 All results1 test ran/cssom/cssom-ruleTypeAndOrder.html
|
Also splits this test into 2 separate tests: cssom-ruleType and -ruleOrder Syntax changes to rule order and rule type based on feedback
0be66c5
to
f6ff583
Compare
@gsnedders sigh, it looks like every time I sync this branch it's just going to push all those changes back in again. I'm thinking maybe we rebase it (or whatever you did to clean things up) once we're all set on changes. This should be the only file that matters, really: https://github.com/w3c/web-platform-tests/pull/5263/files#diff-7dec3f0dbdac0fbf5b02bee5f3b1d0e9 |
@melanierichards You seem to have merged in the remote branch into yours instead of resetting to it. Try the following, with the branch checked out:
Basically: reset the branch to point at the tidied up version from last week, copy in your commit from Friday, and push that cleaned up branch with only those commits to GitHub. |
e49b430
to
1df2d68
Compare
✨ Diffs are now squeaky clean ✨ Thanks for the help, @gsnedders! |
Thank you! ❤️ |
Also splits this test into 2 separate tests: cssom-ruleType and -ruleOrder
I'm assuming there's no reason why @zcorpan didn't merge this before (waiting for CI from his commit?). |
In an effort to help @gsnedders bring the CSS tests into the fold with the current syntax, this PR removes the
generate_tests()
syntax fromcss/cssom-1/index-003.html
. In order to improve clarity for future testers, the old test has been split into two files named for the two concepts being tested:cssom-ruleOrder.html
andcssom-ruleType.html
. There are perhaps additional updates that can be made to these tests, but the main goal of this PR is to removegenerate_tests()
.