From 7427ce30be0cb8de548e894abb268b34768c480b Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 17 Dec 2020 14:32:05 +0100 Subject: [PATCH] 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. --- gulpfile.js | 55 +++++++++++++++------------------------------- src/pdf.sandbox.js | 2 -- web/app_options.js | 7 +++--- 3 files changed, 21 insertions(+), 43 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index e16a6b6f5bb762..b6735a95275257 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -97,7 +97,6 @@ const DEFINES = Object.freeze({ PRODUCTION: true, SKIP_BABEL: true, TESTING: false, - ENABLE_SCRIPTING: false, // The main build targets: GENERIC: false, MOZCENTRAL: false, @@ -661,7 +660,6 @@ gulp.task("default_preferences-pre", function () { LIB: true, BUNDLE_VERSION: 0, // Dummy version BUNDLE_BUILD: 0, // Dummy build - ENABLE_SCRIPTING: process.env.ENABLE_SCRIPTING === "true", }), map: { "pdfjs-lib": "../pdf", @@ -1527,46 +1525,29 @@ gulp.task("testing-pre", function (done) { done(); }); -gulp.task("enable-scripting", function (done) { - process.env.ENABLE_SCRIPTING = "true"; - done(); -}); - gulp.task( "test", - gulp.series( - "enable-scripting", - "testing-pre", - "generic", - "components", - function () { - return streamqueue( - { objectMode: true }, - createTestSource("unit"), - createTestSource("browser"), - createTestSource("integration") - ); - } - ) + gulp.series("testing-pre", "generic", "components", function () { + return streamqueue( + { objectMode: true }, + createTestSource("unit"), + createTestSource("browser"), + createTestSource("integration") + ); + }) ); gulp.task( "bottest", - gulp.series( - "enable-scripting", - "testing-pre", - "generic", - "components", - function () { - return streamqueue( - { objectMode: true }, - createTestSource("unit", true), - createTestSource("font", true), - createTestSource("browser (no reftest)", true), - createTestSource("integration") - ); - } - ) + gulp.series("testing-pre", "generic", "components", function () { + return streamqueue( + { objectMode: true }, + createTestSource("unit", true), + createTestSource("font", true), + createTestSource("browser (no reftest)", true), + createTestSource("integration") + ); + }) ); gulp.task( @@ -1585,7 +1566,7 @@ gulp.task( gulp.task( "integrationtest", - gulp.series("enable-scripting", "testing-pre", "generic", function () { + gulp.series("testing-pre", "generic", function () { return createTestSource("integration"); }) ); diff --git a/src/pdf.sandbox.js b/src/pdf.sandbox.js index 9dec2bc5f902f6..ca01d3e017d2db 100644 --- a/src/pdf.sandbox.js +++ b/src/pdf.sandbox.js @@ -48,8 +48,6 @@ class Sandbox { let code = [ "exports = Object.create(null);", "module = Object.create(null);", - // Next line is replaced by code from initialization.js - // when we create the bundle for the sandbox. PDFJSDev.eval("PDF_SCRIPTING_JS_SOURCE"), `data = ${sandboxData};`, `module.exports.initSandbox({ data, extra: {${extraStr}}, out: this});`, diff --git a/web/app_options.js b/web/app_options.js index 19c12344856e0a..2b67f4e0aa5029 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -67,7 +67,7 @@ const defaultOptions = { }, enableScripting: { /** @type {boolean} */ - value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("ENABLE_SCRIPTING"), + value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"), kind: OptionKind.VIEWER + OptionKind.PREFERENCE, }, enableWebGL: { @@ -249,7 +249,7 @@ if ( ) { defaultOptions.disablePreferences = { /** @type {boolean} */ - value: false, + value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"), kind: OptionKind.VIEWER, }; defaultOptions.locale = { @@ -260,8 +260,7 @@ if ( defaultOptions.sandboxBundleSrc = { /** @type {string} */ value: - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION && !ENABLE_SCRIPTING") + typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION") ? "../build/dev-sandbox/pdf.sandbox.js" : "../build/pdf.sandbox.js", kind: OptionKind.VIEWER,