Bug 1611133 - Fix print preview close handler. r=bgrins

For HTML documents the onclose event is not dispatched to the root <html>
element.

Differential Revision: https://phabricator.services.mozilla.com/D62605

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brendan Dahl 2020-02-12 18:48:46 +00:00
parent 556504ff93
commit 011b986e6d

View File

@ -638,15 +638,15 @@ var PrintUtils = {
}
// copy the window close handler
if (document.documentElement.hasAttribute("onclose")) {
this._closeHandlerPP = document.documentElement.getAttribute("onclose");
if (window.onclose) {
this._closeHandlerPP = window.onclose;
} else {
this._closeHandlerPP = null;
}
document.documentElement.setAttribute(
"onclose",
"PrintUtils.exitPrintPreview(); return false;"
);
window.onclose = function() {
PrintUtils.exitPrintPreview();
return false;
};
// disable chrome shortcuts...
window.addEventListener("keydown", this.onKeyDownPP, true);
@ -673,9 +673,9 @@ var PrintUtils = {
// restore the old close handler
if (this._closeHandlerPP) {
document.documentElement.setAttribute("onclose", this._closeHandlerPP);
window.onclose = this._closeHandlerPP;
} else {
document.documentElement.removeAttribute("onclose");
window.onclose = null;
}
this._closeHandlerPP = null;