Merge pull request #13364 from Snuffleupagus/sandbox-TESTING-define
Clean-up usage of the `TESTING`-define in `src/pdf.sandbox.js`
This commit is contained in:
commit
dda1a9a7b1
@ -21,9 +21,6 @@ const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION");
|
|||||||
/* eslint-disable-next-line no-unused-vars */
|
/* eslint-disable-next-line no-unused-vars */
|
||||||
const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD");
|
const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD");
|
||||||
|
|
||||||
const TESTING =
|
|
||||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || TESTING");
|
|
||||||
|
|
||||||
class SandboxSupport extends SandboxSupportBase {
|
class SandboxSupport extends SandboxSupportBase {
|
||||||
exportValueToSandbox(val) {
|
exportValueToSandbox(val) {
|
||||||
// The communication with the Quickjs sandbox is based on strings
|
// The communication with the Quickjs sandbox is based on strings
|
||||||
@ -58,16 +55,17 @@ class Sandbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create(data) {
|
create(data) {
|
||||||
if (TESTING) {
|
if (PDFJSDev.test("!PRODUCTION || TESTING")) {
|
||||||
this._module.ccall("nukeSandbox", null, []);
|
this._module.ccall("nukeSandbox", null, []);
|
||||||
}
|
}
|
||||||
const code = [PDFJSDev.eval("PDF_SCRIPTING_JS_SOURCE")];
|
const code = [PDFJSDev.eval("PDF_SCRIPTING_JS_SOURCE")];
|
||||||
if (!TESTING) {
|
|
||||||
code.push("delete dump;");
|
if (PDFJSDev.test("!PRODUCTION || TESTING")) {
|
||||||
} else {
|
|
||||||
code.push(
|
code.push(
|
||||||
`globalThis.sendResultForTesting = callExternalFunction.bind(null, "send");`
|
`globalThis.sendResultForTesting = callExternalFunction.bind(null, "send");`
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
code.push("delete dump;");
|
||||||
}
|
}
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
@ -124,7 +122,7 @@ class Sandbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
evalForTesting(code, key) {
|
evalForTesting(code, key) {
|
||||||
if (TESTING) {
|
if (PDFJSDev.test("!PRODUCTION || TESTING")) {
|
||||||
this._module.ccall(
|
this._module.ccall(
|
||||||
"evalInSandbox",
|
"evalInSandbox",
|
||||||
null,
|
null,
|
||||||
@ -138,6 +136,8 @@ class Sandbox {
|
|||||||
this._alertOnError,
|
this._alertOnError,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
throw new Error("Not implemented: evalForTesting");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user