test-navigate-within-document.html (2413B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" > 5 <title>window.performance.timing in document navigation</title> 6 <link rel="author" title="Google" href="http://www.google.com/" /> 7 <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="/common/performance-timeline-utils.js"></script> 11 <script src="resources/webperftestharness.js"></script> 12 </head> 13 <body> 14 <h1>Description</h1> 15 <p>This test validates that all of the window.performance.timing attributes remain unchanged after an in document navigation (URL fragment change).</p> 16 17 <div id="log"></div> 18 <script> 19 setup({explicit_done: true}); 20 21 // explicitly test the namespace before we start testing 22 test_namespace('timing'); 23 24 var timing; 25 26 function check_timing_not_changed() 27 { 28 for (var i = 0; i < timingAttributes.length; ++i) 29 { 30 var property = timingAttributes[i]; 31 test_equals(timing[property], initial_timing[property], 32 property + " is the same after in document navigation."); 33 } 34 done(); 35 } 36 37 var initial_timing = {}; 38 function save_timing_after_load() 39 { 40 for (var i = 0; i < timingAttributes.length; ++i) 41 { 42 var property = timingAttributes[i]; 43 initial_timing[property] = timing[property]; 44 } 45 window.location.href = "#1"; 46 step_timeout(check_timing_not_changed, 0); 47 } 48 49 function load_handler() 50 { 51 if (performanceNamespace === undefined) 52 { 53 // avoid script errors 54 done(); 55 return; 56 } 57 58 timing = performanceNamespace.timing; 59 60 window.removeEventListener("load", load_handler); 61 step_timeout(save_timing_after_load, 0); 62 } 63 64 window.addEventListener("load", load_handler, false); 65 </script> 66 </body> 67 </html>