From a5ed7d2abcd5336908026db5c02cab52371e8d1f Mon Sep 17 00:00:00 2001 From: Matheus Longaray Date: Mon, 11 Jul 2016 08:48:00 +0200 Subject: [PATCH] Bug 1285544 - Make sure print jobs that go through simplification get the right document URL set. r=mconley. --- toolkit/components/printing/content/printUtils.js | 1 + toolkit/content/browser-content.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/toolkit/components/printing/content/printUtils.js b/toolkit/components/printing/content/printUtils.js index 4e4a3b28289d..d9635244ca9e 100644 --- a/toolkit/components/printing/content/printUtils.js +++ b/toolkit/components/printing/content/printUtils.js @@ -114,6 +114,7 @@ var PrintUtils = { let mm = aBrowser.messageManager; mm.sendAsyncMessage("Printing:Print", { windowID: aWindowID, + simplifiedMode: this._shouldSimplify, }); }, diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index d9f0f18959cd..ddc12a0bb5fa 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -466,7 +466,7 @@ var Printing = { } case "Printing:Print": { - this.print(Services.wm.getOuterWindowWithId(data.windowID)); + this.print(Services.wm.getOuterWindowWithId(data.windowID), data.simplifiedMode); break; } } @@ -631,9 +631,17 @@ var Printing = { docShell.printPreview.exitPrintPreview(); }, - print(contentWindow) { + print(contentWindow, simplifiedMode) { let printSettings = this.getPrintSettings(); let rv = Cr.NS_OK; + + // If we happen to be on simplified mode, we need to set docURL in order + // to generate header/footer content correctly, since simplified tab has + // "about:blank" as its URI. + if (printSettings && simplifiedMode) { + printSettings.docURL = contentWindow.document.baseURI; + } + try { let print = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebBrowserPrint);