fix wpt tests with platform requirement

This commit is contained in:
Pierre Tachoire
2025-07-01 16:45:24 -07:00
parent a3c14748d3
commit 80348ef190
2 changed files with 19 additions and 2 deletions

View File

@@ -70,7 +70,13 @@ pub fn main() !void {
defer _ = test_arena.reset(.{ .retain_capacity = {} }); defer _ = test_arena.reset(.{ .retain_capacity = {} });
var err_out: ?[]const u8 = null; var err_out: ?[]const u8 = null;
const result = run(test_arena.allocator(), test_file, &loader, &err_out) catch |err| blk: { const result = run(
test_arena.allocator(),
&platform,
test_file,
&loader,
&err_out,
) catch |err| blk: {
if (err_out == null) { if (err_out == null) {
err_out = @errorName(err); err_out = @errorName(err);
} }
@@ -89,7 +95,13 @@ pub fn main() !void {
try writer.finalize(); try writer.finalize();
} }
fn run(arena: Allocator, test_file: []const u8, loader: *FileLoader, err_out: *?[]const u8) !?[]const u8 { fn run(
arena: Allocator,
platform: *const Platform,
test_file: []const u8,
loader: *FileLoader,
err_out: *?[]const u8,
) !?[]const u8 {
// document // document
const html = blk: { const html = blk: {
const full_path = try std.fs.path.join(arena, &.{ WPT_DIR, test_file }); const full_path = try std.fs.path.join(arena, &.{ WPT_DIR, test_file });
@@ -110,6 +122,7 @@ fn run(arena: Allocator, test_file: []const u8, loader: *FileLoader, err_out: *?
var runner = try @import("testing.zig").jsRunner(arena, .{ var runner = try @import("testing.zig").jsRunner(arena, .{
.url = "http://127.0.0.1", .url = "http://127.0.0.1",
.html = html, .html = html,
.platform = platform,
}); });
defer runner.deinit(); defer runner.deinit();

View File

@@ -19,6 +19,8 @@
const std = @import("std"); const std = @import("std");
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const Platform = @import("runtime/js.zig").Platform;
pub const allocator = std.testing.allocator; pub const allocator = std.testing.allocator;
pub const expectError = std.testing.expectError; pub const expectError = std.testing.expectError;
pub const expect = std.testing.expect; pub const expect = std.testing.expect;
@@ -383,6 +385,7 @@ pub const JsRunner = struct {
var app = try App.init(alloc, .{ var app = try App.init(alloc, .{
.run_mode = .serve, .run_mode = .serve,
.tls_verify_host = false, .tls_verify_host = false,
.platform = opts.platform,
}); });
errdefer app.deinit(); errdefer app.deinit();
@@ -474,6 +477,7 @@ pub const JsRunner = struct {
}; };
const RunnerOpts = struct { const RunnerOpts = struct {
platform: ?*const Platform = null,
url: []const u8 = "https://lightpanda.io/opensource-browser/", url: []const u8 = "https://lightpanda.io/opensource-browser/",
html: []const u8 = html: []const u8 =
\\ <div id="content"> \\ <div id="content">