aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-05-28 15:52:31 -0400
committerGitHub <noreply@github.com>2018-05-28 15:52:31 -0400
commit2439ab02b8e021836ff620ef473e556adaa66d58 (patch)
tree54ad73a97d0b26029602a7327fa752b08dca34aa /components
parent77850c2c05d9dbfe226e97dd62d82fa8c6d402b3 (diff)
parent57c0d82944969f7ee645c9208f41fb24e8561d43 (diff)
downloadservo-2439ab02b8e021836ff620ef473e556adaa66d58.tar.gz
servo-2439ab02b8e021836ff620ef473e556adaa66d58.zip
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 -->
Diffstat (limited to 'components')
-rw-r--r--components/script/dom/document.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index dc9eae886bb..9e048161633 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -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.