Merge pull request #17153 from Snuffleupagus/src-navigator-checks

Guard `navigator`-object accesses in `src/`-files (issue 15728)
This commit is contained in:
Tim van der Meij 2023-10-29 11:59:32 +01:00 committed by GitHub
commit 0329b5e130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -184,6 +184,7 @@ class FontLoader {
supported = true;
} else if (
typeof navigator !== "undefined" &&
typeof navigator?.userAgent === "string" &&
// User agent string sniffing is bad, but there is no reliable way to
// tell if the font is fully loaded and ready to be used with canvas.
/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)

View File

@ -616,14 +616,15 @@ class FeatureTest {
static get platform() {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
typeof navigator === "undefined"
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
(typeof navigator !== "undefined" &&
typeof navigator?.platform === "string")
) {
return shadow(this, "platform", { isMac: false });
return shadow(this, "platform", {
isMac: navigator.platform.includes("Mac"),
});
}
return shadow(this, "platform", {
isMac: navigator.platform.includes("Mac"),
});
return shadow(this, "platform", { isMac: false });
}
static get isCSSRoundSupported() {