Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass in the "sandboxBundleSrc" option when calling DefaultExternalServices.createScripting #12773

Merged
merged 1 commit into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class DefaultExternalServices {
throw new Error("Not implemented: createL10n");
}

static createScripting() {
static createScripting(options) {
throw new Error("Not implemented: createScripting");
}

Expand Down Expand Up @@ -1476,7 +1476,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(),
Expand Down
4 changes: 2 additions & 2 deletions web/chromecom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class FirefoxExternalServices extends DefaultExternalServices {
return new MozL10n(mozL10n);
}

static createScripting() {
static createScripting(options) {
return FirefoxScripting;
}

Expand Down
5 changes: 2 additions & 3 deletions web/generic_scripting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions web/genericcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down