Remove the ENABLE_SCRIPTING build-target, since it's not necessary

There's no really compelling reason, as far as I can tell, to introduce the `ENABLE_SCRIPTING` build-target, instead of simply re-using the existing `TESTING` build-target for the new `gulp integrationtest` task.

In general there should be no problem with just always enable scripting in TESTING-builds, and if I were to *guess* the reason that this didn't seem to work was most likely because the Preferences ended up over-writing the `AppOptions`.
As it turns out the GENERIC-viewer has already has built-in support for disabling of Preferences, via the `AppOptions`, and this can be utilized in TESTING-builds as well to ensure that whatever `AppOptions` are set they're always respected.
This commit is contained in:
Jonas Jenwald 2020-12-17 14:32:05 +01:00
parent eff4d8182d
commit c78f153bda
3 changed files with 21 additions and 43 deletions

View File

@ -97,7 +97,6 @@ const DEFINES = Object.freeze({
PRODUCTION: true, PRODUCTION: true,
SKIP_BABEL: true, SKIP_BABEL: true,
TESTING: false, TESTING: false,
ENABLE_SCRIPTING: false,
// The main build targets: // The main build targets:
GENERIC: false, GENERIC: false,
MOZCENTRAL: false, MOZCENTRAL: false,
@ -682,7 +681,6 @@ gulp.task("default_preferences-pre", function () {
LIB: true, LIB: true,
BUNDLE_VERSION: 0, // Dummy version BUNDLE_VERSION: 0, // Dummy version
BUNDLE_BUILD: 0, // Dummy build BUNDLE_BUILD: 0, // Dummy build
ENABLE_SCRIPTING: process.env.ENABLE_SCRIPTING === "true",
}), }),
map: { map: {
"pdfjs-lib": "../pdf", "pdfjs-lib": "../pdf",
@ -1551,46 +1549,29 @@ gulp.task("testing-pre", function (done) {
done(); done();
}); });
gulp.task("enable-scripting", function (done) {
process.env.ENABLE_SCRIPTING = "true";
done();
});
gulp.task( gulp.task(
"test", "test",
gulp.series( gulp.series("testing-pre", "generic", "components", function () {
"enable-scripting", return streamqueue(
"testing-pre", { objectMode: true },
"generic", createTestSource("unit"),
"components", createTestSource("browser"),
function () { createTestSource("integration")
return streamqueue( );
{ objectMode: true }, })
createTestSource("unit"),
createTestSource("browser"),
createTestSource("integration")
);
}
)
); );
gulp.task( gulp.task(
"bottest", "bottest",
gulp.series( gulp.series("testing-pre", "generic", "components", function () {
"enable-scripting", return streamqueue(
"testing-pre", { objectMode: true },
"generic", createTestSource("unit", true),
"components", createTestSource("font", true),
function () { createTestSource("browser (no reftest)", true),
return streamqueue( createTestSource("integration")
{ objectMode: true }, );
createTestSource("unit", true), })
createTestSource("font", true),
createTestSource("browser (no reftest)", true),
createTestSource("integration")
);
}
)
); );
gulp.task( gulp.task(
@ -1609,7 +1590,7 @@ gulp.task(
gulp.task( gulp.task(
"integrationtest", "integrationtest",
gulp.series("enable-scripting", "testing-pre", "generic", function () { gulp.series("testing-pre", "generic", function () {
return createTestSource("integration"); return createTestSource("integration");
}) })
); );

View File

@ -63,8 +63,6 @@ class Sandbox {
} }
const sandboxData = JSON.stringify(data); const sandboxData = JSON.stringify(data);
const code = [ const code = [
// Next line is replaced by code from initialization.js
// when we create the bundle for the sandbox.
PDFJSDev.eval("PDF_SCRIPTING_JS_SOURCE"), PDFJSDev.eval("PDF_SCRIPTING_JS_SOURCE"),
`pdfjsScripting.initSandbox({ data: ${sandboxData} })`, `pdfjsScripting.initSandbox({ data: ${sandboxData} })`,
]; ];

View File

@ -67,7 +67,7 @@ const defaultOptions = {
}, },
enableScripting: { enableScripting: {
/** @type {boolean} */ /** @type {boolean} */
value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("ENABLE_SCRIPTING"), value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"),
kind: OptionKind.VIEWER + OptionKind.PREFERENCE, kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
}, },
enableWebGL: { enableWebGL: {
@ -249,7 +249,7 @@ if (
) { ) {
defaultOptions.disablePreferences = { defaultOptions.disablePreferences = {
/** @type {boolean} */ /** @type {boolean} */
value: false, value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"),
kind: OptionKind.VIEWER, kind: OptionKind.VIEWER,
}; };
defaultOptions.locale = { defaultOptions.locale = {
@ -260,8 +260,7 @@ if (
defaultOptions.sandboxBundleSrc = { defaultOptions.sandboxBundleSrc = {
/** @type {string} */ /** @type {string} */
value: value:
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
PDFJSDev.test("!PRODUCTION && !ENABLE_SCRIPTING")
? "../build/dev-sandbox/pdf.sandbox.js" ? "../build/dev-sandbox/pdf.sandbox.js"
: "../build/pdf.sandbox.js", : "../build/pdf.sandbox.js",
kind: OptionKind.VIEWER, kind: OptionKind.VIEWER,