prevent overwriting of salvageable state in later prompt/unload steps

This commit is contained in:
Gregory Terzian 2018-05-20 23:49:15 +08:00
parent a297e8f288
commit 57c0d82944
5 changed files with 101 additions and 5 deletions

View file

@ -1654,7 +1654,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 send a message to embedder to prompt user.
// Step 9
@ -1662,9 +1664,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;
}
}
@ -1715,7 +1719,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.