Work on DDG support (but still not working)

- Add dummy MediaQueryList and window.matchMedia
- Execute deferred scripts after non-deferred
  I realize this doesn't change much, given how we currently load all scripts
  after the document is parsed, but scripts _could_ depend on execution order.
- Add support for executing the `onload` attribute of <scripts>

I also cleaned up some of the Script code, i.e. removimg `unknown` kind and
simply returning a null script, and removing the EmptyBody error and returning
a null body string.

Finally, I re-enabled the microtask loop which I must have previously disabled.
This commit is contained in:
Karl Seguin
2025-05-07 18:14:06 +08:00
parent 3466325d4d
commit 7fa7f4ed8a
5 changed files with 155 additions and 90 deletions

View File

@@ -536,7 +536,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
const ModuleLoader = struct {
ptr: *anyopaque,
func: *const fn (ptr: *anyopaque, specifier: []const u8) anyerror![]const u8,
func: *const fn (ptr: *anyopaque, specifier: []const u8) anyerror!?[]const u8,
};
// no init, started with executor.startScope()
@@ -790,7 +790,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
const source = module_loader.func(module_loader.ptr, specifier) catch |err| {
log.err("fetchModuleSource for '{s}' fetch error: {}", .{ specifier, err });
return null;
};
} orelse return null;
const m = compileModule(self.isolate, source, specifier) catch |err| {
log.err("fetchModuleSource for '{s}' compile error: {}", .{ specifier, err });
@@ -2825,7 +2825,7 @@ const NoopInspector = struct {
};
const ErrorModuleLoader = struct {
pub fn fetchModuleSource(_: *anyopaque, _: []const u8) ![]const u8 {
pub fn fetchModuleSource(_: *anyopaque, _: []const u8) !?[]const u8 {
return error.NoModuleLoadConfigured;
}
};