mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #20837 - gterzian:tests_for_has_event_listener, r=cbrewster
Fix for document salvageable state I noticed a bug where if the document was un-salavageable due to the presence of `beforeunload` listeners, this could be overwritten if there were no listeners for `unload`. This could also have happened if an iframe of the document had no listeners while the parent did. <!-- Please describe your changes on the following line: --> --- <!-- 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 #__ (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/20837) <!-- Reviewable:end -->
This commit is contained in:
commit
2439ab02b8
5 changed files with 101 additions and 5 deletions
|
@ -1665,7 +1665,9 @@ impl Document {
|
|||
);
|
||||
// TODO: Step 6, decrease the event loop's termination nesting level by 1.
|
||||
// Step 7
|
||||
self.salvageable.set(!has_listeners);
|
||||
if has_listeners {
|
||||
self.salvageable.set(false);
|
||||
}
|
||||
let mut can_unload = true;
|
||||
// TODO: Step 8, also check sandboxing modals flag.
|
||||
let default_prevented = event.DefaultPrevented();
|
||||
|
@ -1681,9 +1683,11 @@ impl Document {
|
|||
for iframe in self.iter_iframes() {
|
||||
// TODO: handle the case of cross origin iframes.
|
||||
let document = document_from_node(&*iframe);
|
||||
if !document.prompt_to_unload(true) {
|
||||
self.salvageable.set(document.salvageable());
|
||||
can_unload = false;
|
||||
can_unload = document.prompt_to_unload(true);
|
||||
if !document.salvageable() {
|
||||
self.salvageable.set(false);
|
||||
}
|
||||
if !can_unload {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1734,7 +1738,9 @@ impl Document {
|
|||
);
|
||||
self.fired_unload.set(true);
|
||||
// Step 9
|
||||
self.salvageable.set(!has_listeners);
|
||||
if has_listeners {
|
||||
self.salvageable.set(false);
|
||||
}
|
||||
}
|
||||
// TODO: Step 8, decrease the event loop's termination nesting level by 1.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue