mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
Merge pull request #489 from lightpanda-io/microtasks
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / puppeteer-perf (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
wpt / web platform tests (push) Has been cancelled
wpt / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
nightly build / build-linux-x86_64 (push) Has been cancelled
nightly build / build-linux-aarch64 (push) Has been cancelled
nightly build / build-macos-aarch64 (push) Has been cancelled
nightly build / build-macos-x86_64 (push) Has been cancelled
run v8 micro tasks
This commit is contained in:
@@ -100,6 +100,13 @@ pub const Browser = struct {
|
||||
self.session = null;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn runMicrotasks(self: *const Browser) void {
|
||||
// if no session exists, there is nothing to do.
|
||||
if (self.session == null) return;
|
||||
|
||||
return self.session.?.env.runMicrotasks();
|
||||
}
|
||||
};
|
||||
|
||||
// Session is like a browser's tab.
|
||||
@@ -237,7 +244,7 @@ pub const Session = struct {
|
||||
std.debug.assert(self.page != null);
|
||||
|
||||
// Reset all existing callbacks.
|
||||
self.app.loop.reset();
|
||||
self.app.loop.resetJS();
|
||||
|
||||
self.env.stop();
|
||||
// TODO unload document: https://html.spec.whatwg.org/#unloading-documents
|
||||
|
||||
@@ -44,21 +44,11 @@ fn sendInspector(cmd: anytype, action: anytype) !void {
|
||||
|
||||
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
||||
|
||||
// remove awaitPromise true params
|
||||
// TODO: delete when Promise are correctly handled by zig-js-runtime
|
||||
if (action == .callFunctionOn or action == .evaluate) {
|
||||
const json = cmd.input.json;
|
||||
if (std.mem.indexOf(u8, json, "\"awaitPromise\":true")) |_| {
|
||||
// +1 because we'll be turning a true -> false
|
||||
const buf = try cmd.arena.alloc(u8, json.len + 1);
|
||||
_ = std.mem.replace(u8, json, "\"awaitPromise\":true", "\"awaitPromise\":false", buf);
|
||||
bc.session.callInspector(buf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// the result to return is handled directly by the inspector.
|
||||
bc.session.callInspector(cmd.input.json);
|
||||
|
||||
// force running micro tasks after send input to the inspector.
|
||||
cmd.cdp.browser.runMicrotasks();
|
||||
}
|
||||
|
||||
pub const ExecutionContextCreated = struct {
|
||||
|
||||
@@ -64,6 +64,8 @@ const Browser = struct {
|
||||
const session = self.session orelse return false;
|
||||
return std.mem.eql(u8, session.id, session_id);
|
||||
}
|
||||
|
||||
pub fn runMicrotasks(_: *const Browser) void {}
|
||||
};
|
||||
|
||||
const Session = struct {
|
||||
|
||||
2
vendor/zig-js-runtime
vendored
2
vendor/zig-js-runtime
vendored
Submodule vendor/zig-js-runtime updated: d959ef86cc...8fd9176583
Reference in New Issue
Block a user