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 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


  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

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

warning Warning warning

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

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 21, 2017
@avadacatavra
Copy link
Contributor Author

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());
Copy link
Member

Choose a reason for hiding this comment

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

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.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 21, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Nov 21, 2017
@avadacatavra
Copy link
Contributor Author

@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 jdm left a comment

Choose a reason for hiding this comment

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

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))
Copy link
Member

Choose a reason for hiding this comment

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

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)
Copy link
Member

Choose a reason for hiding this comment

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

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

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 21, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Nov 21, 2017
@jdm
Copy link
Member

jdm commented Nov 21, 2017

@bors-servo: try

@bors-servo
Copy link
Contributor

⌛ Trying commit 0269db1 with merge 553e4ea...

bors-servo pushed 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

💔 Test failed - mac-rel-wpt3

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Nov 21, 2017
@avadacatavra
Copy link
Contributor Author

@bors-servo retry

bors-servo pushed 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

⌛ Trying commit 0269db1 with merge 167c884...

@bors-servo
Copy link
Contributor

💔 Test failed - mac-rel-wpt3

@jdm jdm added S-needs-tests New tests have been requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 27, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 28, 2017
@avadacatavra avadacatavra force-pushed the domrefcellpanic branch 3 times, most recently from 7eafa4f to 62caa26 Compare November 28, 2017 17:44
@avadacatavra avadacatavra removed the S-needs-tests New tests have been requested by a reviewer. label Nov 28, 2017
@avadacatavra avadacatavra force-pushed the domrefcellpanic branch 3 times, most recently from d10cd00 to a6ecc75 Compare November 29, 2017 16:37
Copy link
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

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

Looks good!

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

Choose a reason for hiding this comment

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

This style block can be removed now.

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

Choose a reason for hiding this comment

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

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()
Copy link
Member

Choose a reason for hiding this comment

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

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() {
Copy link
Member

Choose a reason for hiding this comment

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

Let's use if let

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

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

Choose a reason for hiding this comment

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

if let

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 29, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels 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
@jdm
Copy link
Member

jdm commented Dec 1, 2017

@bors-servo: r+

@bors-servo
Copy link
Contributor

📌 Commit 79d896d has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Dec 1, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 79d896d with merge 712d75a...

bors-servo pushed 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

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: jdm
Pushing 712d75a to master...

@bors-servo bors-servo merged commit 79d896d into servo:master Dec 1, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Dec 1, 2017
jdm pushed 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DomRefCell<T> already borrowed: BorrowMutError
5 participants