Skip to content

Commit c6754d6

Browse files
committed
wpt: dispatch native event
1 parent edd0c7d commit c6754d6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/wpt/run.zig

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
5959
var window = Window.create(null);
6060
window.replaceDocument(html_doc);
6161
window.setStorageShelf(&storageShelf);
62-
try js_env.bindGlobal(window);
62+
try js_env.bindGlobal(&window);
6363

6464
// thanks to the arena, we don't need to deinit res.
6565
var res: jsruntime.JSResult = undefined;
@@ -107,10 +107,14 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
107107
}
108108

109109
// Mark tests as ready to run.
110-
res = try evalJS(js_env, alloc, "window.dispatchEvent(new Event('load'));", "ready");
111-
if (!res.success) {
112-
return res;
113-
}
110+
const loadevt = try parser.eventCreate();
111+
defer parser.eventDestroy(loadevt);
112+
113+
try parser.eventInit(loadevt, "load", .{});
114+
_ = try parser.eventTargetDispatchEvent(
115+
parser.toEventTarget(Window, &window),
116+
loadevt,
117+
);
114118

115119
// Check the final test status.
116120
res = try evalJS(js_env, alloc, "report.status;", "teststatus");

0 commit comments

Comments
 (0)