| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <meta charset="utf-8" > | |
| 5 <title>window.performance.now across frames</title> | |
| 6 <link rel="author" title="Google" href="http://www.google.com/"> | |
| 7 <link rel="help" href="http://www.w3.org/TR/hr-time/#sec-extenstions-per
formance-interface"> | |
| 8 | |
| 9 <script src="/w3c/resources/testharness.js"></script> | |
| 10 <script src="/w3c/resources/testharnessreport.js"></script> | |
| 11 | |
| 12 <script type="text/javascript"> | |
| 13 setup({explicit_done: true}); | |
| 14 | |
| 15 function start_test() { | |
| 16 setTimeout(function() { | |
| 17 var iframe = document.createElement('iframe'); | |
| 18 iframe.id = 'frameContext'; | |
| 19 iframe.onload = finish_test; | |
| 20 iframe.src = "resources/now_frame.html"; | |
| 21 document.body.appendChild(iframe); | |
| 22 }, 1000); | |
| 23 } | |
| 24 | |
| 25 function finish_test() { | |
| 26 var childWindow = document.getElementById('frameContext').contentW
indow; | |
| 27 | |
| 28 // Verify a positive number is returned for both the frame and par
ent. | |
| 29 test(function() { assert_true(window.performance.now() > 0); }, 'p
arent performance.now() > 0'); | |
| 30 test(function() { assert_true(childWindow.performance.now() > 0);
}, 'child performance.now() > 0'); | |
| 31 | |
| 32 // Verify that the test properly created the child at least a seco
nd after the parent. | |
| 33 test(function () { assert_true(childWindow.performance.timing.navi
gationStart > (window.performance.timing.navigationStart + 1000)); }, | |
| 34 'Child created at least 1 second after parent'); | |
| 35 | |
| 36 test(function () { | |
| 37 var parentNow = window.performance.now(); | |
| 38 var childNow = childWindow.performance.now(); | |
| 39 var childParentSkew = Math.abs(childNow - parentNow); | |
| 40 assert_true(childParentSkew > 1000, 'Child and parent\'s now()s
have different bases (skewed more than 1 second)'); | |
| 41 | |
| 42 var childLoadTime = childWindow.performance.timing.loadEventStar
t - childWindow.performance.timing.navigationStart; | |
| 43 assert_true(1000 > (childNow - childLoadTime), 'Child\'s now() i
s based on its document\'s navigationStart'); | |
| 44 }, 'Child and parent time bases are correct'); | |
| 45 | |
| 46 done(); | |
| 47 } | |
| 48 </script> | |
| 49 | |
| 50 </head> | |
| 51 <body onload="start_test()"> | |
| 52 <h1>Description</h1> | |
| 53 <p>This test validates the values of the window.performance.now() are ba
sed on the current document's navigationStart.</p> | |
| 54 <div id="log"></div> | |
| 55 </body> | |
| 56 </html> | |
| OLD | NEW |