tor-browser

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

resource_subframe_self_navigation.html (1661B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <body>
      5 <script>
      6 function numberOfDownloads(url) {
      7    let absoluteURL = new URL(url, location.href).href;
      8    return performance.getEntriesByName(absoluteURL).length;
      9 }
     10 
     11 function waitForSubFrameLoad() {
     12    return new Promise((resolve) => {
     13        window.subFrameLoaded = () => {
     14            window.subFrameLoaded = null;
     15            resolve();
     16        };
     17    });
     18 }
     19 
     20 function runTest(type) {
     21    performance.clearResourceTimings();
     22    let elem = document.createElement(type);
     23    if (type === 'object')
     24        elem.data = 'resources/self_navigation.html?' + type;
     25    else
     26        elem.src = 'resources/self_navigation.html?' + type;
     27    document.body.appendChild(elem);
     28    return waitForSubFrameLoad().then(() => {
     29        let resources = performance.getEntriesByType('resource');
     30        assert_equals(numberOfDownloads('resources/self_navigation.html?' + type), 1);
     31        assert_equals(numberOfDownloads('resources/notify_parent.html?redirected'), 0);
     32        document.body.removeChild(elem);
     33    });
     34 }
     35 
     36 promise_test(
     37    () => runTest('iframe'),
     38    "Subsequent <iframe> navigations don't appear in the resource-timing buffer.");
     39 
     40 promise_test(
     41    () => runTest('frame'),
     42    "Subsequent <frame> navigations don't appear in the resource-timing buffer.");
     43 
     44 promise_test(
     45    () => runTest('embed'),
     46    "Subsequent <embed> navigations don't appear in the resource-timing buffer.");
     47 
     48 promise_test(
     49    () => runTest('object'),
     50    "Subsequent <object> navigations don't appear in the resource-timing buffer.");
     51 
     52 </script>
     53 </body>