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
--- 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) => {