Merge pull request #12765 from Snuffleupagus/_initializeAutoPrint-scripting-tweaks

Avoid the `getJavaScript` API-call in `PDFViewerApplication._initializeAutoPrint` when "enableScripting" is set
This commit is contained in:
Brendan Dahl 2020-12-21 13:56:56 -08:00 committed by GitHub
commit 9c99df7cac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1652,7 +1652,7 @@ const PDFViewerApplication = {
async _initializeAutoPrint(pdfDocument, openActionPromise) { async _initializeAutoPrint(pdfDocument, openActionPromise) {
const [openAction, javaScript] = await Promise.all([ const [openAction, javaScript] = await Promise.all([
openActionPromise, openActionPromise,
pdfDocument.getJavaScript(), !AppOptions.get("enableScripting") ? pdfDocument.getJavaScript() : null,
]); ]);
if (pdfDocument !== this.pdfDocument) { if (pdfDocument !== this.pdfDocument) {
@ -1660,10 +1660,10 @@ const PDFViewerApplication = {
} }
let triggerAutoPrint = false; let triggerAutoPrint = false;
if (openAction && openAction.action === "Print") { if (openAction?.action === "Print") {
triggerAutoPrint = true; triggerAutoPrint = true;
} }
if (javaScript && !AppOptions.get("enableScripting")) { if (javaScript) {
javaScript.some(js => { javaScript.some(js => {
if (!js) { if (!js) {
// Don't warn/fallback for empty JavaScript actions. // Don't warn/fallback for empty JavaScript actions.
@ -1686,9 +1686,7 @@ const PDFViewerApplication = {
} }
if (triggerAutoPrint) { if (triggerAutoPrint) {
setTimeout(() => {
this.triggerPrinting(); this.triggerPrinting();
});
} }
}, },