OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta charset="utf-8" /> | 4 <meta charset="utf-8" /> |
5 <title>window.performance.now in shared workers</title> | 5 <title>window.performance.now in shared workers</title> |
6 <link rel="author" title="Google" href="http://www.google.com/" /> | 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"/> | 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> | 8 <script src="/w3c/resources/testharness.js"></script> |
9 <script src="/w3c/resources/testharnessreport.js"></script> | 9 <script src="/w3c/resources/testharnessreport.js"></script> |
10 <script src="/w3c/webperf/resources/webperftestharness.js"></script> | 10 <script src="/w3c/webperf/resources/webperftestharness.js"></script> |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 window.iframeStartTime = 0; | 33 window.iframeStartTime = 0; |
34 window.test_iframe = function(event, iframeNow) { | 34 window.test_iframe = function(event, iframeNow) { |
35 var workerTime = event.data; | 35 var workerTime = event.data; |
36 test_greater_than(workerTime, window.iframeStartTime, "Time since origin tim
e should be greater in the worker than the iframe", {}); | 36 test_greater_than(workerTime, window.iframeStartTime, "Time since origin tim
e should be greater in the worker than the iframe", {}); |
37 worker.port.postMessage(["close();"]); | 37 worker.port.postMessage(["close();"]); |
38 done(); | 38 done(); |
39 } | 39 } |
40 | 40 |
41 function start() { | 41 function start() { |
| 42 test_true("workerStart" in worker, "workerStart is defined on the SharedWork
er object"); |
| 43 test_greater_than(worker.workerStart, 0, "Time of worker start was after the
navigation start for the document"); |
42 worker.port.postMessage(tests); | 44 worker.port.postMessage(tests); |
43 } | 45 } |
44 | 46 |
45 function setupIframe() { | 47 function setupIframe() { |
46 var iframe = document.createElement("iframe"); | 48 var iframe = document.createElement("iframe"); |
47 var body = document.getElementsByTagName("body")[0]; | 49 var body = document.getElementsByTagName("body")[0]; |
48 body.appendChild(iframe); | 50 body.appendChild(iframe); |
49 var script = iframe.contentWindow.document.createElement("script"); | 51 var script = iframe.contentWindow.document.createElement("script"); |
50 script.innerHTML = | 52 script.innerHTML = |
51 "window.top.iframeStartTime = window.performance.now();" + | 53 "window.top.iframeStartTime = window.performance.now();" + |
52 "var worker = new SharedWorker('/w3c/webperf/resources/worker.js');" + | 54 "var worker = new SharedWorker('/w3c/webperf/resources/worker.js');" + |
53 "worker.port.onmessage = function(event) {" + | 55 "worker.port.onmessage = function(event) {" + |
54 " window.top.test_iframe(event);" + | 56 " window.top.test_iframe(event);" + |
55 "};" + | 57 "};" + |
56 "worker.port.postMessage(['self.performance.now();']);"; | 58 "worker.port.postMessage(['self.performance.now();']);"; |
57 iframe.contentWindow.document.body.appendChild(script); | 59 iframe.contentWindow.document.body.appendChild(script); |
58 } | 60 } |
59 | 61 |
60 window.addEventListener("load", start); | 62 window.addEventListener("load", start); |
61 </script> | 63 </script> |
62 </head> | 64 </head> |
63 <body> | 65 <body> |
64 <h1>Description</h1> | 66 <h1>Description</h1> |
65 <p>This test validates that performance.now() exists in shared workers and repor
ts reasonable times.</p> | 67 <p>This test validates that performance.now() exists in shared workers and repor
ts reasonable times.</p> |
66 | 68 |
67 <div id="log"></div> | 69 <div id="log"></div> |
68 | 70 |
69 </body> | 71 </body> |
70 </html> | 72 </html> |
OLD | NEW |