mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Bug 1359053 - Reject interaction.flushEventLoop if window is discarded; r=maja_zf
The window reference may have been discarded as a result of interaction. For example, this may happen when clicking a button that deletes the host <iframe> element containing the child window. In this case, the WindowProxy will set its closed property to true, to indicate that the browsing context has been discarded. We only want to flush the event loop of windows that exist, and so we return early from interaction.flushEventLoop if the window has been closed. MozReview-Commit-ID: LtTHQRudKvk --HG-- extra : rebase_source : e4133ddeed9e89e38fba6e9b8f17544a3546f7eb
This commit is contained in:
parent
e14f20eea7
commit
754d617ec8
@ -291,13 +291,20 @@ interaction.selectOption = function (el) {
|
||||
*
|
||||
* @return {Promise}
|
||||
* Promise is accepted once event queue is flushed, or rejected if
|
||||
* |win| is unloaded before the queue can be flushed.
|
||||
* |win| has closed or been unloaded before the queue can be flushed.
|
||||
*/
|
||||
interaction.flushEventLoop = function* (win) {
|
||||
let unloadEv;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (win.closed) {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
unloadEv = reject;
|
||||
win.addEventListener("unload", unloadEv, {once: true});
|
||||
|
||||
win.requestAnimationFrame(resolve);
|
||||
}).then(() => {
|
||||
win.removeEventListener("unload", unloadEv);
|
||||
|
Loading…
Reference in New Issue
Block a user