mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-10-09 04:42:30 -04:00
webapi: resource-timing
Adds resource timing, e.g. `performance.getEntriesByType("resource")`.
The `resource-timing` WPT category is currently at 4.6%, and this is a first
step at improving it. It also hopefully fixes https://github.com/lightpanda-io/browser/issues/3359
This is more complicated than I thought because there's a "Timing-Allow-Origin"
header that a server can include which hides some of the data if the request
doesn't come from the listed origin. And that, of course, interacts with
redirects.
(The DOMException change is seemingly random, but it came up in one of the WPT
cases I was looking at).
This commit is contained in:
17 files changed
+1281
-53
No files matched your search
@@ -693,6 +693,33 @@ fn testHTTPHandler(req: *std.http.Server.Request) !void {
|
||||
});
|
||||
}
|
||||
|
||||
// Scripts, so a cross-origin (localhost) load doesn't depend on CORS.
|
||||
if (std.mem.eql(u8, path, "/resource-timing/tao")) {
|
||||
return req.respond("window.__rt_tao = true;", .{
|
||||
.extra_headers = &.{
|
||||
.{ .name = "Content-Type", .value = "text/javascript" },
|
||||
.{ .name = "Timing-Allow-Origin", .value = "https://example.com, *" },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, path, "/resource-timing/plain")) {
|
||||
return req.respond("window.__rt_plain = true;", .{
|
||||
.extra_headers = &.{
|
||||
.{ .name = "Content-Type", .value = "text/javascript" },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, path, "/resource-timing/redirect")) {
|
||||
return req.respond("", .{
|
||||
.status = .found,
|
||||
.extra_headers = &.{
|
||||
.{ .name = "Location", .value = "/resource-timing/plain" },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, path, "/redirect-no-fragment")) {
|
||||
return req.respond("", .{
|
||||
.status = .found,
|
||||
|
||||
Reference in new issue
Block a user