test-timing-reload.html (3576B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>window.performance.timing attributes after a reloaded navigation</title> 6 <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> 7 <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/> 8 <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"/> 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 <script src="/common/performance-timeline-utils.js"></script> 12 <script src="resources/webperftestharness.js"></script> 13 <script> 14 setup({explicit_done: true}); 15 16 // explicitly test the namespace before we start testing 17 test_namespace('navigation'); 18 19 var reload_frame; 20 var initial_timing; 21 22 function onload_test() 23 { 24 reload_frame = document.getElementById("frameContext"); 25 26 if (reload_frame.contentWindow.performance === undefined) 27 { 28 // avoid script errors 29 done(); 30 return; 31 } 32 33 reload_frame.onload = do_test; 34 35 // save frame's initial timings 36 initial_timing = {}; 37 var timing = reload_frame.contentWindow.performance.timing; 38 39 for (var i = 0; i < timingAttributes.length; ++i) 40 { 41 var property = timingAttributes[i]; 42 initial_timing[property] = timing[property]; 43 } 44 45 step_timeout(reload_the_frame, 100); 46 } 47 48 function reload_the_frame() 49 { 50 reload_frame.contentWindow.location.reload(true); 51 } 52 53 function do_test() 54 { 55 reload_frame.onload = ""; 56 57 // ensure the frame reloaded 58 test_equals(reload_frame.contentWindow.performance.navigation.type, 59 performanceNamespace.navigation.TYPE_RELOAD, 60 "window.performance.navigation.type == TYPE_RELOAD"); 61 62 // ensure reload timings changed 63 var timing = reload_frame.contentWindow.performance.timing; 64 for (var i = 0; i < timingAttributes.length; ++i) 65 { 66 var property = timingAttributes[i]; 67 68 // ignore any timings that were zero initially 69 if (initial_timing[property] !== 0) 70 { 71 test_not_equals(timing[property], initial_timing[property], 72 property + " is different after the reload."); 73 } 74 } 75 76 done(); 77 } 78 </script> 79 </head> 80 <body onload="onload_test();"> 81 <h1>Description</h1> 82 <p>This test validates that the window.performance.timing attributes change when a page is reloaded.</p> 83 84 <p>This page should be loaded with a green background frame below. The frame will be automatically reloaded 85 and then verified that the window.performance.timing attributes have been updated to the new reloaded navigation timings.</p> 86 87 <div id="log"></div> 88 <br /> 89 <iframe id="frameContext" src="resources/blank_page_green.html" style="width: 250px; height: 250px;"></iframe> 90 91 </body> 92 </html>