42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
</head>
|
|
<body>
|
|
<span id="e"></span>
|
|
<span id="f"></span>
|
|
<script>
|
|
description("Tests the timestamps from performance.now increase and are in milliseconds");
|
|
|
|
function busyWait(millis) {
|
|
var start = Date.now();
|
|
while (Date.now() - start < millis) {}
|
|
}
|
|
|
|
var firstTimestamp = window.performance.now();
|
|
shouldBeDefined("firstTimestamp");
|
|
shouldBeGreaterThanOrEqual("firstTimestamp", "0");
|
|
|
|
// Verify returned value is in milliseconds since navigationStart. This
|
|
// generously assumes this JS will run within the first 5 seconds while ruling
|
|
// out the possibility that the returned value is in milliseconds since epoch.
|
|
shouldBeTrue("firstTimestamp < 5000");
|
|
|
|
var waitTime = 10;
|
|
busyWait(waitTime);
|
|
|
|
var secondTimestamp = window.performance.now();
|
|
shouldBeDefined("secondTimestamp");
|
|
shouldBeGreaterThanOrEqual("secondTimestamp", "firstTimestamp + (waitTime / 2)");
|
|
|
|
// Verify that the difference is in the milliseconds range, keeping
|
|
// the range test broad to avoid issues on overloaded bots.
|
|
var elapsed = secondTimestamp - firstTimestamp;
|
|
shouldBeGreaterThanOrEqual("elapsed", "1");
|
|
shouldBeTrue("elapsed < 100");
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|