1 description("Tests the timestamps from performance.now increase and are in milliseconds");
3 function busyWait(millis) {
4 var start = Date.now();
5 while (Date.now() - start < millis) {}
8 var firstTimestamp = window.performance.now();
9 shouldBeDefined("firstTimestamp");
10 shouldBeGreaterThanOrEqual("firstTimestamp", "0");
12 // Verify returned value is in milliseconds since navigationStart. This
13 // generously assumes this JS will run within the first 5 seconds while ruling
14 // out the possibility that the returned value is in milliseconds since epoch.
15 shouldBeTrue("firstTimestamp < 5000");
20 var secondTimestamp = window.performance.now();
21 shouldBeDefined("secondTimestamp");
22 shouldBeGreaterThanOrEqual("secondTimestamp", "firstTimestamp + (waitTime / 2)");
24 // Verify that the difference is in the milliseconds range, keeping
25 // the range test broad to avoid issues on overloaded bots.
26 var elapsed = secondTimestamp - firstTimestamp;
27 shouldBeGreaterThanOrEqual("elapsed", "1");
28 shouldBeTrue("elapsed < 100");