also used to initialize the worker context */
| 221 | |
| 222 | /* also used to initialize the worker context */ |
| 223 | static JSContext *JS_NewCustomContext(JSRuntime *rt) |
| 224 | { |
| 225 | JSContext *ctx; |
| 226 | ctx = JS_NewContext(rt); |
| 227 | if (!ctx) |
| 228 | return NULL; |
| 229 | /* system modules */ |
| 230 | js_init_module_std(ctx, "qjs:std"); |
| 231 | js_init_module_os(ctx, "qjs:os"); |
| 232 | js_init_module_bjson(ctx, "qjs:bjson"); |
| 233 | |
| 234 | JSValue global = JS_GetGlobalObject(ctx); |
| 235 | JS_SetPropertyFunctionList(ctx, global, global_obj, countof(global_obj)); |
| 236 | JSValue args = JS_NewArray(ctx); |
| 237 | int i; |
| 238 | for(i = 0; i < qjs__argc; i++) { |
| 239 | JS_SetPropertyUint32(ctx, args, i, JS_NewString(ctx, qjs__argv[i])); |
| 240 | } |
| 241 | JS_SetPropertyStr(ctx, global, "execArgv", args); |
| 242 | JS_SetPropertyStr(ctx, global, "argv0", JS_NewString(ctx, qjs__argv[0])); |
| 243 | JSValue navigator_proto = JS_NewObject(ctx); |
| 244 | JS_SetPropertyFunctionList(ctx, navigator_proto, navigator_proto_funcs, countof(navigator_proto_funcs)); |
| 245 | JSValue navigator = JS_NewObjectProto(ctx, navigator_proto); |
| 246 | JS_DefinePropertyValueStr(ctx, global, "navigator", navigator, JS_PROP_CONFIGURABLE | JS_PROP_ENUMERABLE); |
| 247 | JS_FreeValue(ctx, global); |
| 248 | JS_FreeValue(ctx, navigator_proto); |
| 249 | |
| 250 | return ctx; |
| 251 | } |
| 252 | |
| 253 | struct trace_malloc_data { |
| 254 | uint8_t *base; |
no test coverage detected