Merge pull request #11647 from Snuffleupagus/notifyPagesLoaded

[Firefox] Block the "load" event until all pages are loaded, to ensure that printing works (bug 1618553)
This commit is contained in:
Brendan Dahl 2021-02-05 14:04:27 -08:00 committed by GitHub
commit a447d05292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -943,6 +943,8 @@ const PDFViewerApplication = {
this.load(pdfDocument); this.load(pdfDocument);
}, },
exception => { exception => {
this._unblockDocumentLoadEvent();
if (loadingTask !== this.pdfLoadingTask) { if (loadingTask !== this.pdfLoadingTask) {
return undefined; // Ignore errors for previously opened PDF files. return undefined; // Ignore errors for previously opened PDF files.
} }
@ -1420,6 +1422,8 @@ const PDFViewerApplication = {
}); });
pagesPromise.then(() => { pagesPromise.then(() => {
this._unblockDocumentLoadEvent();
this._initializeAutoPrint(pdfDocument, openActionPromise); this._initializeAutoPrint(pdfDocument, openActionPromise);
}); });
@ -2335,6 +2339,19 @@ const PDFViewerApplication = {
return wholeTicks; 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 * Used together with the integration-tests, to enable awaiting full
* initialization of the scripting/sandbox. * initialization of the scripting/sandbox.

View File

@ -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 ( if (
document.readyState === "interactive" || document.readyState === "interactive" ||
document.readyState === "complete" document.readyState === "complete"