Lightpanda: the headless browser designed for AI and automation
webapi: report performance.timeOrigin relative to the Unix epoch
Jay Hemnani649938e52941
diff --git a/src/browser/tests/performance.html b/src/browser/tests/performance.htmlindex 06d1e5d6a..53bc227a6 100644--- a/src/browser/tests/performance.html+++ b/src/browser/tests/performance.html@@ -604,3 +604,8 @@});}</script>++<script id=timeOrigin_is_unix_epoch>+ // timeOrigin + now() is the current wall-clock time, like Date.now().+ testing.expectEqual(true, Math.abs(performance.timeOrigin + performance.now() - Date.now()) < 1000);+</script>diff --git a/src/browser/webapi/Performance.zig b/src/browser/webapi/Performance.zigindex a4bc5d509..f135c011f 100644--- a/src/browser/webapi/Performance.zig+++ b/src/browser/webapi/Performance.zig@@ -46,6 +46,8 @@ pub const Proto = EventTarget;_proto: *EventTarget,_time_origin: u64,+// Wall-clock (Unix epoch) microseconds at the same moment, exposed as timeOrigin.+_time_origin_unix: u64,_arena: Allocator,_factory: *Factory,// Marks and measures. Kept in startTime order (see insertOrdered), as the@@ -90,6 +92,7 @@ pub fn init(factory: *Factory, arena: Allocator) !*Performance {._arena = arena,._factory = factory,._time_origin = highResTimestamp(),+ ._time_origin_unix = lp.datetime.microTimestamp(.real),});}@@ -115,7 +118,7 @@ pub fn now(self: *const Performance) f64 {fn getTimeOrigin(self: *const Performance) f64 {// Return as milliseconds- return @as(f64, @floatFromInt(self._time_origin)) / 1000.0;+ return @as(f64, @floatFromInt(self._time_origin_unix)) / 1000.0;}fn getNavigation(self: *Performance) *PerformanceNavigation {