aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/ZigGlobalObject.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-09-10 20:40:46 -0800
committerGravatar GitHub <noreply@github.com> 2023-09-10 21:40:46 -0700
commitedea4f095a3bebf54f986c0fa038482316f4cde8 (patch)
tree922c4d1fb2b2abf1831a181b7e9571847aa654dc /src/bun.js/bindings/ZigGlobalObject.cpp
parent07c88435e0aede1d58bf462ef56270ca43d4e961 (diff)
downloadbun-edea4f095a3bebf54f986c0fa038482316f4cde8.tar.gz
bun-edea4f095a3bebf54f986c0fa038482316f4cde8.tar.zst
bun-edea4f095a3bebf54f986c0fa038482316f4cde8.zip
Fixes #4588 (#4804)
* Fixes #4588 * typo * fixup --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp')
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index 6398fb7a0..cdc4adb1b 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -3075,11 +3075,21 @@ void GlobalObject::finishCreation(VM& vm)
JSC::Identifier userAgentIdentifier = JSC::Identifier::fromString(init.vm, "userAgent"_s);
JSC::Identifier hardwareConcurrencyIdentifier = JSC::Identifier::fromString(init.vm, "hardwareConcurrency"_s);
- JSC::JSObject* obj = JSC::constructEmptyObject(init.owner, init.owner->objectPrototype(), 3);
+ JSC::JSObject* obj = JSC::constructEmptyObject(init.owner, init.owner->objectPrototype(), 4);
obj->putDirect(init.vm, userAgentIdentifier, JSC::jsString(init.vm, str));
obj->putDirect(init.vm, init.vm.propertyNames->toStringTagSymbol,
jsNontrivialString(init.vm, "Navigator"_s), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly);
+// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform
+// https://github.com/oven-sh/bun/issues/4588
+#if OS(DARWIN)
+ obj->putDirect(init.vm, JSC::Identifier::fromString(init.vm, "platform"_s), JSC::jsString(init.vm, String("MacIntel"_s)));
+#elif OS(WINDOWS)
+ obj->putDirect(init.vm, JSC::Identifier::fromString(init.vm, "platform"_s), JSC::jsString(init.vm, String("Win32"_s)));
+#elif OS(LINUX)
+ obj->putDirect(init.vm, JSC::Identifier::fromString(init.vm, "platform"_s), JSC::jsString(init.vm, String("Linux x86_64"_s)));
+#endif
+
obj->putDirect(init.vm, hardwareConcurrencyIdentifier, JSC::jsNumber(cpuCount));
init.set(
obj);