Merge pull request #233 from lightpanda-io/fix-window-global

wpt: dispatch native event
This commit is contained in:
Pierre Tachoire
2024-05-07 16:18:10 +02:00
committed by GitHub

View File

@@ -59,7 +59,7 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
var window = Window.create(null); var window = Window.create(null);
window.replaceDocument(html_doc); window.replaceDocument(html_doc);
window.setStorageShelf(&storageShelf); window.setStorageShelf(&storageShelf);
try js_env.bindGlobal(window); try js_env.bindGlobal(&window);
// thanks to the arena, we don't need to deinit res. // thanks to the arena, we don't need to deinit res.
var res: jsruntime.JSResult = undefined; var res: jsruntime.JSResult = undefined;
@@ -107,10 +107,14 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime dir: []const u8, f: []const
} }
// Mark tests as ready to run. // Mark tests as ready to run.
res = try evalJS(js_env, alloc, "window.dispatchEvent(new Event('load'));", "ready"); const loadevt = try parser.eventCreate();
if (!res.success) { defer parser.eventDestroy(loadevt);
return res;
} try parser.eventInit(loadevt, "load", .{});
_ = try parser.eventTargetDispatchEvent(
parser.toEventTarget(Window, &window),
loadevt,
);
// Check the final test status. // Check the final test status.
res = try evalJS(js_env, alloc, "report.status;", "teststatus"); res = try evalJS(js_env, alloc, "report.status;", "teststatus");