Merge pull request #12773 from Snuffleupagus/move-sandboxBundleSrc
Pass in the "sandboxBundleSrc" option when calling `DefaultExternalServices.createScripting`
This commit is contained in:
commit
df53e7811c
@ -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(),
|
||||
|
@ -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;
|
||||
|
@ -366,7 +366,7 @@ class FirefoxExternalServices extends DefaultExternalServices {
|
||||
return new MozL10n(mozL10n);
|
||||
}
|
||||
|
||||
static createScripting() {
|
||||
static createScripting(options) {
|
||||
return FirefoxScripting;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user