diff --git a/web/app.js b/web/app.js index 0023eb528fa80d..250afd7696eb57 100644 --- a/web/app.js +++ b/web/app.js @@ -943,6 +943,8 @@ const PDFViewerApplication = { this.load(pdfDocument); }, exception => { + this._unblockDocumentLoadEvent(); + if (loadingTask !== this.pdfLoadingTask) { return undefined; // Ignore errors for previously opened PDF files. } @@ -1420,6 +1422,8 @@ const PDFViewerApplication = { }); pagesPromise.then(() => { + this._unblockDocumentLoadEvent(); + this._initializeAutoPrint(pdfDocument, openActionPromise); }); @@ -2335,6 +2339,19 @@ const PDFViewerApplication = { return wholeTicks; }, + /** + * Should be called *after* all pages have loaded, or if an error occurred, + * to unblock the "load" event; see https://bugzilla.mozilla.org/show_bug.cgi?id=1618553 + * @private + */ + _unblockDocumentLoadEvent() { + if (document.blockUnblockOnload) { + document.blockUnblockOnload(false); + } + // Ensure that this method is only ever run once. + this._unblockDocumentLoadEvent = () => {}; + }, + /** * Used together with the integration-tests, to enable awaiting full * initialization of the scripting/sandbox. diff --git a/web/viewer.js b/web/viewer.js index e4165fcdd07f72..1f3a8b9b51052a 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -236,6 +236,12 @@ function webViewerLoad() { } } +// Block the "load" event until all pages are loaded, to ensure that printing +// works in Firefox; see https://bugzilla.mozilla.org/show_bug.cgi?id=1618553 +if (document.blockUnblockOnload) { + document.blockUnblockOnload(true); +} + if ( document.readyState === "interactive" || document.readyState === "complete"