Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GENERIC viewer] Warn about AppOptions being overridden by Preferences during loading #14063

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,20 @@ const PDFViewerApplication = {
*/
async _readPreferences() {
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
AppOptions.get("disablePreferences")
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
// Give custom implementations of the default viewer a simpler way to
// opt-out of having the `Preferences` override existing `AppOptions`.
return;
if (AppOptions.get("disablePreferences")) {
// Give custom implementations of the default viewer a simpler way to
// opt-out of having the `Preferences` override existing `AppOptions`.
return;
}
if (AppOptions._hasUserOptions()) {
console.warn(
"_readPreferences: The Preferences may override manually set AppOptions; " +
'please use the "disablePreferences"-option in order to prevent that.'
);
}
}
try {
AppOptions.setAll(await this.preferences.getAll());
Expand Down
7 changes: 7 additions & 0 deletions web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,13 @@ class AppOptions {
static remove(name) {
delete userOptions[name];
}

/**
* @ignore
*/
static _hasUserOptions() {
return Object.keys(userOptions).length > 0;
}
}

export { AppOptions, compatibilityParams, OptionKind };