window: use window as global object

This commit is contained in:
Pierre Tachoire
2024-02-26 10:57:51 +01:00
parent b8bf09c8e5
commit fec212ab94
9 changed files with 22 additions and 43 deletions

View File

@@ -41,10 +41,6 @@ fn testExecFn(
try js_env.start(alloc);
defer js_env.stop();
// alias global as self and window
try js_env.attachObject(try js_env.getGlobal(), "self", null);
try js_env.attachObject(try js_env.getGlobal(), "window", null);
// document
const file = try std.fs.cwd().openFile("test.html", .{});
defer file.close();
@@ -54,8 +50,10 @@ fn testExecFn(
std.debug.print("documentHTMLClose error: {s}\n", .{@errorName(err)});
};
// add document object
try js_env.addObject(doc, "document");
// alias global as self and window
var window = Window.create(null);
window.replaceDocument(parser.documentHTMLToDocument(doc));
try js_env.bindGlobal(window);
// run test
try execFn(alloc, js_env);