Merge pull request #16583 from Snuffleupagus/Firefox-disable-pref-changes

[Firefox] Disable the ability to change preferences directly from the viewer
This commit is contained in:
Jonas Jenwald 2023-06-21 21:07:28 +02:00 committed by GitHub
commit 24b2c3a5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -174,13 +174,9 @@ class DownloadManager {
}
class FirefoxPreferences extends BasePreferences {
async _writeToStorage(prefObj) {
return FirefoxCom.requestAsync("setPreferences", prefObj);
}
async _readFromStorage(prefObj) {
const prefStr = await FirefoxCom.requestAsync("getPreferences", prefObj);
return JSON.parse(prefStr);
const prefs = await FirefoxCom.requestAsync("getPreferences", prefObj);
return typeof prefs === "string" ? JSON.parse(prefs) : prefs;
}
}

View File

@ -83,6 +83,9 @@ class BasePreferences {
* have been reset.
*/
async reset() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error("Please use `about:config` to change preferences.");
}
await this.#initializedPromise;
const prefs = this.#prefs;
@ -102,6 +105,9 @@ 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;
const defaultValue = this.#defaults[name],
prefs = this.#prefs;