Move the "updatedPreference" event listener registration
This patch fixes a situation that'll probably never happen, but nonetheless seems like something that we should address. Currently the "updatedPreference" listener isn't registered *until after* the preferences have been read and initialized, which leaves a very short window of time where a preference change could theoretically be skipped.
This commit is contained in:
parent
db9115625b
commit
9e352a8bad
@ -67,16 +67,13 @@ class BasePreferences {
|
|||||||
typeof prefVal === typeof val ? prefVal : val;
|
typeof prefVal === typeof val ? prefVal : val;
|
||||||
}
|
}
|
||||||
AppOptions.setAll(options, /* init = */ true);
|
AppOptions.setAll(options, /* init = */ true);
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|
||||||
window.addEventListener("updatedPreference", evt => {
|
|
||||||
this.#updatePref(evt.detail);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
|
window.addEventListener("updatedPreference", evt => {
|
||||||
|
this.#updatePref(evt.detail);
|
||||||
|
});
|
||||||
this.eventBus = null;
|
this.eventBus = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,10 +98,11 @@ class BasePreferences {
|
|||||||
throw new Error("Not implemented: _readFromStorage");
|
throw new Error("Not implemented: _readFromStorage");
|
||||||
}
|
}
|
||||||
|
|
||||||
#updatePref({ name, value }) {
|
async #updatePref({ name, value }) {
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||||
throw new Error("Not implemented: #updatePref");
|
throw new Error("Not implemented: #updatePref");
|
||||||
}
|
}
|
||||||
|
await this.#initializedPromise;
|
||||||
|
|
||||||
if (name in this.#browserDefaults) {
|
if (name in this.#browserDefaults) {
|
||||||
if (typeof value !== typeof this.#browserDefaults[name]) {
|
if (typeof value !== typeof this.#browserDefaults[name]) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user