Skip to content
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

[cssom] Add tests for CSSGroupingRule#insertRule #17276

Merged

Conversation

jugglinmike
Copy link
Contributor

These tests are somewhat contentious due an inconsistency in the CSS
specification:

w3c/csswg-drafts#3528

@gsnedders
Copy link
Member

(Needs a rebase to pass CI, due to #17286. Sorry!)

@jugglinmike jugglinmike force-pushed the css-grouping-rule-insert-rule branch from aaf396a to 4ce782c Compare June 12, 2019 16:03
@jugglinmike
Copy link
Contributor Author

No problem. Rebased!

Copy link
Member

@zcorpan zcorpan left a comment

Choose a reason for hiding this comment

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

LGTM % 1 bug :)

var first = groupingRule.cssRules[0].cssText;

assert_throws('HierarchyRequestError', function() {
groupingRule.insertRule('@import url ("foo.css");', 0);
Copy link
Member

Choose a reason for hiding this comment

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

There shouldn't be a space between url and (

@jugglinmike
Copy link
Contributor Author

Thanks for your eagle eye, @zcorpan

@zcorpan
Copy link
Member

zcorpan commented Jun 26, 2019

Spec PR w3c/csswg-drafts#4057

@jugglinmike
Copy link
Contributor Author

@zcorpan noted that the two definitions differ in their use of [SameObject] on the cssRules property. Since the definition I'm proposing we persist specifies that, I've added a test to ensure that it's honored.

groupingRule.deleteRule('.baz {}', 0);
} catch (err) {}

assert_equals(groupingRule.cssRules.wptMarker, 'wpt');
Copy link
Member

Choose a reason for hiding this comment

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

This test could pass if the returned object is a new structured clone each time. Add a straight assert_equals on the object directly, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I based this off of existing CSSOM tests. Asserting object equality will require creating additional references, so I assumed this wasn't done as a way to promote garbage collection.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yeah, storing a reference would defeat the purpose of testing the effect of GC. But as-is it seems extremely unlikely for a GC to happen in the middle of running this test...

That said, I think this is good enough to merge.

These tests are somewhat contentious due an inconsistency in the CSS
specification:

w3c/csswg-drafts#3528
@jugglinmike jugglinmike force-pushed the css-grouping-rule-insert-rule branch from e31996f to 98dcdfd Compare July 2, 2019 01:30
@jugglinmike
Copy link
Contributor Author

Thanks for the review, @zcorpan. The spec change was accepted today, so I'll merge this myself.

@jugglinmike jugglinmike merged commit 814db84 into web-platform-tests:master Jul 2, 2019
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.

None yet

5 participants