fix(js): keep performance clock bounded
This commit is contained in:
1 parent
cdab919599
commit
d93ff517fc
2 files changed
+20
-6
No files matched your search
@@ -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>");
|
||||
|
||||
Reference in new issue
Block a user