fix wpt and legacy_test runners

This commit is contained in:
Karl Seguin
2026-01-17 11:46:22 +08:00
parent 48f07a110f
commit 412c881cd4
2 changed files with 13 additions and 7 deletions

View File

@@ -85,15 +85,18 @@ pub fn run(allocator: Allocator, file: []const u8, session: *lp.Session) !void {
const page = try session.createPage();
defer session.removePage();
const js_context = page.js;
var ls: lp.js.Local.Scope = undefined;
page.js.localScope(&ls);
defer ls.deinit();
var try_catch: lp.js.TryCatch = undefined;
try_catch.init(js_context);
try_catch.init(&ls.local);
defer try_catch.deinit();
try page.navigate(url, .{});
_ = session.wait(2000);
js_context.eval("testing.assertOk()", "testing.assertOk()") catch |err| {
ls.local.eval("testing.assertOk()", "testing.assertOk()") catch |err| {
const caught = try_catch.caughtOrError(allocator, err);
std.debug.print("{s}: test failure\nError: {f}\n", .{ file, caught });
return err;

View File

@@ -118,20 +118,23 @@ fn run(
_ = page.wait(2000);
const js_context = page.js;
var ls: lp.js.Local.Scope = undefined;
page.js.localScope(&ls);
defer ls.deinit();
var try_catch: lp.js.TryCatch = undefined;
try_catch.init(js_context);
try_catch.init(&ls.local);
defer try_catch.deinit();
// Check the final test status.
js_context.eval("report.status", "teststatus") catch |err| {
ls.local.eval("report.status", "teststatus") catch |err| {
const caught = try_catch.caughtOrError(arena, err);
err_out.* = caught.exception;
return err;
};
// return the detailed result.
const value = js_context.exec("report.log", "report") catch |err| {
const value = ls.local.exec("report.log", "report") catch |err| {
const caught = try_catch.caughtOrError(arena, err);
err_out.* = caught.exception;
return err;