1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

[GENERIC viewer] Add Fluent PLATFORM function (PR 19414 follow-up)

This patch extends the `FeatureTest.platform` getter to provide the necessary information, and uses that one to implement a Fluent `PLATFORM` function based on: https://searchfox.org/mozilla-central/rev/d1fbe983fb7720f0a4aca0e748817af11c1a374e/intl/l10n/rust/fluent-ffi/src/bundle.rs#81-98
This commit is contained in:
Jonas Jenwald 2025-02-06 18:34:31 +01:00
parent f1152f5caf
commit d5d3d8b3f7
2 changed files with 32 additions and 7 deletions

View file

@ -632,18 +632,24 @@ class FeatureTest {
if (
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
(typeof navigator !== "undefined" &&
typeof navigator?.platform === "string")
typeof navigator?.platform === "string" &&
typeof navigator?.userAgent === "string")
) {
const { platform, userAgent } = navigator;
return shadow(this, "platform", {
isMac: navigator.platform.includes("Mac"),
isWindows: navigator.platform.includes("Win"),
isAndroid: userAgent.includes("Android"),
isLinux: platform.includes("Linux"),
isMac: platform.includes("Mac"),
isWindows: platform.includes("Win"),
isFirefox:
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
(typeof navigator?.userAgent === "string" &&
navigator.userAgent.includes("Firefox")),
userAgent.includes("Firefox"),
});
}
return shadow(this, "platform", {
isAndroid: false,
isLinux: false,
isMac: false,
isWindows: false,
isFirefox: false,