mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Compare commits
1 Commits
main
...
cdp-browse
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d91d24b12 |
@@ -643,18 +643,6 @@ pub const PendingScript = struct {
|
||||
// if async isn't known, it'll fallback to defer.
|
||||
|
||||
const script = &self.script;
|
||||
|
||||
// Module scripts are deferred by default.
|
||||
// https://v8.dev/features/modules#defer
|
||||
if (script.kind == .module) {
|
||||
return &self.manager.deferreds;
|
||||
}
|
||||
|
||||
// Script is not a module but inline, we ignore async/defer properties.
|
||||
if (script.source == .@"inline") {
|
||||
return &self.manager.scripts;
|
||||
}
|
||||
|
||||
if (script.is_async) {
|
||||
return &self.manager.asyncs;
|
||||
}
|
||||
@@ -663,6 +651,12 @@ pub const PendingScript = struct {
|
||||
return &self.manager.deferreds;
|
||||
}
|
||||
|
||||
// Module scripts are deferred by default.
|
||||
// https://v8.dev/features/modules#defer
|
||||
if (script.kind == .module) {
|
||||
return &self.manager.deferreds;
|
||||
}
|
||||
|
||||
return &self.manager.scripts;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1350,7 +1350,6 @@ test "Browser: HTML.HtmlScriptElement" {
|
||||
try testing.htmlRunner("html/script/import.html");
|
||||
try testing.htmlRunner("html/script/dynamic_import.html");
|
||||
try testing.htmlRunner("html/script/importmap.html");
|
||||
try testing.htmlRunner("html/script/order.html");
|
||||
}
|
||||
|
||||
test "Browser: HTML.HtmlSlotElement" {
|
||||
|
||||
@@ -38,16 +38,22 @@ const DEV_TOOLS_WINDOW_ID = 1923710101;
|
||||
pub fn processMessage(cmd: anytype) !void {
|
||||
const action = std.meta.stringToEnum(enum {
|
||||
getVersion,
|
||||
setDownloadBehavior,
|
||||
getWindowForTarget,
|
||||
setPermission,
|
||||
setWindowBounds,
|
||||
resetPermissions,
|
||||
grantPermissions,
|
||||
getWindowForTarget,
|
||||
setDownloadBehavior,
|
||||
}, cmd.input.action) orelse return error.UnknownMethod;
|
||||
|
||||
switch (action) {
|
||||
.getVersion => return getVersion(cmd),
|
||||
.setDownloadBehavior => return setDownloadBehavior(cmd),
|
||||
.getWindowForTarget => return getWindowForTarget(cmd),
|
||||
.setPermission => return setPermission(cmd),
|
||||
.setWindowBounds => return setWindowBounds(cmd),
|
||||
.resetPermissions => return resetPermissions(cmd),
|
||||
.grantPermissions => return grantPermissions(cmd),
|
||||
.getWindowForTarget => return getWindowForTarget(cmd),
|
||||
.setDownloadBehavior => return setDownloadBehavior(cmd),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +95,21 @@ fn setWindowBounds(cmd: anytype) !void {
|
||||
return cmd.sendResult(null, .{});
|
||||
}
|
||||
|
||||
// TODO: noop method
|
||||
fn grantPermissions(cmd: anytype) !void {
|
||||
return cmd.sendResult(null, .{});
|
||||
}
|
||||
|
||||
// TODO: noop method
|
||||
fn setPermission(cmd: anytype) !void {
|
||||
return cmd.sendResult(null, .{});
|
||||
}
|
||||
|
||||
// TODO: noop method
|
||||
fn resetPermissions(cmd: anytype) !void {
|
||||
return cmd.sendResult(null, .{});
|
||||
}
|
||||
|
||||
const testing = @import("../testing.zig");
|
||||
test "cdp.browser: getVersion" {
|
||||
var ctx = testing.context();
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="../../testing.js"></script>
|
||||
|
||||
<script defer id="remote_defer" src="order_defer.js"></script>
|
||||
<script defer id="remote_async" src="order_async.js"></script>
|
||||
|
||||
<script type=module id="inline_module">
|
||||
// inline module is always deferred.
|
||||
list += 'g';
|
||||
testing.expectEqual('abcdefg', list);
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var list = '';
|
||||
</script>
|
||||
|
||||
<script id="remote" src="order.js"></script>
|
||||
|
||||
<script async id="inline_async">
|
||||
// inline script ignore async
|
||||
list += 'b';
|
||||
testing.expectEqual('ab', list);
|
||||
</script>
|
||||
|
||||
<script defer id="inline_defer">
|
||||
// inline script ignore defer
|
||||
list += 'c';
|
||||
testing.expectEqual('abc', list);
|
||||
</script>
|
||||
|
||||
<script id="default">
|
||||
// simple inline script
|
||||
list += 'd';
|
||||
testing.expectEqual('abcd', list);
|
||||
</script>
|
||||
@@ -1,2 +0,0 @@
|
||||
list += 'a';
|
||||
testing.expectEqual('a', list);
|
||||
@@ -1,3 +0,0 @@
|
||||
list += 'f';
|
||||
testing.expectEqual('abcdef', list);
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
list += 'e';
|
||||
testing.expectEqual('abcde', list);
|
||||
Reference in New Issue
Block a user