explicitly load testing.js

This commit is contained in:
Karl Seguin
2025-09-01 22:14:50 +08:00
parent 3a0a930b79
commit 8a9cbaf413
3 changed files with 3 additions and 12 deletions

View File

@@ -1,3 +1,5 @@
<script src="../testing.js"></script>
<body> <body>
<iframe src="https://httpbin.io/html" title="iframea"></iframe> <iframe src="https://httpbin.io/html" title="iframea"></iframe>
<iframe src="https://httpbin.io/html" title="iframeb"></iframe> <iframe src="https://httpbin.io/html" title="iframeb"></iframe>

View File

@@ -1,3 +1,4 @@
<script src="../testing.js"></script>
<body></body> <body></body>
<script id=aliases> <script id=aliases>
testing.expectEqual(window, window.self); testing.expectEqual(window, window.self);

View File

@@ -516,18 +516,6 @@ pub fn newRunner(file: []const u8) !void {
try_catch.init(js_context); try_catch.init(js_context);
defer try_catch.deinit(); defer try_catch.deinit();
// if you want to make a lot of changes to testing.js, but don't want to reload
// every time, use this to dynamically load it during development
const content = try std.fs.cwd().readFileAlloc(arena_allocator, "src/browser/tests/testing.js", 1024 * 32);
// const content = @embedFile("browser/tests/testing.js");
js_context.eval(content, "testing.js") catch |err| {
const msg = try_catch.err(arena_allocator) catch @errorName(err) orelse "unknown";
std.debug.print("Failed to setup testing.js: {s}\n", .{msg});
return err;
};
const url = try std.fmt.allocPrint(arena_allocator, "http://localhost:9582/src/browser/tests/{s}", .{file}); const url = try std.fmt.allocPrint(arena_allocator, "http://localhost:9582/src/browser/tests/{s}", .{file});
try page.navigate(url, .{}); try page.navigate(url, .{});
page.wait(2); page.wait(2);