mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Compare commits
10 Commits
20314fccec
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc83d85542 | ||
|
|
706a87a458 | ||
|
|
3ec15ad1f7 | ||
|
|
07e603ecda | ||
|
|
52fc2c365f | ||
|
|
8f3620adf0 | ||
|
|
f7abf0956f | ||
|
|
73217f7832 | ||
|
|
52fb2010fc | ||
|
|
03ffcdb604 |
@@ -228,9 +228,9 @@ pub fn addFromElement(self: *ScriptManager, element: *parser.Element, comptime c
|
|||||||
if (source == .@"inline") {
|
if (source == .@"inline") {
|
||||||
// if we're here, it means that we have pending scripts (i.e. self.scripts
|
// if we're here, it means that we have pending scripts (i.e. self.scripts
|
||||||
// is not empty). Because the script is inline, it's complete/ready, but
|
// is not empty). Because the script is inline, it's complete/ready, but
|
||||||
// we need to process them in order
|
// we need to process them in order.
|
||||||
pending_script.complete = true;
|
pending_script.complete = true;
|
||||||
self.scripts.append(&pending_script.node);
|
pending_script.getList().append(&pending_script.node);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
log.debug(.http, "script queue", .{
|
log.debug(.http, "script queue", .{
|
||||||
@@ -643,6 +643,18 @@ pub const PendingScript = struct {
|
|||||||
// if async isn't known, it'll fallback to defer.
|
// if async isn't known, it'll fallback to defer.
|
||||||
|
|
||||||
const script = &self.script;
|
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) {
|
if (script.is_async) {
|
||||||
return &self.manager.asyncs;
|
return &self.manager.asyncs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1350,6 +1350,7 @@ test "Browser: HTML.HtmlScriptElement" {
|
|||||||
try testing.htmlRunner("html/script/import.html");
|
try testing.htmlRunner("html/script/import.html");
|
||||||
try testing.htmlRunner("html/script/dynamic_import.html");
|
try testing.htmlRunner("html/script/dynamic_import.html");
|
||||||
try testing.htmlRunner("html/script/importmap.html");
|
try testing.htmlRunner("html/script/importmap.html");
|
||||||
|
try testing.htmlRunner("html/script/order.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
test "Browser: HTML.HtmlSlotElement" {
|
test "Browser: HTML.HtmlSlotElement" {
|
||||||
|
|||||||
@@ -488,16 +488,16 @@ pub const Page = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std.debug.print("\nprimary schedule: {d}\n", .{self.scheduler.primary.count()});
|
std.debug.print("\nhigh_priority schedule: {d}\n", .{self.scheduler.high_priority.count()});
|
||||||
var it = self.scheduler.primary.iterator();
|
var it = self.scheduler.high_priority.iterator();
|
||||||
while (it.next()) |task| {
|
while (it.next()) |task| {
|
||||||
std.debug.print(" - {s} schedule: {d}ms\n", .{ task.name, task.ms - now });
|
std.debug.print(" - {s} schedule: {d}ms\n", .{ task.name, task.ms - now });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std.debug.print("\nsecondary schedule: {d}\n", .{self.scheduler.secondary.count()});
|
std.debug.print("\nlow_priority schedule: {d}\n", .{self.scheduler.low_priority.count()});
|
||||||
var it = self.scheduler.secondary.iterator();
|
var it = self.scheduler.low_priority.iterator();
|
||||||
while (it.next()) |task| {
|
while (it.next()) |task| {
|
||||||
std.debug.print(" - {s} schedule: {d}ms\n", .{ task.name, task.ms - now });
|
std.debug.print(" - {s} schedule: {d}ms\n", .{ task.name, task.ms - now });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,7 +373,11 @@ const Command = struct {
|
|||||||
\\ Defaults to
|
\\ Defaults to
|
||||||
++ (if (builtin.mode == .Debug) " pretty." else " logfmt.") ++
|
++ (if (builtin.mode == .Debug) " pretty." else " logfmt.") ++
|
||||||
\\
|
\\
|
||||||
\\ --user_agent_suffix
|
\\--log_filter_scopes
|
||||||
|
\\ Filter out too verbose logs per scope:
|
||||||
|
\\ http, unknown_prop, script_event, ...
|
||||||
|
\\
|
||||||
|
\\--user_agent_suffix
|
||||||
\\ Suffix to append to the Lightpanda/X.Y User-Agent
|
\\ Suffix to append to the Lightpanda/X.Y User-Agent
|
||||||
\\
|
\\
|
||||||
;
|
;
|
||||||
|
|||||||
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