Skip to content

Commit 8dc22f4

Browse files
Merge pull request #14063 from Snuffleupagus/disablePreferences-warning
[GENERIC viewer] Warn about AppOptions being overridden by Preferences during loading
2 parents 1bef4e5 + 96b38f6 commit 8dc22f4

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

web/app.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,20 @@ const PDFViewerApplication = {
301301
*/
302302
async _readPreferences() {
303303
if (
304-
(typeof PDFJSDev === "undefined" ||
305-
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
306-
AppOptions.get("disablePreferences")
304+
typeof PDFJSDev === "undefined" ||
305+
PDFJSDev.test("!PRODUCTION || GENERIC")
307306
) {
308-
// Give custom implementations of the default viewer a simpler way to
309-
// opt-out of having the `Preferences` override existing `AppOptions`.
310-
return;
307+
if (AppOptions.get("disablePreferences")) {
308+
// Give custom implementations of the default viewer a simpler way to
309+
// opt-out of having the `Preferences` override existing `AppOptions`.
310+
return;
311+
}
312+
if (AppOptions._hasUserOptions()) {
313+
console.warn(
314+
"_readPreferences: The Preferences may override manually set AppOptions; " +
315+
'please use the "disablePreferences"-option in order to prevent that.'
316+
);
317+
}
311318
}
312319
try {
313320
AppOptions.setAll(await this.preferences.getAll());

web/app_options.js

+7
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,13 @@ class AppOptions {
379379
static remove(name) {
380380
delete userOptions[name];
381381
}
382+
383+
/**
384+
* @ignore
385+
*/
386+
static _hasUserOptions() {
387+
return Object.keys(userOptions).length > 0;
388+
}
382389
}
383390

384391
export { AppOptions, compatibilityParams, OptionKind };

0 commit comments

Comments
 (0)