OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8" /> |
| 5 <title>Navigation Timing 2 WPT</title> |
| 6 <link rel="author" title="Google" href="http://www.google.com/" /> |
| 7 <link rel="help" href="http://www.w3.org/TR/navigation-timing-2/#sec-Per
formanceNavigationTiming"/> |
| 8 <script src="/resources/testharness.js"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> |
| 10 </head> |
| 11 <body> |
| 12 <h1>Description</h1> |
| 13 <p>This test validates that each window has a unique nav timing 2 instan
ce.</p> |
| 14 <iframe id="frameContext" src="resources/blank_page_green.html" style="d
isplay:none;";></iframe> |
| 15 <script> |
| 16 |
| 17 var navTiming2Attributes = [ |
| 18 'connectEnd', |
| 19 'connectStart', |
| 20 'decodedBodySize', |
| 21 'domComplete', |
| 22 'domContentLoadedEventEnd', |
| 23 'domContentLoadedEventStart', |
| 24 'domInteractive', |
| 25 'domainLookupEnd', |
| 26 'domainLookupStart', |
| 27 'duration', |
| 28 'encodedBodySize', |
| 29 'entryType', |
| 30 'fetchStart', |
| 31 'initiatorType', |
| 32 'loadEventEnd', |
| 33 'loadEventStart', |
| 34 'name', |
| 35 'redirectCount', |
| 36 'redirectEnd', |
| 37 'redirectStart', |
| 38 'requestStart', |
| 39 'responseEnd', |
| 40 'responseStart', |
| 41 'secureConnectionStart', |
| 42 'transferSize', |
| 43 'type', |
| 44 'unloadEventEnd', |
| 45 'unloadEventStart', |
| 46 'workerStart' |
| 47 ]; |
| 48 |
| 49 function not_same_instance(instance1, instance2, attributes) { |
| 50 for (var i in attributes) { |
| 51 if (instance1[attributes[i]] != instance2[attributes[i]]) |
| 52 return true; |
| 53 } |
| 54 return false; |
| 55 } |
| 56 |
| 57 async_test(function (t) { |
| 58 var observer = new PerformanceObserver( |
| 59 t.step_func(function (entryList) { |
| 60 assert_equals(entryList.getEntriesByType("navigation").l
ength, 1, "Only one nav timing instance exists."); |
| 61 assert_equals(document.getElementById("frameContext").co
ntentWindow.performance.getEntriesByType("navigation").length, 1, |
| 62 "Only one nav timing instance exists."); |
| 63 var main_frame_instance = entryList.getEntriesByType("na
vigation")[0]; |
| 64 var iframe_instance = document.getElementById("frameCont
ext").contentWindow.performance.getEntriesByType("navigation")[0]; |
| 65 assert_true(not_same_instance(main_frame_instance, ifram
e_instance, navTiming2Attributes), |
| 66 "Two nav timing instances are not the same instance.
"); |
| 67 observer.disconnect(); |
| 68 t.done(); |
| 69 }) |
| 70 ); |
| 71 observer.observe({entryTypes: ["navigation"]}); |
| 72 |
| 73 }, "Each window has a unique nav timing 2 instance."); |
| 74 </script> |
| 75 </body> |
| 76 </html> |
OLD | NEW |