nav2-test-attributes-exist.html (2482B)
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-PerformanceNavigationTiming"/> 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 PerformanceObserver can observe nav timing 2 instance and that the expected attributes in nav timing 2 instance exist (but does not validate that the values are correct).</p> 14 15 <script> 16 var navTiming2Attributes = [ 17 'connectEnd', 18 'connectStart', 19 'decodedBodySize', 20 'domComplete', 21 'domContentLoadedEventEnd', 22 'domContentLoadedEventStart', 23 'domInteractive', 24 'domainLookupEnd', 25 'domainLookupStart', 26 'duration', 27 'encodedBodySize', 28 'entryType', 29 'fetchStart', 30 'initiatorType', 31 'loadEventEnd', 32 'loadEventStart', 33 'name', 34 'nextHopProtocol', 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 async_test(function (t) { 49 var observer = new PerformanceObserver( 50 t.step_func(function (entryList) { 51 var entries = entryList.getEntries(); 52 assert_equals(entries.length, 1, 53 "There should be only one navigation timing instance."); 54 for (var i = 0; i < navTiming2Attributes.length; i++) { 55 assert_true(navTiming2Attributes[i] in entries[0], 56 "Expected attribute: " + navTiming2Attributes[i] + "."); 57 } 58 observer.disconnect(); 59 t.done(); 60 }) 61 ); 62 observer.observe({entryTypes: ["navigation"]}); 63 64 }, "Performance navigation timing entries are observable."); 65 </script> 66 </body> 67 </html>