Remove the typeof navigator
-checks in the web/app_options.js
file
Given that the `Navigator` interface has been available since "forever", please see https://developer.mozilla.org/en-US/docs/Web/API/Navigator#browser_compatibility, it's somewhat difficult to see why these checks are actually necessary since the viewer is only intended for usage in browsers. Looking at the history of the code, this functionality was originally placed in the general `src/shared/compatibility.js` file which could thus run in e.g. worker-threads and Node.js environments (where the `Navigator` interface isn't available).
This commit is contained in:
parent
d5f048abe0
commit
2dececf445
@ -15,12 +15,16 @@
|
|||||||
|
|
||||||
const compatibilityParams = Object.create(null);
|
const compatibilityParams = Object.create(null);
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
const userAgent =
|
if (
|
||||||
(typeof navigator !== "undefined" && navigator.userAgent) || "";
|
typeof PDFJSDev !== "undefined" &&
|
||||||
const platform =
|
PDFJSDev.test("LIB") &&
|
||||||
(typeof navigator !== "undefined" && navigator.platform) || "";
|
typeof navigator === "undefined"
|
||||||
const maxTouchPoints =
|
) {
|
||||||
(typeof navigator !== "undefined" && navigator.maxTouchPoints) || 1;
|
globalThis.navigator = Object.create(null);
|
||||||
|
}
|
||||||
|
const userAgent = navigator.userAgent || "";
|
||||||
|
const platform = navigator.platform || "";
|
||||||
|
const maxTouchPoints = navigator.maxTouchPoints || 1;
|
||||||
|
|
||||||
const isAndroid = /Android/.test(userAgent);
|
const isAndroid = /Android/.test(userAgent);
|
||||||
const isIOS =
|
const isIOS =
|
||||||
@ -278,7 +282,7 @@ if (
|
|||||||
};
|
};
|
||||||
defaultOptions.locale = {
|
defaultOptions.locale = {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
value: typeof navigator !== "undefined" ? navigator.language : "en-US",
|
value: navigator.language || "en-US",
|
||||||
kind: OptionKind.VIEWER,
|
kind: OptionKind.VIEWER,
|
||||||
};
|
};
|
||||||
defaultOptions.sandboxBundleSrc = {
|
defaultOptions.sandboxBundleSrc = {
|
||||||
|
Loading…
Reference in New Issue
Block a user