Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upchange parse_own_css to queue event not fire synchronously #19307
Conversation
highfive
commented
Nov 21, 2017
highfive
commented
Nov 21, 2017
|
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()); | |||
This comment has been minimized.
This comment has been minimized.
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.
c6a1549
to
d8e0dba
|
@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. |
|
To make sure this works locally, please run |
| @@ -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.
This comment has been minimized.
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.
This comment has been minimized.
d8e0dba
to
0269db1
|
@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 -->
|
|
|
@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 -->
|
|
7eafa4f
to
62caa26
d10cd00
to
a6ecc75
|
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.
This comment has been minimized.
| @@ -0,0 +1,3 @@ | |||
| ;bug: https://github.com/servo/servo/issues/19392 | |||
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
| event.dispatch(self, Some(target)) | ||
| } | ||
|
|
||
| pub fn dispatch_event(&self, event: &Event) -> EventStatus { | ||
| match self.global().downcast::<Window>() { |
This comment has been minimized.
This comment has been minimized.
a6ecc75
to
a1abe94
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
|
@bors-servo: r+ |
|
|
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 -->
|
|
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]
avadacatavra commentedNov 21, 2017
•
edited by SimonSapin
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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is