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

change parse_own_css to queue event not fire synchronously #19307

Merged
merged 1 commit into from Dec 1, 2017

Conversation

@avadacatavra
Copy link
Contributor

avadacatavra commented Nov 21, 2017

fixes a panic and aligns with spec

I've also added checks around each mutable borrow of the tokenizer to see if we can catch any other panics


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #18930 (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Nov 21, 2017

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmlstyleelement.rs, components/script/dom/servoparser/mod.rs
  • @KiChjang: components/script/dom/htmlstyleelement.rs, components/script/dom/servoparser/mod.rs
@highfive
Copy link

highfive commented Nov 21, 2017

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@avadacatavra
Copy link
Contributor Author

avadacatavra commented Nov 21, 2017

r? jdm

@highfive highfive assigned jdm and unassigned wafflespeanut Nov 21, 2017
@@ -175,6 +175,7 @@ impl ServoParser {
document.set_current_parser(Some(&parser));
if !type_.eq_ignore_ascii_case("text/html") {
parser.parse_string_chunk("<pre>\n".to_owned());
assert!(parser.tokenizer.try_borrow_mut().is_ok());

This comment has been minimized.

@jdm

jdm Nov 21, 2017

Member

Asserting here is no different than performing the infallible borrow. Rather than adding these extra asserts everywhere, I would like a single API on ServoParser called something like parser_is_not_active (and an API on Document named something like can_invoke_script, which has access to the parser), and we should assert that that API returns true when we're asked to dispatch an event in EventTarget.

@avadacatavra avadacatavra force-pushed the avadacatavra:domrefcellpanic branch from c6a1549 to d8e0dba Nov 21, 2017
@avadacatavra
Copy link
Contributor Author

avadacatavra commented Nov 21, 2017

@jdm not sure if i should queue the events if the parser is in use?

@jdm
Copy link
Member

jdm commented Nov 21, 2017

No, we don't want to change behaviour based on this. We simply want to expose potential problems that could end up interacting with the parser if they invoke document.write.

Copy link
Member

jdm left a comment

To make sure this works locally, please run ./mach test-wpt workers/. This would have caught the problem with unwrapping the the downcast to Window, which doesn't work in a non-window global.

@@ -315,11 +315,35 @@ impl EventTarget {
pub fn dispatch_event_with_target(&self,
target: &EventTarget,
event: &Event) -> EventStatus {
event.dispatch(self, Some(target))

This comment has been minimized.

@jdm

jdm Nov 21, 2017

Member

Assert here, and let's match on target.global().downcast::<Window>() instead of trying Element (keeping in mind that None is valid).

}

pub fn dispatch_event(&self, event: &Event) -> EventStatus {
event.dispatch(self, None)

This comment has been minimized.

@jdm

jdm Nov 21, 2017

Member

Assert here, and do the same as the previous comment but using self.

@avadacatavra avadacatavra force-pushed the avadacatavra:domrefcellpanic branch from d8e0dba to 0269db1 Nov 21, 2017
@jdm
Copy link
Member

jdm commented Nov 21, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Nov 21, 2017

Trying commit 0269db1 with merge 553e4ea...

bors-servo added a commit that referenced this pull request Nov 21, 2017
change parse_own_css to queue event not fire synchronously

<!-- Please describe your changes on the following line: -->
fixes a panic and aligns with spec

I've also added checks around each mutable borrow of the tokenizer to see if we can catch any other panics

---
<!-- 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 #18930 (github issue number if applicable).

<!-- 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/19307)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 21, 2017

💔 Test failed - mac-rel-wpt3

@avadacatavra
Copy link
Contributor Author

avadacatavra commented Nov 21, 2017

@bors-servo retry

bors-servo added a commit that referenced this pull request Nov 21, 2017
change parse_own_css to queue event not fire synchronously

<!-- Please describe your changes on the following line: -->
fixes a panic and aligns with spec

I've also added checks around each mutable borrow of the tokenizer to see if we can catch any other panics

---
<!-- 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 #18930 (github issue number if applicable).

<!-- 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/19307)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 21, 2017

Trying commit 0269db1 with merge 167c884...

@bors-servo
Copy link
Contributor

bors-servo commented Nov 21, 2017

💔 Test failed - mac-rel-wpt3

@jdm jdm added S-needs-tests and removed S-awaiting-review labels Nov 27, 2017
@avadacatavra avadacatavra force-pushed the avadacatavra:domrefcellpanic branch 3 times, most recently from 7eafa4f to 62caa26 Nov 28, 2017
@avadacatavra avadacatavra force-pushed the avadacatavra:domrefcellpanic branch 3 times, most recently from d10cd00 to a6ecc75 Nov 29, 2017
Copy link
Member

jdm left a comment

Looks good!

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style onload="document.blah = true">
</style>

This comment has been minimized.

@jdm

jdm Nov 29, 2017

Member

This style block can be removed now.

@@ -0,0 +1,3 @@
;bug: https://github.com/servo/servo/issues/19392

This comment has been minimized.

@jdm

jdm Nov 29, 2017

Member

This (and the other ini file) should be:

[parser-fallsback-to-unknown-element.html]
  expected: CRASH
  bug: https://github.com/servo/servo/issues/19392
@@ -102,6 +102,10 @@ enum LastChunkState {
}

impl ServoParser {
pub fn parser_is_not_active(&self) -> bool {
self.tokenizer.try_borrow_mut().is_ok()

This comment has been minimized.

@jdm

jdm Nov 29, 2017

Member

Let's add || self.can_write(), so that this is handled correctly when #19393 is fixed.

@@ -315,10 +315,23 @@ impl EventTarget {
pub fn dispatch_event_with_target(&self,
target: &EventTarget,
event: &Event) -> EventStatus {
match target.global().downcast::<Window>() {
Some(window) => if window.has_document() {

This comment has been minimized.

@jdm

jdm Nov 29, 2017

Member

Let's use if let

event.dispatch(self, Some(target))
}

pub fn dispatch_event(&self, event: &Event) -> EventStatus {
match self.global().downcast::<Window>() {

This comment has been minimized.

@jdm

jdm Nov 29, 2017

Member

if let

@avadacatavra avadacatavra force-pushed the avadacatavra:domrefcellpanic branch from a6ecc75 to a1abe94 Nov 30, 2017
created checks to see if parser is in use before event dispatch

changed tests to expect crash and added async style test
@avadacatavra avadacatavra force-pushed the avadacatavra:domrefcellpanic branch from a1abe94 to 79d896d Nov 30, 2017
@jdm
Copy link
Member

jdm commented Dec 1, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Dec 1, 2017

📌 Commit 79d896d has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Dec 1, 2017

Testing commit 79d896d with merge 712d75a...

bors-servo added a commit that referenced this pull request Dec 1, 2017
change parse_own_css to queue event not fire synchronously

<!-- Please describe your changes on the following line: -->
fixes a panic and aligns with spec

I've also added checks around each mutable borrow of the tokenizer to see if we can catch any other panics

---
<!-- 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 #18930 (github issue number if applicable).

<!-- 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/19307)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Dec 1, 2017

@bors-servo bors-servo merged commit 79d896d into servo:master Dec 1, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
jdm added a commit to web-platform-tests/wpt that referenced this pull request Jan 4, 2018
created checks to see if parser is in use before event dispatch

changed tests to expect crash and added async style test

Upstreamed from servo/servo#19307 [ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.