tor-browser

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

no-entries-for-cross-origin-css-fetched-memory-cache.sub.html (2270B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>Make sure that resources fetched by cross origin CSS are not in the timeline.</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/common/get-host-info.sub.js"></script>
      7 <!--
      8  This test is mostly the same as no-entries-for-cross-origin-css-fetched.html
      9  but loads the sub-resources from another Document (<iframe>) earlier before
     10  they are loaded via cross-origin CSSs, so that the resources are loaded from
     11  cache and therefore no resource timing entries are created.
     12 -->
     13 
     14 <body>
     15  <script>
     16    const addLink = () => {
     17      return new Promise(resolve => {
     18        const link = document.createElement('LINK');
     19        link.rel = 'stylesheet';
     20        link.id = 'cross_origin_style';
     21        link.href = 'http://{{hosts[][www1]}}:{{ports[http][1]}}/resource-timing/resources/nested.css';
     22        link.addEventListener('load', resolve);
     23        document.body.appendChild(link);
     24      });
     25    }
     26 
     27    const addFrame = () => {
     28      return new Promise(resolve => {
     29        const iframe = document.createElement('iframe');
     30        iframe.src = 'resources/no-entries-for-cross-origin-css-fetched-memory-cache-iframe.sub.html';
     31        iframe.addEventListener('load', resolve);
     32        document.body.appendChild(iframe);
     33      });
     34    }
     35 
     36    promise_test(async t => {
     37      await addFrame();
     38      await addLink();
     39      // Assert no resource timing entries are created when the link is attached.
     40      const url = (new URL(document.getElementById('cross_origin_style').href));
     41      const prefix = url.protocol + '//' + url.host;
     42      assert_equals(performance.getEntriesByName(
     43        prefix + '/resource-timing/resources/resource_timing_test0.css?id=n1').length, 0,
     44        'Import should not be in timeline');
     45      assert_equals(performance.getEntriesByName(
     46        prefix + '/fonts/Ahem.ttf?id=n1').length, 0, 'Font should not be in timeline');
     47      assert_equals(performance.getEntriesByName(
     48        prefix + '/resource-timing/resources/blue.png?id=n1').length, 0,
     49        'Image should not be in timeline');
     50    }, 'Make sure that resources fetched by cross origin CSS are not in the timeline.');
     51  </script>
     52  <ol>Some content</ol>
     53 </body>