Bug 1265174 - do not restore "onclose" attribute to null value in print preview window, when there was none at the start. r=smaug
authorarai <arai.unmht@gmail.com>
Sat, 13 Jan 2018 10:16:00 +0200
changeset 399297 78776e9bdba1f3427823d364f49adf4065ea7b79
parent 399296 b67c5b1e033bdea10e4cc242099ffb986fd09357
child 399298 d350d4735de6bdc5184abfdb3fe9a7f3108c349e
push id33257
push userncsoregi@mozilla.com
push dateMon, 15 Jan 2018 17:27:13 +0000
treeherdermozilla-central@d1b820065830 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1265174
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1265174 - do not restore "onclose" attribute to null value in print preview window, when there was none at the start. r=smaug
toolkit/components/printing/content/printUtils.js
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -664,20 +664,21 @@ var PrintUtils = {
       if (this._sourceBrowser.isArticle) {
         printPreviewTB.enableSimplifyPage();
       } else {
         this.logTelemetry("PRINT_PREVIEW_SIMPLIFY_PAGE_UNAVAILABLE_COUNT");
         printPreviewTB.disableSimplifyPage();
       }
 
       // copy the window close handler
-      if (document.documentElement.hasAttribute("onclose"))
+      if (document.documentElement.hasAttribute("onclose")) {
         this._closeHandlerPP = document.documentElement.getAttribute("onclose");
-      else
+      } else {
         this._closeHandlerPP = null;
+      }
       document.documentElement.setAttribute("onclose", "PrintUtils.exitPrintPreview(); return false;");
 
       // disable chrome shortcuts...
       window.addEventListener("keydown", this.onKeyDownPP, true);
       window.addEventListener("keypress", this.onKeyPressPP, true);
 
       ppBrowser.collapsed = false;
       ppBrowser.focus();
@@ -694,17 +695,21 @@ var PrintUtils = {
       browserMM.sendAsyncMessage("Printing:Preview:Exit");
     }
     this._ppBrowsers.clear();
     this._currentPPBrowser = null;
     window.removeEventListener("keydown", this.onKeyDownPP, true);
     window.removeEventListener("keypress", this.onKeyPressPP, true);
 
     // restore the old close handler
-    document.documentElement.setAttribute("onclose", this._closeHandlerPP);
+    if (this._closeHandlerPP) {
+      document.documentElement.setAttribute("onclose", this._closeHandlerPP);
+    } else {
+      document.documentElement.removeAttribute("onclose");
+    }
     this._closeHandlerPP = null;
 
     // remove the print preview toolbar
     let printPreviewTB = document.getElementById("print-preview-toolbar");
     printPreviewTB.destroy();
     printPreviewTB.remove();
 
     if (gFocusedElement)