From 620f1ef1a97bbb8c7301eafc38d9cd1b8b401940 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Mon, 19 Sep 2022 14:22:32 +0200 Subject: [PATCH] Don't use window.print in the Firefox builtin viewer (bug 1774427) Currently, it's impossible to print a pdf in a sandboxed iframe in using window.print. --- web/app.js | 6 +++++- web/firefoxcom.js | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web/app.js b/web/app.js index 87d4b81e4..b2184e06e 100644 --- a/web/app.js +++ b/web/app.js @@ -152,6 +152,10 @@ class DefaultExternalServices { static reportTelemetry(data) {} + static print() { + window.print(); + } + static createDownloadManager(options) { throw new Error("Not implemented: createDownloadManager"); } @@ -1897,7 +1901,7 @@ const PDFViewerApplication = { if (!this.supportsPrinting) { return; } - window.print(); + this.externalServices.print(); }, bindEvents() { diff --git a/web/firefoxcom.js b/web/firefoxcom.js index 0e5172b53..c2e7860fd 100644 --- a/web/firefoxcom.js +++ b/web/firefoxcom.js @@ -402,6 +402,10 @@ class FirefoxExternalServices extends DefaultExternalServices { FirefoxCom.request("updateEditorStates", data); } + static print() { + FirefoxCom.request("print", null); + } + static createL10n(options) { const mozL10n = document.mozL10n; // TODO refactor mozL10n.setExternalLocalizerServices