Bug 1308621 - print preview shouldn't re-set the source browser, r?mconley draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 06 Oct 2016 12:58:37 +0100
changeset 422561 8f02529157a6f28a60dfb70187d1d04c4474e298
parent 422256 49fe455cac957808ed4a5d1685c3a1938dac1d31
child 533306 1509b49dccd8f313267391eacbcd458359ad8419
push id31741
push userbmo:gijskruitbosch+bugs@gmail.com
push dateFri, 07 Oct 2016 20:41:08 +0000
reviewersmconley
bugs1308621
milestone52.0a1
Bug 1308621 - print preview shouldn't re-set the source browser, r?mconley Right now the "already in print preview" case in printPreview() collapses the print preview browser - but also clobbers its _sourceBrowser property, which shouldn't point to the print preview browser but to the 'normal' browser whose print preview is in the print preview browser. This patch fixes the clobbering, and updates later code to not call getSourceBrowser() repeatedly, as doing so can in some race conditions end up print previewing the wrong page. MozReview-Commit-ID: FlMRrPEkAJQ
toolkit/components/printing/content/printUtils.js
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -200,18 +200,18 @@ var PrintUtils = {
       this._originalURL = this._sourceBrowser.currentURI.spec;
 
       // Here we log telemetry data for when the user enters print preview.
       this.logTelemetry("PRINT_PREVIEW_OPENED_COUNT");
     } else {
       // collapse the browser here -- it will be shown in
       // enterPrintPreview; this forces a reflow which fixes display
       // issues in bug 267422.
-      this._sourceBrowser = this._listener.getPrintPreviewBrowser();
-      this._sourceBrowser.collapsed = true;
+      let ppBrowser = this._listener.getPrintPreviewBrowser();
+      ppBrowser.collapsed = true;
     }
 
     this._webProgressPP = {};
     let ppParams        = {};
     let notifyOnOpen    = {};
     let printSettings   = this.getPrintSettings();
     // Here we get the PrintingPromptService so we can display the PP Progress from script
     // For the browser implemented via XUL with the PP toolbar we cannot let it be
@@ -526,25 +526,25 @@ var PrintUtils = {
           spMM.removeMessageListener("Printing:Preview:ReaderModeReady", onReaderReady);
           sendEnterPreviewMessage(simplifiedBrowser, true);
         });
 
         // Here, we send down a message to simplified browser in order to parse
         // the original page. After we have parsed it, content will tell parent
         // that the document is ready for print previewing.
         spMM.sendAsyncMessage("Printing:Preview:ParseDocument", {
-          URL: this._listener.getSourceBrowser().currentURI.spec,
-          windowID: this._listener.getSourceBrowser().outerWindowID,
+          URL: this._sourceBrowser.currentURI.spec,
+          windowID: this._sourceBrowser.outerWindowID,
         });
 
         // Here we log telemetry data for when the user enters simplify mode.
         this.logTelemetry("PRINT_PREVIEW_SIMPLIFY_PAGE_OPENED_COUNT");
       }
     } else {
-      sendEnterPreviewMessage(this._listener.getSourceBrowser(), false);
+      sendEnterPreviewMessage(this._sourceBrowser, false);
     }
 
     if (this._webProgressPP.value) {
       mm.addMessageListener("Printing:Preview:StateChange", this);
       mm.addMessageListener("Printing:Preview:ProgressChange", this);
     }
 
     let onEntered = (message) => {