Compare commits

..

No commits in common. "c1a398d9327f53bdd8ce388f4826162a0554d2a8" and "2e10ff6dd4a875b63743b4a764e7375f1bb94e1d" have entirely different histories.

3 changed files with 27 additions and 23 deletions

View File

@ -67,13 +67,6 @@ if (isNodeJS) {
warn("Cannot polyfill `Path2D`, rendering may be broken."); warn("Cannot polyfill `Path2D`, rendering may be broken.");
} }
} }
if (!globalThis.navigator?.language) {
globalThis.navigator = {
language: "en-US",
platform: "",
userAgent: "",
};
}
} }
} }

View File

@ -643,6 +643,12 @@ class FeatureTest {
} }
static get platform() { static get platform() {
if (
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
(typeof navigator !== "undefined" &&
typeof navigator?.platform === "string" &&
typeof navigator?.userAgent === "string")
) {
const { platform, userAgent } = navigator; const { platform, userAgent } = navigator;
return shadow(this, "platform", { return shadow(this, "platform", {
@ -655,6 +661,14 @@ class FeatureTest {
userAgent.includes("Firefox"), userAgent.includes("Firefox"),
}); });
} }
return shadow(this, "platform", {
isAndroid: false,
isLinux: false,
isMac: false,
isWindows: false,
isFirefox: false,
});
}
static get isCSSRoundSupported() { static get isCSSRoundSupported() {
return shadow( return shadow(

View File

@ -19,16 +19,13 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if ( if (
typeof PDFJSDev !== "undefined" && typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("LIB") && PDFJSDev.test("LIB") &&
!globalThis.navigator?.language typeof navigator === "undefined"
) { ) {
globalThis.navigator = { globalThis.navigator = Object.create(null);
language: "en-US",
maxTouchPoints: 1,
platform: "",
userAgent: "",
};
} }
const { maxTouchPoints, platform, userAgent } = navigator; 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 =