tor-browser

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

nav2-test-redirect-server.html (2306B)


      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 
     11        <script>
     12            setup({ single_test: true });
     13 
     14            function verifyTimingEventOrder(eventOrder, timingEntry) {
     15                for (let i = 0; i < eventOrder.length - 1; i++) {
     16                    assert_true(timingEntry[eventOrder[i]] < timingEntry[eventOrder[i + 1]],
     17                        "Expected " + eventOrder[i] + " to be no greater than " + eventOrder[i + 1] + ".");
     18                }
     19            }
     20 
     21            function onload_test()
     22            {
     23                const frame_performance = document.getElementById("frameContext").contentWindow.performance;
     24                const navigation_entry = frame_performance.getEntriesByType("navigation")[0];
     25                assert_equals(navigation_entry.type,
     26                        "navigate",
     27                        "Expected navigation type  to be navigate.");
     28                assert_equals(navigation_entry.redirectCount, 1, "Expected redirectCount to be 1.");
     29                assert_equals(navigation_entry.name, 'http://' + document.location.host + '/navigation-timing/resources/blank_page_green.html');
     30 
     31                var timgingEvents = [
     32                    'startTime',
     33                    'redirectStart',
     34                    'redirectEnd',
     35                ];
     36                verifyTimingEventOrder(timgingEvents, frame_performance.getEntriesByType("navigation")[0]);
     37                done();
     38            }
     39        </script>
     40 
     41    </head>
     42    <body>
     43        <h1>Description</h1>
     44        <p>This test validates the values of the window.performance.redirectCount and the
     45           window.performance.timing.redirectStart/End times for a same-origin server side redirect navigation.</p>
     46 
     47        <iframe id="frameContext" onload="onload_test();" src="/common/redirect.py?location=/navigation-timing/resources/blank_page_green.html" style="width: 250px; height: 250px;"></iframe>
     48    </body>
     49 </html>