Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / performance / tests / test_timeOrigin.html
blob69796a432d0051cda7d3e61c0197ab8dbd226311
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for performance.timeOrigin</title>
5 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 </head>
8 <body>
9 <script type="text/js-worker" id="worker-src">
10 postMessage({ now: performance.now(), timeOrigin: performance.timeOrigin });
11 </script>
13 <script type="text/js-worker" id="shared-worker-src">
14 onconnect = function(evt) {
15 evt.ports[0].postMessage({ now: performance.now(), timeOrigin: performance.timeOrigin });
17 </script>
19 <script class="testbody" type="text/javascript">
21 function testBasic() {
22 ok("timeOrigin" in performance, "Performance.timeOrigin exists.");
23 ok(performance.timeOrigin > 0, "TimeOrigin must be greater than 0.");
24 next();
27 function testWorker() {
28 var now = performance.now();
30 var blob = new Blob([ document.getElementById("worker-src").textContent ],
31 { type: "text/javascript" });
32 var w = new Worker(URL.createObjectURL(blob));
33 w.onmessage = function(e) {
34 ok (e.data.now + e.data.timeOrigin > now + performance.timeOrigin, "Comparing worker.now and window.now");
35 next();
39 function testSharedWorker() {
40 var now = performance.now();
42 var blob = new Blob([ document.getElementById("shared-worker-src").textContent ],
43 { type: "text/javascript" });
44 var w = new SharedWorker(URL.createObjectURL(blob));
45 w.port.onmessage = function(e) {
46 ok (e.data.now + e.data.timeOrigin > now + performance.timeOrigin, "Comparing worker.now and window.now");
47 next();
51 var tests = [ testBasic, testWorker, testSharedWorker ];
52 function next() {
53 if (!tests.length) {
54 SpecialPowers.setBoolPref("privacy.reduceTimerPrecision", reduceTimePrecisionPrevPrefValue);
55 SimpleTest.finish();
56 return;
59 var test = tests.shift();
60 test();
63 SimpleTest.waitForExplicitFinish();
65 // It is a known issue that comparing time between a worker and a window
66 // when timer clamping is in effect may cause time to go backwards.
67 // Do not run this test with this preference set. For large values of
68 // clamping you will see failures. For small values, it is intermitant.
69 var reduceTimePrecisionPrevPrefValue = SpecialPowers.getBoolPref("privacy.reduceTimerPrecision");
70 SpecialPowers.setBoolPref("privacy.reduceTimerPrecision", false);
72 addLoadEvent(next);
73 </script>
74 </pre>
75 </body>
76 </html>