From ee22e07fff8a15b8280ae29bb3d82d42e4e595e2 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Sat, 7 Feb 2026 17:51:58 +0800 Subject: [PATCH] Add dummy window.opener accessor This seems pretty complicated to implement...mostly because we'd have to keep a window around in certain cases and because exactly what's accessible on that window depends on a few factors. --- src/browser/tests/window/window.html | 1 + src/browser/webapi/Window.zig | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/browser/tests/window/window.html b/src/browser/tests/window/window.html index b9d3d1d8..290f9874 100644 --- a/src/browser/tests/window/window.html +++ b/src/browser/tests/window/window.html @@ -5,6 +5,7 @@ testing.expectEqual(window, globalThis); testing.expectEqual(window, self); testing.expectEqual(window, window.self); + testing.expectEqual(null, window.opener); testing.expectEqual(1080, innerHeight); testing.expectEqual(1920, innerWidth); diff --git a/src/browser/webapi/Window.zig b/src/browser/webapi/Window.zig index bbcaa3b0..00b0ea2c 100644 --- a/src/browser/webapi/Window.zig +++ b/src/browser/webapi/Window.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -421,6 +421,12 @@ pub fn getScrollY(self: *const Window) u32 { return self._scroll_pos.y; } +pub fn getOpener(_: *const Window) ?*Window { + // This should return a window-like object in specific conditions. Would be + // pretty complicated to properly support I think. + return null; +} + const ScrollToOpts = union(enum) { x: i32, opts: Opts, @@ -749,6 +755,7 @@ pub const JsApi = struct { pub const pageYOffset = bridge.accessor(Window.getScrollY, null, .{ .cache = "pageYOffset" }); pub const scrollTo = bridge.function(Window.scrollTo, .{}); pub const scroll = bridge.function(Window.scrollTo, .{}); + pub const opener = bridge.accessor(Window.getOpener, null, .{}); }; const testing = @import("../../testing.zig");