tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nav2-test-instance-accessors.html (3244B)


      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        <script src="/common/get-host-info.sub.js"></script>
     11    </head>
     12    <body>
     13        <h1>Description</h1>
     14        <p>This test validates that nav timing 2 instance can be accessed by three different accessors once available: window.performance.getEntries()/getEntriesByType("navigation")/getEntriesByName("document")</p>
     15 
     16        <script>
     17        var host_info = get_host_info();
     18        var expectedUrl = "http://" + host_info.ORIGINAL_HOST + ":" +
     19          host_info.HTTP_PORT + "/navigation-timing/nav2-test-instance-accessors.html";
     20        var navTiming2Attributes = [
     21            'connectEnd',
     22            'connectStart',
     23            'decodedBodySize',
     24            'domComplete',
     25            'domContentLoadedEventEnd',
     26            'domContentLoadedEventStart',
     27            'domInteractive',
     28            'domainLookupEnd',
     29            'domainLookupStart',
     30            'duration',
     31            'encodedBodySize',
     32            'entryType',
     33            'fetchStart',
     34            'initiatorType',
     35            'loadEventEnd',
     36            'loadEventStart',
     37            'name',
     38            'redirectCount',
     39            'redirectEnd',
     40            'redirectStart',
     41            'requestStart',
     42            'responseEnd',
     43            'responseStart',
     44            'secureConnectionStart',
     45            'transferSize',
     46            'type',
     47            'unloadEventEnd',
     48            'unloadEventStart',
     49            'workerStart'
     50        ];
     51 
     52        async_test(function (t) {
     53            var observer = new PerformanceObserver(
     54                t.step_func(function (entryList) {
     55                    var instance1 = performance.getEntries()[0];
     56                    var instance2 = performance.getEntriesByType("navigation")[0];
     57                    var instance3 = performance.getEntriesByName(expectedUrl)[0];
     58 
     59                    assert_equals(performance.getEntriesByType("navigation").length, 1, "Expected there is only one navigation timing instance.");
     60                    assert_equals(performance.getEntriesByName(expectedUrl).length, 1, "Expected there is only one navigation timing instance.");
     61 
     62                    for (var i = 0; i < navTiming2Attributes.length; i++) {
     63                        assert_equals(instance1[navTiming2Attributes[i]], instance2[navTiming2Attributes[i]]);
     64                    }
     65 
     66                    for (var i = 0; i < navTiming2Attributes.length; i++) {
     67                        assert_equals(instance1[navTiming2Attributes[i]], instance3[navTiming2Attributes[i]]);
     68                    }
     69                    observer.disconnect();
     70                    t.done();
     71                })
     72            );
     73            observer.observe({entryTypes: ["navigation"]});
     74 
     75        }, "Performance navigation timing entries are accessible through three different accessors.");
     76        </script>
     77    </body>
     78 </html>