You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert_equals(typeofself.performance,"object","self.performance is an object");
4
+
assert_equals((typeofself.performance.now),"function","self.performance.now() is a function");
5
+
assert_equals(typeofself.performance.now(),"number","self.performance.now() returns a number");
6
+
},"self.performance.now() is a function that returns a number");
7
+
8
+
test(function(){
9
+
assert_true(self.performance.now()>0);
10
+
},"self.performance.now() returns a positive number");
11
+
12
+
test(function(){
13
+
varnow1=self.performance.now();
14
+
varnow2=self.performance.now();
15
+
assert_true((now2-now1)>=0);
16
+
},"self.performance.now() difference is not negative");
17
+
18
+
async_test(function(){
19
+
// Check whether the performance.now() method is close to Date() within 30ms (due to inaccuracies)
20
+
varinitial_hrt=self.performance.now();
21
+
varinitial_date=Date.now();
22
+
this.step_timeout(function(){
23
+
varfinal_hrt=self.performance.now();
24
+
varfinal_date=Date.now();
25
+
assert_approx_equals(final_hrt-initial_hrt,final_date-initial_date,30,'High resolution time value increased by approximately the same amount as time from date object');
26
+
this.done();
27
+
},2000);
28
+
},'High resolution time has approximately the right relative magnitude');
// The time values returned when calling the now method MUST be monotonically increasing and not subject to system clock adjustments or system clock skew.
assert_greater_than_equal(workerOrigin-windowOrigin,200,'We waited 200ms to spawn the second worker, so its timeOrigin should be greater than that of the window.');
40
+
}));
41
+
},200);
42
+
},'Window and worker timeOrigins differ when worker is created after a delay.');
assert_not_equals(workerTimeOrigin,0,"worker timeOrigin must not be 0");
19
+
assert_not_equals(performance.timeOrigin,0,"Document timeOrigin must not be 0");
20
+
21
+
assert_equals(globalTimeOrigin,performance.timeOrigin,"timeOrigin should not be changed in same document mode");
22
+
assert_less_than(globalTimeOrigin,workerTimeOrigin,"Document timeOrigin must be earlier than worker timeOrigin");
23
+
24
+
// Document and worker's now() start from their respective timeOrigins.
25
+
consttimeDiff=workerTimeOrigin-globalTimeOrigin;// convert worker's time to Document time.
26
+
assert_less_than(globalTimeOrigin+globalNowBeforeWorkerStart,globalTimeOrigin+timeDiff+workerNow,"Document old now is earlier than worker now.");
27
+
28
+
// Comparing timing between Document and worker threads could be delicate as it relies on the thread implementation and could be subject to race conditions.
29
+
}));
30
+
},'timeOrigin and now() should be correctly ordered between window and worker');
0 commit comments