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

Expose public getter to stylesheet's owner #23073

Merged
merged 1 commit into from Mar 23, 2019
Merged

Conversation

@sbansal3096
Copy link
Contributor

@sbansal3096 sbansal3096 commented Mar 21, 2019

  • expose a public getter on CSSStyleSheet to return the stylesheet's owner
  • in CSSRuleList::insert_rule, use the new getter to pass a non-None value as an argument to arc.insert_rule
  • add a test for this that verifies that the new stylesheet is actually loaded

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #23028
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

@highfive highfive commented Mar 21, 2019

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @paulrouget (or someone else) soon.

@highfive
Copy link

@highfive highfive commented Mar 21, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/cssstylesheet.rs, components/script/dom/cssrulelist.rs
  • @KiChjang: components/script/dom/cssstylesheet.rs, components/script/dom/cssrulelist.rs

@highfive
Copy link

@highfive highfive commented Mar 21, 2019

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@sbansal3096
Copy link
Contributor Author

@sbansal3096 sbansal3096 commented Mar 21, 2019

@jdm I am still to add tests. Can you check the work done till now?

@jdm
Copy link
Member

@jdm jdm commented Mar 21, 2019

That looks like what I expected to see :)

@sbansal3096
Copy link
Contributor Author

@sbansal3096 sbansal3096 commented Mar 21, 2019

That looks like what I expected to see :)

@jdm
Cool! Thanks
Can you help me a bit in writing tests? I am new to the community.

@jdm
Copy link
Member

@jdm jdm commented Mar 21, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 21, 2019

Trying commit e01e4a8 with merge b6824cd...

bors-servo added a commit that referenced this issue Mar 21, 2019
Work in Progress

<!-- Please describe your changes on the following line: -->

- [x] expose a public getter on CSSStyleSheet to return the stylesheet's owner
- [x] in CSSRuleList::insert_rule, use the new getter to pass a non-None value as an argument to arc.insert_rule
- [ ] add a test for this that verifies that the new stylesheet is actually loaded
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #23028

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23073)
<!-- Reviewable:end -->
@jdm
Copy link
Member

@jdm jdm commented Mar 21, 2019

The idea of the test we want to write is the following:

  • there is a <style> element in the page
  • we use the insertRule API to add a new rule to this element's stylesheet
  • the new rule inserted is an @import rule that causes a new stylesheet to be loaded

Just having these steps complete successfully will mean that the crash is fixed. However, we also want to test that the imported stylesheet is loaded. Therefore, if the loaded stylesheet contains a CSS style that changes the CSS property of an element on the page, we can compare the expected rendering output against a test page that is supposed to match. This is called a reference test.

We can add the test to tests/wpt/web-platform-tests/css/cssom, and see an example of another reference test in that directory here. We can use the code from the testcase in #23028 as the basis for this new test.

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 21, 2019

💔 Test failed - linux-rel-wpt

@jdm
Copy link
Member

@jdm jdm commented Mar 21, 2019

The nice thing is that there's already a test that exercises this code, and it no longer crashes:

  ▶ OK [expected CRASH] /css/cssom/insertRule-namespace-no-index.html

@servo-wpt-sync
Copy link
Collaborator

@servo-wpt-sync servo-wpt-sync commented Mar 21, 2019

Opened new PR for upstreamable changes.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#15987.

@sbansal3096 sbansal3096 changed the title Work in Progress Expose public getter to stylesheet's owner Mar 21, 2019
@sbansal3096
Copy link
Contributor Author

@sbansal3096 sbansal3096 commented Mar 21, 2019

@jdm I added test on the basis of the test case you provided me.

@servo-wpt-sync
Copy link
Collaborator

@servo-wpt-sync servo-wpt-sync commented Mar 22, 2019

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#15987.

tests/wpt/web-platform-tests/css/css Outdated Show resolved Hide resolved
@servo-wpt-sync
Copy link
Collaborator

@servo-wpt-sync servo-wpt-sync commented Mar 22, 2019

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at web-platform-tests/wpt#15987.

@CYBAI
Copy link
Member

@CYBAI CYBAI commented Mar 22, 2019

@bors-servo try=wpt

  • Let's try to see the test result! 👀

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

Trying commit 66225fa with merge 9d87c1c...

bors-servo added a commit that referenced this issue Mar 22, 2019
Expose public getter to stylesheet's owner

<!-- Please describe your changes on the following line: -->

- [x] expose a public getter on CSSStyleSheet to return the stylesheet's owner
- [x] in CSSRuleList::insert_rule, use the new getter to pass a non-None value as an argument to arc.insert_rule
- [x] add a test for this that verifies that the new stylesheet is actually loaded
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23028

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23073)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

💔 Test failed - linux-rel-wpt

@CYBAI
Copy link
Member

@CYBAI CYBAI commented Mar 22, 2019

You would want to label this test case as OK :) In this case, you can just remove the tests/wpt/metadata/css/cssom/insertRule-namespace-no-index.html.ini file!

{
    "status": "OK", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": null, 
    "test": "/css/cssom/insertRule-namespace-no-index.html", 
    "line": 86887, 
    "action": "test_result", 
    "expected": "CRASH"
}

Also, you'd want to add a spec link to the new WPT test.

$ ./mach test-tidy --no-progress --all
 0:09.77 INFO Diffing old and new manifests /home/travis/build/servo/servo/tests/wpt/mozilla/meta/MANIFEST.json
 0:09.93 INFO Diffing old and new manifests /home/travis/build/servo/servo/tests/wpt/metadata/MANIFEST.json
 0:16.46 INFO Diffing old and new manifests /home/travis/build/servo/servo/tests/wpt/webgl/meta/MANIFEST.json
Checking the config file...
Checking the wpt manifest file...
Checking directories for correct file extensions...
Running the WPT lint on ./tests/wpt/web-platform-tests/...
{"path": "css/cssom/stylesheet-owner.html", "message": "Testcase file must have a link to a spec", "lineno": null, "rule": "MISSING-LINK"}
WPT Lint Tool:: lint error(s) in Web Platform Tests: exit status 1
Running the WPT lint on ./tests/wpt/mozilla/tests/...
...
The command "./mach test-tidy --no-progress --all" exited with 1.

Besides, could you squash all the commits :)?

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

Trying commit 13eebbf with merge 549b5ec...

bors-servo added a commit that referenced this issue Mar 22, 2019
Expose public getter to stylesheet's owner

<!-- Please describe your changes on the following line: -->

- [x] expose a public getter on CSSStyleSheet to return the stylesheet's owner
- [x] in CSSRuleList::insert_rule, use the new getter to pass a non-None value as an argument to arc.insert_rule
- [x] add a test for this that verifies that the new stylesheet is actually loaded
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23028

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23073)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

💔 Test failed - linux-rel-css

@CYBAI
Copy link
Member

@CYBAI CYBAI commented Mar 22, 2019

💔 Test failed - linux-rel-css

Failed with #13480

emilio
emilio approved these changes Mar 22, 2019
Copy link
Member

@emilio emilio left a comment

Looks good, sounds like Servo still doesn't support ownerNode, right? If so, at that point self.owner may need to become an Option<> ... But anyhow, this looks good on its own. Thanks for fixing this!

@emilio
Copy link
Member

@emilio emilio commented Mar 22, 2019

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

📌 Commit 13eebbf has been approved by emilio

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

Testing commit 13eebbf with merge 7e5758b...

bors-servo added a commit that referenced this issue Mar 22, 2019
Expose public getter to stylesheet's owner

<!-- Please describe your changes on the following line: -->

- [x] expose a public getter on CSSStyleSheet to return the stylesheet's owner
- [x] in CSSRuleList::insert_rule, use the new getter to pass a non-None value as an argument to arc.insert_rule
- [x] add a test for this that verifies that the new stylesheet is actually loaded
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23028

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23073)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

💔 Test failed - status-taskcluster

@CYBAI
Copy link
Member

@CYBAI CYBAI commented Mar 22, 2019

@bors-servo retry

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

💣 Failed to start rebuilding: Unknown error

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 22, 2019

Testing commit 13eebbf with merge 059ac12...

bors-servo added a commit that referenced this issue Mar 22, 2019
Expose public getter to stylesheet's owner

<!-- Please describe your changes on the following line: -->

- [x] expose a public getter on CSSStyleSheet to return the stylesheet's owner
- [x] in CSSRuleList::insert_rule, use the new getter to pass a non-None value as an argument to arc.insert_rule
- [x] add a test for this that verifies that the new stylesheet is actually loaded
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #23028

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23073)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Mar 23, 2019

@bors-servo bors-servo merged commit 13eebbf into servo:master Mar 23, 2019
4 checks passed
@servo-wpt-sync
Copy link
Collaborator

@servo-wpt-sync servo-wpt-sync commented Mar 23, 2019

Error syncing changes upstream. Logs saved in error-snapshot-1553302774944.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

8 participants