fix(js): keep performance clock bounded

This commit is contained in:
SGavrl committed 2026-08-01 15:20:35 +00:00
1 parent cdab919599
commit d93ff517fc
2 files changed
+20 -6

No files matched your search

+14
View File
@@ -1330,6 +1330,20 @@ mod tests {
assert_eq!(violations.as_f64(), Some(0.0), "performance.now() went backwards");
}
#[test]
fn performance_now_does_not_outrun_elapsed_time() {
let mut rt = setup_runtime("<html><body></body></html>");
let lead = rt
.evaluate(
"(function(){for(var i=0;i<500000;i++)performance.now(); return performance.now()-(Date.now()-performance.timeOrigin);})()",
)
.unwrap();
assert!(
lead.as_f64().unwrap() <= 1.0,
"performance.now() advanced ahead of elapsed time: {lead}"
);
}
#[test]
fn test_document_title() {
let mut rt = setup_runtime("<html><head><title>Test</title></head><body></body></html>");