Bug 1689462 - don't check for beforeunload on hung content processes, r=florian

Differential Revision: https://phabricator.services.mozilla.com/D104043
This commit is contained in:
Gijs Kruitbosch
2021-02-08 23:50:20 +00:00
parent 902343c13e
commit aeacc9134a
2 changed files with 80 additions and 0 deletions

View File

@@ -49,6 +49,25 @@
"dom.beforeunload_timeout_ms"
);
Object.defineProperty(LazyModules, "ProcessHangMonitor", {
configurable: true,
get() {
// Import if we can - this is a browser/ module so it may not be
// available, in which case we return null. We replace this getter
// when the module becomes available (should be on delayed startup
// when the first browser window loads, via BrowserGlue.jsm ).
const kURL = "resource:///modules/ProcessHangMonitor.jsm";
if (Cu.isModuleLoaded(kURL)) {
let { ProcessHangMonitor } = ChromeUtils.import(kURL);
Object.defineProperty(LazyModules, "ProcessHangMonitor", {
value: ProcessHangMonitor,
});
return ProcessHangMonitor;
}
return null;
},
});
const elementsToDestroyOnUnload = new Set();
window.addEventListener(
@@ -1661,6 +1680,15 @@
return { permitUnload: true };
}
// Don't bother asking if this browser is hung:
let { ProcessHangMonitor } = LazyModules;
if (
ProcessHangMonitor?.findActiveReport(this) ||
ProcessHangMonitor?.findPausedReport(this)
) {
return { permitUnload: true };
}
let result;
let success;