forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnow-api.js
30 lines (24 loc) · 821 Bytes
/
now-api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
if (self.importScripts)
importScripts("../../resources/js-test-pre.js");
self.jsTestIsAsync = true;
if (self.window)
description("Basic Interface test for High Resolution Time APIs.");
debug("Performance");
shouldBeDefined(`Performance`);
shouldBeDefined(`Performance.prototype.now`);
shouldThrow(`new Performance()`);
debug("performance");
shouldBeDefined(`performance`);
shouldBeTrue(`performance instanceof Performance`);
shouldBeTrue(`typeof performance.now() === "number"`);
shouldBeTrue(`performance.now() <= performance.now()`);
self.time1 = performance.now();
setTimeout(function() {
self.delta = performance.now() - time1;
// Allow for ~20ms error.
shouldBeTrue(`delta >= 95 && delta <= 120`);
if (self.importScripts)
finishJSTest();
else
testWorker();
}, 100);