tor-browser

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

third-party-cookies-cross-site-popup-opener.html (1838B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <meta name="timeout" content="long">
      4 <title>Window that opens a popup in a cross-site context</title>
      5 <script src="/resources/testdriver.js"></script>
      6 <script src="/resources/testdriver-vendor.js"></script>
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/common/get-host-info.sub.js"></script>
      9 <script src="/cookies/resources/cookie-helper.sub.js"></script>
     10 <script src="/cookies/third-party-cookies/resources/test-helpers.js"></script>
     11 
     12 <body>
     13  <script>
     14 
     15    let origin;
     16 
     17    // Test that parent window passed its origin in the URL parameters correctly.
     18    test(() => {
     19      assert_true(window.location.search.startsWith("?origin="));
     20      origin = decodeURIComponent(window.location.search.slice(
     21        window.location.search.indexOf("?origin=") + 8));
     22    }, "Cross-site window opened correctly");
     23 
     24    // Cookies set by the parent window in a 1P context.
     25    const cookieNames = ["1P_http", "1P_dom"];
     26    if (window.cookieStore) {
     27      cookieNames.push("1P_cs");
     28    }
     29 
     30    // Verify whether third-party cookies are blocked by default.
     31    if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) {
     32      assertThirdPartyHttpCookies({
     33        desc: "3P fetch",
     34        origin,
     35        cookieNames,
     36        expectsCookie: false,
     37      });
     38    } else {
     39      // Default behavior for third-party cookie blocking is flaky in Firefox.
     40      throw new AssertionError("Testing default third-party cookie blocking is not implemented in Firefox.");
     41    }
     42 
     43    // Open the cookies' origin in a popup to activate the heuristic.
     44    const popupUrl = new URL(
     45      "/cookies/third-party-cookies/resources/" +
     46      "third-party-cookies-cross-site-popup.html",
     47      origin);
     48    const popup = window.open(popupUrl);
     49 
     50    fetch_tests_from_window(popup);
     51 
     52  </script>
     53 </body>