tor-browser

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

third-party-cookies-cross-site-embedder.html (1418B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8"/>
      3 <meta name="timeout" content="long">
      4 <title>Window embedding a cross-site embed</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/common/get-host-info.sub.js"></script>
      7 <script src="/cookies/resources/cookie-helper.sub.js"></script>
      8 <script src="/cookies/third-party-cookies/resources/test-helpers.js"></script>
      9 
     10 <body>
     11 <script>
     12 
     13 let origin;
     14 
     15 // Test that parent window passed its origin in the URL parameters correctly.
     16 test(() => {
     17  assert_true(window.location.search.startsWith("?origin="));
     18  origin = decodeURIComponent(window.location.search.slice(
     19      window.location.search.indexOf("?origin=") + 8));
     20 }, "Cross-site window opened correctly");
     21 
     22 // Cookies set by the parent window in a 1P context.
     23 const cookieNames = ["1P_http", "1P_dom"];
     24 if (window.cookieStore) {
     25  cookieNames.push("1P_cs");
     26 }
     27 
     28 // Third-party cookies are blocked by default.
     29 assertThirdPartyHttpCookies({
     30  desc: "3P fetch",
     31  origin,
     32  cookieNames,
     33  expectsCookie: false,
     34 });
     35 
     36 // Create a cross-site <iframe> which embeds the cookies' origin into this
     37 // page.
     38 const iframe = document.createElement("iframe");
     39 const url = new URL(
     40    "/cookies/third-party-cookies/resources/" +
     41        "third-party-cookies-cross-site-embed.html",
     42    origin);
     43 iframe.src = String(url);
     44 document.body.appendChild(iframe);
     45 
     46 fetch_tests_from_window(iframe.contentWindow);
     47 
     48 </script>
     49 </body>