From 6cc32b699f79a35505659351fb04a5c8e7bac3fa Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 17 Jul 2024 19:51:53 +0200 Subject: [PATCH] Add the possibility to change some pdfjs preferences from the viewer (bug 1908483) --- web/firefoxcom.js | 4 ++++ web/preferences.js | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web/firefoxcom.js b/web/firefoxcom.js index a7cd0068b..3add42240 100644 --- a/web/firefoxcom.js +++ b/web/firefoxcom.js @@ -150,6 +150,10 @@ class Preferences extends BasePreferences { async _readFromStorage(prefObj) { return FirefoxCom.requestAsync("getPreferences", prefObj); } + + async _writeToStorage(prefObj) { + return FirefoxCom.requestAsync("setPreferences", prefObj); + } } (function listenFindEvents() { diff --git a/web/preferences.js b/web/preferences.js index 61a01ea88..d44e4a39a 100644 --- a/web/preferences.js +++ b/web/preferences.js @@ -108,14 +108,14 @@ class BasePreferences { * provided that the preference exists and the types match. */ async set(name, value) { - if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { - throw new Error("Please use `about:config` to change preferences."); - } await this.#initializedPromise; AppOptions.setAll({ [name]: value }, /* prefs = */ true); - const prefs = AppOptions.getAll(OptionKind.PREFERENCE); - await this._writeToStorage(prefs); + await this._writeToStorage( + typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL") + ? { [name]: AppOptions.get(name) } + : AppOptions.getAll(OptionKind.PREFERENCE) + ); } /**