diff --git a/web/app.js b/web/app.js index 21266514b..59743aa72 100644 --- a/web/app.js +++ b/web/app.js @@ -167,7 +167,7 @@ class DefaultExternalServices { throw new Error("Not implemented: createL10n"); } - static createScripting() { + static createScripting(options) { throw new Error("Not implemented: createScripting"); } @@ -1477,7 +1477,12 @@ const PDFViewerApplication = { if (pdfDocument !== this.pdfDocument) { return; // The document was closed while the data resolved. } - const scripting = this.externalServices.createScripting(); + const scripting = this.externalServices.createScripting( + typeof PDFJSDev === "undefined" || + PDFJSDev.test("!PRODUCTION || GENERIC || CHROME") + ? { sandboxBundleSrc: AppOptions.get("sandboxBundleSrc") } + : null + ); // Store a reference to the current scripting-instance, to allow destruction // of the sandbox and removal of the event listeners at document closing. const internalEvents = new Map(), diff --git a/web/chromecom.js b/web/chromecom.js index 6694755e7..e29688c13 100644 --- a/web/chromecom.js +++ b/web/chromecom.js @@ -430,8 +430,8 @@ class ChromeExternalServices extends DefaultExternalServices { return new GenericL10n(navigator.language); } - static createScripting() { - return new GenericScripting(); + static createScripting({ sandboxBundleSrc }) { + return new GenericScripting(sandboxBundleSrc); } } PDFViewerApplication.externalServices = ChromeExternalServices; diff --git a/web/firefoxcom.js b/web/firefoxcom.js index 9af65e863..30b9ed791 100644 --- a/web/firefoxcom.js +++ b/web/firefoxcom.js @@ -366,7 +366,7 @@ class FirefoxExternalServices extends DefaultExternalServices { return new MozL10n(mozL10n); } - static createScripting() { + static createScripting(options) { return FirefoxScripting; } diff --git a/web/generic_scripting.js b/web/generic_scripting.js index 4c2f9164c..aef7ba177 100644 --- a/web/generic_scripting.js +++ b/web/generic_scripting.js @@ -13,13 +13,12 @@ * limitations under the License. */ -import { AppOptions } from "./app_options.js"; import { loadScript } from "pdfjs-lib"; class GenericScripting { - constructor() { + constructor(sandboxBundleSrc) { this._ready = loadScript( - AppOptions.get("sandboxBundleSrc"), + sandboxBundleSrc, /* removeScriptElement = */ true ).then(() => { return window.pdfjsSandbox.QuickJSSandbox(); diff --git a/web/genericcom.js b/web/genericcom.js index 2bf923a7b..df616133a 100644 --- a/web/genericcom.js +++ b/web/genericcom.js @@ -51,8 +51,8 @@ class GenericExternalServices extends DefaultExternalServices { return new GenericL10n(locale); } - static createScripting() { - return new GenericScripting(); + static createScripting({ sandboxBundleSrc }) { + return new GenericScripting(sandboxBundleSrc); } } PDFViewerApplication.externalServices = GenericExternalServices;