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
Conversation
r? jdm |
@@ -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()); |
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.
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.
c6a1549
to
d8e0dba
Compare
@jdm not sure if i should queue the events if the parser is in use? |
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. |
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.
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.
components/script/dom/eventtarget.rs
Outdated
@@ -315,11 +315,35 @@ impl EventTarget { | |||
pub fn dispatch_event_with_target(&self, | |||
target: &EventTarget, | |||
event: &Event) -> EventStatus { | |||
event.dispatch(self, Some(target)) |
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.
Assert here, and let's match on target.global().downcast::<Window>()
instead of trying Element (keeping in mind that None is valid).
components/script/dom/eventtarget.rs
Outdated
} | ||
|
||
pub fn dispatch_event(&self, event: &Event) -> EventStatus { | ||
event.dispatch(self, None) |
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.
Assert here, and do the same as the previous comment but using self.
d8e0dba
to
0269db1
Compare
@bors-servo: try |
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 -->
💔 Test failed - mac-rel-wpt3 |
@bors-servo retry |
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 -->
💔 Test failed - mac-rel-wpt3 |
7eafa4f
to
62caa26
Compare
d10cd00
to
a6ecc75
Compare
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.
Looks good!
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style onload="document.blah = true"> | ||
</style> |
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 style block can be removed now.
@@ -0,0 +1,3 @@ | |||
;bug: https://github.com/servo/servo/issues/19392 |
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 (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() |
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.
Let's add || self.can_write()
, so that this is handled correctly when #19393 is fixed.
components/script/dom/eventtarget.rs
Outdated
@@ -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() { |
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.
Let's use if let
components/script/dom/eventtarget.rs
Outdated
event.dispatch(self, Some(target)) | ||
} | ||
|
||
pub fn dispatch_event(&self, event: &Event) -> EventStatus { | ||
match self.global().downcast::<Window>() { |
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.
if let
a6ecc75
to
a1abe94
Compare
created checks to see if parser is in use before event dispatch changed tests to expect crash and added async style test
a1abe94
to
79d896d
Compare
@bors-servo: r+ |
📌 Commit 79d896d has been approved by |
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 -->
☀️ 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 |
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]
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 errorsThis change is