mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Compare commits
3 Commits
cdp-browse
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc83d85542 | ||
|
|
706a87a458 | ||
|
|
3ec15ad1f7 |
@@ -643,6 +643,18 @@ 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;
|
||||
}
|
||||
@@ -651,12 +663,6 @@ 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,6 +1350,7 @@ 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,22 +38,16 @@ const DEV_TOOLS_WINDOW_ID = 1923710101;
|
||||
pub fn processMessage(cmd: anytype) !void {
|
||||
const action = std.meta.stringToEnum(enum {
|
||||
getVersion,
|
||||
setPermission,
|
||||
setWindowBounds,
|
||||
resetPermissions,
|
||||
grantPermissions,
|
||||
getWindowForTarget,
|
||||
setDownloadBehavior,
|
||||
getWindowForTarget,
|
||||
setWindowBounds,
|
||||
}, cmd.input.action) orelse return error.UnknownMethod;
|
||||
|
||||
switch (action) {
|
||||
.getVersion => return getVersion(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),
|
||||
.getWindowForTarget => return getWindowForTarget(cmd),
|
||||
.setWindowBounds => return setWindowBounds(cmd),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,21 +89,6 @@ 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();
|
||||
|
||||
35
src/tests/html/script/order.html
Normal file
35
src/tests/html/script/order.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!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>
|
||||
2
src/tests/html/script/order.js
Normal file
2
src/tests/html/script/order.js
Normal file
@@ -0,0 +1,2 @@
|
||||
list += 'a';
|
||||
testing.expectEqual('a', list);
|
||||
3
src/tests/html/script/order_async.js
Normal file
3
src/tests/html/script/order_async.js
Normal file
@@ -0,0 +1,3 @@
|
||||
list += 'f';
|
||||
testing.expectEqual('abcdef', list);
|
||||
|
||||
2
src/tests/html/script/order_defer.js
Normal file
2
src/tests/html/script/order_defer.js
Normal file
@@ -0,0 +1,2 @@
|
||||
list += 'e';
|
||||
testing.expectEqual('abcde', list);
|
||||
Reference in New Issue
Block a user