From 62fe1c292d0f38c66e508b4ddf769a3e36367f22 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 16 Nov 2023 10:09:00 +0100 Subject: [PATCH] wpt: add a console.log debug message --- src/main_wpt.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main_wpt.zig b/src/main_wpt.zig index 7f567ea21..96c8ad42d 100644 --- a/src/main_wpt.zig +++ b/src/main_wpt.zig @@ -205,6 +205,11 @@ fn runWPT(arena: *std.heap.ArenaAllocator, comptime apis: []jsruntime.API, f: [] \\ return true; \\}; \\window.removeEventListener = function () {}; + \\ + \\console = []; + \\console.log = function () { + \\ console.push(...arguments); + \\}; ; res = try evalJS(js_env, alloc, init, "init"); if (!res.success) { @@ -247,6 +252,12 @@ fn runWPT(arena: *std.heap.ArenaAllocator, comptime apis: []jsruntime.API, f: [] return res; } + // display console logs + res = try evalJS(js_env, alloc, "console.join(', ');", "console"); + if (res.result.len > 0) { + std.debug.print("-- CONSOLE LOG\n{s}\n--\n", .{res.result}); + } + // Check the final test status. res = try evalJS(js_env, alloc, "report.status;", "teststatus"); if (!res.success) {