WorkerPerformanceNow.html (1036B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>performance.now in dedicated workers</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <script> 10 async_test(function(t) { 11 const worker = new Worker('support/WorkerSendingPerformanceNow.js'); 12 worker.onmessage = t.step_func_done(event => { 13 const results = event.data; 14 assert_equals(results.length, 4); 15 assert_equals(results[0], 'undefined', 16 'workerStart not defined on the Worker object'); 17 assert_equals(results[1], 'object', "self.performance is defined"); 18 assert_equals(results[2], 'function', "self.performance.now is defined"); 19 assert_greater_than(results[3], 0, "Time in the worker should be positive"); 20 assert_greater_than(window.performance.now(), results[3], "Time in the worker should be before the current time in the main document"); 21 }); 22 worker.postMessage(''); 23 }, 'performance.now() exists in dedicated workers and reports reasonable times'); 24 </script> 25 </body> 26 </html>