mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1638 from lightpanda-io/performance-mark-name
accept more performance mark name and return dummy 0
This commit is contained in:
@@ -252,6 +252,28 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id=measure_with_navigation_timing_marks>
|
||||
{
|
||||
// performance.measure() must accept PerformanceTiming attribute names
|
||||
// (e.g. "fetchStart") as start/end marks per the W3C User Timing Level 2 spec.
|
||||
// https://www.w3.org/TR/user-timing/#dom-performance-measure
|
||||
performance.clearMarks();
|
||||
performance.clearMeasures();
|
||||
|
||||
performance.mark("mark-dataComplete");
|
||||
let m = performance.measure("dataComplete", "fetchStart", "mark-dataComplete");
|
||||
testing.expectEqual('dataComplete', m.name);
|
||||
testing.expectEqual('measure', m.entryType);
|
||||
testing.expectEqual(true, m.duration >= 0);
|
||||
|
||||
// navigationStart is also a valid mark name (was already supported)
|
||||
performance.mark("mark-end");
|
||||
let m2 = performance.measure("fromNav", "navigationStart", "mark-end");
|
||||
testing.expectEqual('fromNav', m2.name);
|
||||
testing.expectEqual(true, m2.duration >= 0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id=mixed_marks_and_measures>
|
||||
{
|
||||
performance.clearMarks();
|
||||
|
||||
@@ -208,9 +208,37 @@ fn getMarkTime(self: *const Performance, mark_name: []const u8) !f64 {
|
||||
}
|
||||
}
|
||||
|
||||
// Recognized mark names by browsers. `navigationStart` is an equivalent
|
||||
// to 0. Others are dependant to request arrival, end of request etc.
|
||||
if (std.mem.eql(u8, "navigationStart", mark_name)) {
|
||||
// PerformanceTiming attribute names are valid start/end marks per the
|
||||
// W3C User Timing Level 2 spec. All are relative to navigationStart (= 0).
|
||||
// https://www.w3.org/TR/user-timing/#dom-performance-measure
|
||||
//
|
||||
// `navigationStart` is an equivalent to 0.
|
||||
// Others are dependant to request arrival, end of request etc, but we
|
||||
// return a dummy 0 value for now.
|
||||
const navigation_timing_marks = std.StaticStringMap(void).initComptime(.{
|
||||
.{ "navigationStart", {} },
|
||||
.{ "unloadEventStart", {} },
|
||||
.{ "unloadEventEnd", {} },
|
||||
.{ "redirectStart", {} },
|
||||
.{ "redirectEnd", {} },
|
||||
.{ "fetchStart", {} },
|
||||
.{ "domainLookupStart", {} },
|
||||
.{ "domainLookupEnd", {} },
|
||||
.{ "connectStart", {} },
|
||||
.{ "connectEnd", {} },
|
||||
.{ "secureConnectionStart", {} },
|
||||
.{ "requestStart", {} },
|
||||
.{ "responseStart", {} },
|
||||
.{ "responseEnd", {} },
|
||||
.{ "domLoading", {} },
|
||||
.{ "domInteractive", {} },
|
||||
.{ "domContentLoadedEventStart", {} },
|
||||
.{ "domContentLoadedEventEnd", {} },
|
||||
.{ "domComplete", {} },
|
||||
.{ "loadEventStart", {} },
|
||||
.{ "loadEventEnd", {} },
|
||||
});
|
||||
if (navigation_timing_marks.has(mark_name)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user