tor-browser

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

resource-timing-cross-origin.https.html (2453B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <meta charset="utf-8" />
      5 <title>This test validates Resource Timing for cross origin content fetched by Service Worker from an originally same-origin URL.</title>
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="/common/get-host-info.sub.js"></script>
      9 <script src="resources/test-helpers.sub.js"></script>
     10 </head>
     11 
     12 <body>
     13 <script>
     14 function test_sw_resource_timing({ mode }) {
     15    promise_test(async t => {
     16      const worker_url = `resources/worker-fetching-cross-origin.js?mode=${mode}`;
     17      const scope = 'resources/iframe-with-image.html';
     18      const registration = await service_worker_unregister_and_register(t, worker_url, scope);
     19      await wait_for_state(t, registration.installing, 'activated');
     20      const frame = await with_iframe(scope);
     21      const frame_performance = frame.contentWindow.performance;
     22      // Check that there is one entry for which the timing allow check algorithm failed.
     23      const entries = frame_performance.getEntriesByType('resource');
     24      assert_equals(entries.length, 1);
     25      const entry = entries[0];
     26      assert_equals(entry.redirectStart, 0, 'redirectStart should be 0 in cross-origin request.');
     27      assert_equals(entry.redirectEnd, 0, 'redirectEnd should be 0 in cross-origin request.');
     28      assert_equals(entry.domainLookupStart, entry.fetchStart, 'domainLookupStart should be 0 in cross-origin request.');
     29      assert_equals(entry.domainLookupEnd, entry.fetchStart, 'domainLookupEnd should be 0 in cross-origin request.');
     30      assert_equals(entry.connectStart, entry.fetchStart, 'connectStart should be 0 in cross-origin request.');
     31      assert_equals(entry.connectEnd, entry.fetchStart, 'connectEnd should be 0 in cross-origin request.');
     32      assert_greater_than(entry.responseStart, entry.fetchStart, 'responseStart should be 0 in cross-origin request.');
     33      assert_equals(entry.secureConnectionStart, entry.fetchStart, 'secureConnectionStart should be 0 in cross-origin request.');
     34      assert_equals(entry.transferSize, 0, 'decodedBodySize should be 0 in cross-origin request.');
     35      frame.remove();
     36      await registration.unregister();
     37  }, `Test that timing allow check fails when service worker changes origin from same to cross origin (${mode}).`);
     38 }
     39 
     40 test_sw_resource_timing({ mode: "cors" });
     41 test_sw_resource_timing({ mode: "no-cors" });
     42 
     43 
     44 </script>
     45 </body>
     46 </html>