From 6218b9a51255dd2960f579db32cd29ea3b687e35 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 7 Dec 2020 18:23:34 +0100 Subject: [PATCH] Re-factor/re-name the `scripting` getter, on the `externalServices`-implementations, to a `createScripting` method Given that the GENERIC default viewer supports opening more than one document, and that a unique scripting-instance is now used for each document, the changes made in this patch seem appropriate. --- web/app.js | 10 +++++----- web/chromecom.js | 2 +- web/firefoxcom.js | 2 +- web/genericcom.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/app.js b/web/app.js index 4b48e3a5b..e67d7bc07 100644 --- a/web/app.js +++ b/web/app.js @@ -168,6 +168,10 @@ class DefaultExternalServices { throw new Error("Not implemented: createL10n"); } + static createScripting() { + throw new Error("Not implemented: createScripting"); + } + static get supportsIntegratedFind() { return shadow(this, "supportsIntegratedFind", false); } @@ -186,10 +190,6 @@ class DefaultExternalServices { static get isInAutomation() { return shadow(this, "isInAutomation", false); } - - static get scripting() { - throw new Error("Not implemented: scripting"); - } } const PDFViewerApplication = { @@ -1456,7 +1456,7 @@ const PDFViewerApplication = { // or the document was closed while the data resolved. return; } - const { scripting } = this.externalServices; + const scripting = this.externalServices.createScripting(); // Store a reference to the current scripting-instance, to allow destruction // of the sandbox and removal of the event listeners at document closing. this._scriptingInstance = { scripting, events: new Map() }; diff --git a/web/chromecom.js b/web/chromecom.js index f3dec140b..6694755e7 100644 --- a/web/chromecom.js +++ b/web/chromecom.js @@ -430,7 +430,7 @@ class ChromeExternalServices extends DefaultExternalServices { return new GenericL10n(navigator.language); } - static get scripting() { + static createScripting() { return new GenericScripting(); } } diff --git a/web/firefoxcom.js b/web/firefoxcom.js index 26a347bed..3d764e87f 100644 --- a/web/firefoxcom.js +++ b/web/firefoxcom.js @@ -360,7 +360,7 @@ class FirefoxExternalServices extends DefaultExternalServices { return new MozL10n(mozL10n); } - static get scripting() { + static createScripting() { return FirefoxScripting; } diff --git a/web/genericcom.js b/web/genericcom.js index abca71efc..2bf923a7b 100644 --- a/web/genericcom.js +++ b/web/genericcom.js @@ -51,7 +51,7 @@ class GenericExternalServices extends DefaultExternalServices { return new GenericL10n(locale); } - static get scripting() { + static createScripting() { return new GenericScripting(); } }