Replace SessionState directly with the Page.

This commit is contained in:
Karl Seguin
2025-05-27 18:35:35 +08:00
parent 1d0876af4d
commit 7d9951aa3c
34 changed files with 562 additions and 603 deletions

View File

@@ -113,10 +113,10 @@ fn run(arena: Allocator, test_file: []const u8, loader: *FileLoader, err_out: *?
});
defer runner.deinit();
try polyfill.load(arena, runner.scope);
try polyfill.load(arena, runner.page.scope);
// loop over the scripts.
const doc = parser.documentHTMLToDocument(runner.state.window.document);
const doc = parser.documentHTMLToDocument(runner.page.window.document);
const scripts = try parser.documentGetElementsByTagName(doc, "script");
const script_count = try parser.nodeListLength(scripts);
for (0..script_count) |i| {
@@ -147,7 +147,7 @@ fn run(arena: Allocator, test_file: []const u8, loader: *FileLoader, err_out: *?
try parser.eventInit(loadevt, "load", .{});
_ = try parser.eventTargetDispatchEvent(
parser.toEventTarget(@TypeOf(runner.window), &runner.window),
parser.toEventTarget(@TypeOf(runner.page.window), &runner.page.window),
loadevt,
);
}
@@ -155,9 +155,9 @@ fn run(arena: Allocator, test_file: []const u8, loader: *FileLoader, err_out: *?
{
// wait for all async executions
var try_catch: Env.TryCatch = undefined;
try_catch.init(runner.scope);
try_catch.init(runner.page.scope);
defer try_catch.deinit();
try runner.loop.run();
try runner.page.loop.run();
if (try_catch.hasCaught()) {
err_out.* = (try try_catch.err(arena)) orelse "unknwon error";