Skip to content

Commit 030a0dd

Browse files
committed
Add navigator.userAgent to qjs CLI
1 parent bace4f6 commit 030a0dd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

qjs.c

+8
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ static JSContext *JS_NewCustomContext(JSRuntime *rt)
104104
/* system modules */
105105
js_init_module_std(ctx, "std");
106106
js_init_module_os(ctx, "os");
107+
108+
/* navigator.userAgent */
109+
JSValue global = JS_GetGlobalObject(ctx);
110+
JSValue navigator = JS_NewObject(ctx);
111+
JS_DefinePropertyValueStr(ctx, navigator, "userAgent", JS_NewString(ctx, "quickjs-ng"), JS_PROP_ENUMERABLE);
112+
JS_DefinePropertyValueStr(ctx, global, "navigator", navigator, JS_PROP_ENUMERABLE);
113+
JS_FreeValue(ctx, global);
114+
107115
return ctx;
108116
}
109117

0 commit comments

Comments
 (0)