OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8" /> |
| 5 <title>window.performance.now in dedicated workers</title> |
| 6 <link rel="author" title="Google" href="http://www.google.com/" /> |
| 7 <link rel="help" href="https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighRes
olutionTime2/Overview.html"/> |
| 8 <script src="/w3c/resources/testharness.js"></script> |
| 9 <script src="/w3c/resources/testharnessreport.js"></script> |
| 10 <script src="/w3c/webperf/resources/webperftestharness.js"></script> |
| 11 <link rel="stylesheet" href="/w3c/resources/testharness.css" /> |
| 12 <script> |
| 13 setup({explicit_done: true}); |
| 14 |
| 15 var tests = [ |
| 16 '"performance" in self;', |
| 17 '"now" in self.performance;', |
| 18 'self.performance.now();', |
| 19 ]; |
| 20 |
| 21 var startTime = window.performance.now(); |
| 22 var worker = new Worker("/w3c/webperf/resources/worker.js"); |
| 23 |
| 24 worker.onmessage = function(event) { |
| 25 var results = event.data; |
| 26 assert_true(results.length == 3); |
| 27 test_true(results[0], "self.performance is defined"); |
| 28 test_true(results[1], "self.performance.now is defined"); |
| 29 test_greater_than(results[2], startTime, "Time in the worker should be after
the startTime in the main document"); |
| 30 test_greater_than(window.performance.now(), results[2], "Time in the worker
should be before the current time in the main document"); |
| 31 done(); |
| 32 } |
| 33 |
| 34 function start() { |
| 35 worker.postMessage(tests); |
| 36 } |
| 37 |
| 38 window.addEventListener("load", start); |
| 39 </script> |
| 40 </head> |
| 41 <body> |
| 42 <h1>Description</h1> |
| 43 <p>This test validates that performance.now() exists in dedicated workers and re
ports reasonable times.</p> |
| 44 |
| 45 <div id="log"></div> |
| 46 |
| 47 </body> |
| 48 </html> |
OLD | NEW |