Simple window.top implementation (not frame-aware)

This commit is contained in:
Karl Seguin
2025-05-27 15:25:27 +08:00
parent 9abead7c49
commit 9bcaaab9d7

View File

@@ -117,6 +117,11 @@ pub const Window = struct {
return self;
}
// TODO: frames
pub fn get_top(self: *Window) *Window {
return self;
}
pub fn get_document(self: *Window) ?*parser.DocumentHTML {
return self.document;
}
@@ -292,6 +297,11 @@ test "Browser.HTML.Window" {
var runner = try testing.jsRunner(testing.tracking_allocator, .{});
defer runner.deinit();
try runner.testCases(&.{
.{ "window.parent === window", "true" },
.{ "window.top === window", "true" },
}, .{});
// requestAnimationFrame should be able to wait by recursively calling itself
// Note however that we in this test do not wait as the request is just send to the browser
try runner.testCases(&.{