tor-browser

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

coop-navigated-popup.https.html (1735B)


      1 <!doctype html>
      2 <title>Cross-Origin-Opener-Policy: a navigated popup</title>
      3 <!-- In particular this is different from coep-navigate-popup.https.html as this document initiates
      4     the navigation (and uses same-origin-allow-popups and no COEP as without that it cannot be
      5     observed). COOP should work identically, but implementations might have used the wrong
      6     authority. -->
      7 <script src=/resources/testharness.js></script>
      8 <script src=/resources/testharnessreport.js></script>
      9 <script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->
     10 <script>
     11 async_test(t => {
     12  const noCOOP = "/common/blank.html";
     13  const popupName = token();
     14  const popup = window.open(noCOOP, popupName);
     15  const channel = new BroadcastChannel(token());
     16  // Close the popup once the test is complete.
     17  // The browsing context is closed after the navigation hence use the broadcast channel
     18  // to trigger the closure.
     19  t.add_cleanup(() => {
     20    channel.postMessage("close");
     21  });
     22  popup.onload = t.step_func(() => {
     23    assert_equals(popup.name, popupName);
     24    assert_equals(new URL(popup.document.URL).pathname, noCOOP);
     25    channel.onmessage = t.step_func_done(event => {
     26      const payload = event.data;
     27      // The name should be empty, but we're checking the length rather than a
     28      // string comparison to "" to keep the random token out of error messages.
     29      assert_equals(payload.name.length, 0);
     30      assert_false(payload.opener);
     31      assert_true(popup.closed);
     32    });
     33    const coop = `resources/coop-coep.py?coop=same-origin&coep=&channel=${channel.name}`;
     34    popup.location = coop;
     35  });
     36 }, "Open a popup to a document without COOP, then navigate it to a document with");
     37 </script>