diff --git a/src/browser/Frame.zig b/src/browser/Frame.zig index 454ad784..dedb522e 100644 --- a/src/browser/Frame.zig +++ b/src/browser/Frame.zig @@ -721,7 +721,6 @@ fn scheduleNavigationWithArena(originator: *Frame, arena: Allocator, request_url if (!opts.force and URL.eqlDocument(target.url, resolved_url)) { target.url = try target.arena.dupeZ(u8, resolved_url); target.window._location = try Location.init(target.url, target); - target.document._location = target.window._location; if (target.parent == null) { try session.navigation.updateEntries(target.url, opts.kind, target, true); } diff --git a/src/browser/js/Snapshot.zig b/src/browser/js/Snapshot.zig index 517bf313..c625127c 100644 --- a/src/browser/js/Snapshot.zig +++ b/src/browser/js/Snapshot.zig @@ -587,6 +587,12 @@ fn attachClass(comptime JsApi: type, isolate: *v8.Isolate, template: *const v8.F const prototype = v8.v8__FunctionTemplate__PrototypeTemplate(template); const signature = v8.v8__Signature__New(isolate, template); + // Namespace objects (e.g. console) expose their members as own properties + // of each instance rather than via the prototype, so Object.entries(...) + // returns them. See https://console.spec.whatwg.org/#console-namespace. + const own_properties = @hasDecl(JsApi.Meta, "own_properties") and JsApi.Meta.own_properties; + const member_template = if (own_properties) instance else prototype; + const declarations = @typeInfo(JsApi).@"struct".decls; var has_named_index_getter = false; @@ -652,7 +658,7 @@ fn attachClass(comptime JsApi: type, isolate: *v8.Isolate, template: *const v8.F if (value.static) { v8.v8__Template__Set(@ptrCast(template), js_name, @ptrCast(function_template), v8.None); } else { - v8.v8__Template__Set(@ptrCast(prototype), js_name, @ptrCast(function_template), v8.None); + v8.v8__Template__Set(@ptrCast(member_template), js_name, @ptrCast(function_template), v8.None); } }, bridge.Indexed => { diff --git a/src/browser/tests/console/console.html b/src/browser/tests/console/console.html index 33c2fa62..8f68ccd8 100644 --- a/src/browser/tests/console/console.html +++ b/src/browser/tests/console/console.html @@ -1,6 +1,16 @@ + + + +