tor-browser

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

nav2-test-navigate-within-document.html (3074B)


      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/#sec-navigation-timing-interface"/>
      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 all of the window.performance.getEntriesByType("navigation") attributes remain unchanged after an in document navigation (URL fragment change).</p>
     14 
     15        <script>
     16            setup({ single_test: true });
     17 
     18            var navTiming2Attributes = [
     19                'connectEnd',
     20                'connectStart',
     21                'decodedBodySize',
     22                'domComplete',
     23                'domContentLoadedEventEnd',
     24                'domContentLoadedEventStart',
     25                'domInteractive',
     26                'domainLookupEnd',
     27                'domainLookupStart',
     28                'duration',
     29                'encodedBodySize',
     30                'entryType',
     31                'fetchStart',
     32                'initiatorType',
     33                'loadEventEnd',
     34                'loadEventStart',
     35                'name',
     36                'redirectCount',
     37                'redirectEnd',
     38                'redirectStart',
     39                'requestStart',
     40                'responseEnd',
     41                'responseStart',
     42                'secureConnectionStart',
     43                'transferSize',
     44                'type',
     45                'unloadEventEnd',
     46                'unloadEventStart',
     47                'workerStart'
     48            ];
     49 
     50            var initial_timing = {};
     51 
     52            function check_timing_not_changed()
     53            {
     54                var timing = window.performance.getEntriesByType("navigation")[0];
     55                for (var i = 0; i < navTiming2Attributes.length; ++i)
     56                {
     57                    var property = navTiming2Attributes[i];
     58                    assert_equals(timing[property], initial_timing[property],
     59                                property + " is the same after in document navigation.");
     60                }
     61                done();
     62            }
     63 
     64            function save_timing_after_load()
     65            {
     66                var timing = window.performance.getEntriesByType("navigation")[0];
     67                for (var i = 0; i < navTiming2Attributes.length; ++i)
     68                {
     69                    var property = navTiming2Attributes[i];
     70                    initial_timing[property] = timing[property];
     71                }
     72                window.location.href = "#1";
     73                setTimeout("check_timing_not_changed()", 0);
     74            }
     75 
     76            function load_handler()
     77            {
     78                window.removeEventListener("load", load_handler);
     79                setTimeout("save_timing_after_load()", 0);
     80            }
     81 
     82            window.addEventListener("load", load_handler, false);
     83        </script>
     84    </body>
     85 </html>