diff --git a/gulpfile.js b/gulpfile.js index fe03105b6..ffc65f1f6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -535,7 +535,7 @@ gulp.task('default_preferences-pre', function() { ], { base: 'src/', }), gulp.src([ 'web/*.js', - '!web/{pdfjs,preferences,viewer}.js', + '!web/{app,pdfjs,preferences,viewer}.js', ], { base: '.', }), ]).pipe(transform('utf8', preprocess)) .pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + 'lib/')); diff --git a/web/app.js b/web/app.js index 65e31def5..da99a55f2 100644 --- a/web/app.js +++ b/web/app.js @@ -187,7 +187,9 @@ let PDFViewerApplication = { for (const name in prefs) { AppOptions.set(name, prefs[name]); } - } catch (reason) { } + } catch (reason) { + console.error(`_readPreferences: "${reason.message}".`); + } }, /** diff --git a/web/app_options.js b/web/app_options.js index ef5216ffe..ea9878314 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -222,7 +222,7 @@ const defaultOptions = { }, }; if (typeof PDFJSDev === 'undefined' || - PDFJSDev.test('!PRODUCTION || GENERIC')) { + PDFJSDev.test('!PRODUCTION || (GENERIC && !LIB)')) { defaultOptions.disablePreferences = { /** @type {boolean} */ value: false, @@ -262,9 +262,15 @@ class AppOptions { if ((kind & defaultOption.kind) === 0) { continue; } - if ((kind & OptionKind.PREFERENCE) !== 0) { - options[name] = defaultOption.value; - continue; + if (kind === OptionKind.PREFERENCE) { + const value = defaultOption.value, valueType = typeof value; + + if (valueType === 'boolean' || valueType === 'string' || + (valueType === 'number' && Number.isInteger(value))) { + options[name] = value; + continue; + } + throw new Error(`Invalid type for preference: ${name}`); } } const userOption = userOptions[name]; diff --git a/web/preferences.js b/web/preferences.js index d2fd8bd2b..ba3b1b53e 100644 --- a/web/preferences.js +++ b/web/preferences.js @@ -35,8 +35,6 @@ function getDefaultPreferences() { } }).then(function({ AppOptions, OptionKind, }) { return AppOptions.getAll(OptionKind.PREFERENCE); - }, function(reason) { - console.error(reason); }); } }