test-timing-attributes-order.html (5189B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>window.performance.timing attribute ordering on a simple 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 test_namespace('timing'); 17 18 var step = 1; 19 function onload_test() 20 { 21 if (step === 1 && window.performance === undefined) 22 { 23 // avoid script errors 24 done(); 25 return; 26 } 27 28 var navigation_frame = document.getElementById("frameContext").contentWindow; 29 performanceNamespace = navigation_frame.performance; 30 switch (step) 31 { 32 case 1: 33 { 34 navigation_frame.location.href = '/navigation-timing/resources/blank_page_green.html'; 35 step++; 36 break; 37 } 38 case 2: 39 { 40 test_namespace('navigation', true); 41 42 // 43 // Tests 44 // 45 test_equals(performanceNamespace.navigation.type, 46 performanceNamespace.navigation.TYPE_NAVIGATE, 47 'window.performance.navigation.type == TYPE_NAVIGATE'); 48 49 // navigiation must be non-0 50 test_timing_greater_than('navigationStart', 0); 51 52 // must be no redirection for this test case 53 test_timing_equals('redirectStart', 0); 54 test_timing_equals('redirectEnd', 0); 55 56 // validate attribute ordering 57 test_timing_order('fetchStart', 'navigationStart'); 58 test_timing_order('domainLookupStart', 'fetchStart'); 59 test_timing_order('domainLookupEnd', 'domainLookupStart'); 60 test_timing_order('connectStart', 'domainLookupEnd'); 61 test_timing_order('connectEnd', 'connectStart'); 62 test_timing_order('requestStart', 'connectEnd'); 63 test_timing_order('responseStart', 'requestStart'); 64 test_timing_order('responseEnd', 'responseStart'); 65 test_timing_order('domLoading', 'fetchStart'); 66 test_timing_order('domInteractive', 'responseEnd'); 67 test_timing_order('domContentLoadedEventStart', 'domInteractive'); 68 test_timing_order('domContentLoadedEventEnd', 'domContentLoadedEventStart'); 69 test_timing_order('domComplete', 'domContentLoadedEventEnd'); 70 test_timing_order('loadEventStart', 'domContentLoadedEventEnd'); 71 test_timing_order('loadEventEnd', 'loadEventStart'); 72 73 // setup requires the frame to have a previous page with an onunload event handler. 74 test_timing_order('unloadEventStart', 'navigationStart'); 75 test_timing_order('unloadEventEnd', 'unloadEventStart'); 76 77 step++; 78 done(); 79 break; 80 } 81 default: 82 break; 83 } 84 } 85 </script> 86 </head> 87 <body> 88 <h1>Description</h1> 89 <p>This test validates the ordering of the window.performance.timing attributes.</p> 90 91 <p>This page should be loaded with a yellow background frame below which contains an unload event 92 handler.</p> 93 94 <p>After the page loads, the frame is navigated to a new blank page with a green background. At this point, the navigation timeline is verified</p> 95 96 <p>This test passes if all of the checks to the frame.window.performance.timing attributes are 97 correct throughout the navigation scenario and the frame below ends with a green background. 98 Otherwise, this test fails.</p> 99 100 <h1>Setup</h1> 101 102 <div id="log"></div> 103 <br /> 104 <iframe id="frameContext" 105 onload="/* Need to make sure we don't examine loadEventEnd 106 until after the load event has finished firing */ 107 step_timeout(onload_test, 0);" 108 src="resources/blank_page_unload.html" 109 style="width: 250px; height: 250px;"></iframe> 110 </body> 111 </html>