tor-browser

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

none.https.html (3050B)


      1 <meta name="timeout" content="long">
      2 <title>Cross-Origin-Embedder-Policy header and nested navigable resource without such header</title>
      3 <script src=/resources/testharness.js></script>
      4 <script src=/resources/testharnessreport.js></script>
      5 <script src=/common/utils.js></script> <!-- Use token() to allow running tests in parallel -->
      6 <script src="/common/get-host-info.sub.js"></script>
      7 <div id=log></div>
      8 <script>
      9 
     10 const HOST = get_host_info();
     11 const BASE = new URL("resources", location).pathname;
     12 
     13 async_test(t => {
     14  const frame = document.createElement("iframe");
     15  t.add_cleanup(() => frame.remove());
     16  frame.onload = t.step_func_done(() => {
     17    assert_not_equals(frame.contentDocument, null);
     18  });
     19  frame.src = "/common/blank.html";
     20  document.body.append(frame);
     21  assert_equals(frame.contentDocument.body.localName, "body");
     22 }, `"none" top-level: navigating a frame to "none" should succeed`);
     23 
     24 async_test(t => {
     25  const frame = document.createElement("iframe");
     26  t.add_cleanup(() => frame.remove());
     27  const blank = "/common/blank.html";
     28  let firstNavOk = false;
     29  frame.onload = t.step_func(() => {
     30    if (!firstNavOk) {
     31      assert_not_equals(frame.contentDocument, null);
     32      firstNavOk = true;
     33    } else {
     34      assert_not_equals(frame.contentDocument, null);
     35      assert_equals(frame.contentWindow.location.pathname, blank);
     36      t.done();
     37    }
     38  });
     39  frame.src = `resources/navigate-require-corp.sub.html?to=${blank}`;
     40  document.body.append(frame);
     41  assert_equals(frame.contentDocument.body.localName, "body");
     42 }, `"none" top-level: navigating a frame from "require-corp" to "none" should succeed`);
     43 
     44 async_test(t => {
     45  let pageLoaded = false;
     46  // TODO(arthursonzogni): Consider switching toward another message passing
     47  // API like:
     48  // /common/dispatcher/dispatcher.js
     49  const bc = new BroadcastChannel(token());
     50  let finished = false;
     51  let doneCheck = _ => {
     52    if (finished && pageLoaded) {
     53      t.done();
     54    }
     55  }
     56  bc.onmessage = t.step_func((event) => {
     57    pageLoaded = true;
     58    let payload = event.data;
     59    assert_equals(payload, "loaded");
     60 
     61    doneCheck();
     62  });
     63 
     64  const bc2 = new BroadcastChannel(token());
     65  bc2.onmessage = t.step_func((event) => {
     66    finished = true;
     67    let payload = event.data;
     68    assert_equals(payload, "loaded");
     69 
     70    doneCheck();
     71  });
     72 
     73  const win = window.open(`resources/navigate-require-corp.sub.html?channelName=${bc.name}&to=navigate-none.sub.html?channelName=${bc2.name}`, "_blank", "noopener");
     74  assert_equals(win, null);
     75 }, `"require-corp" top-level noopener popup: navigating to "none" should succeed`);
     76 
     77 async_test(t => {
     78  const frame = document.createElement("iframe");
     79  const id = token();
     80  t.add_cleanup(() => frame.remove());
     81  window.addEventListener('message', t.step_func((e) => {
     82    if (e.data === id) {
     83      // Loaded!
     84      t.done();
     85    }
     86  }));
     87  frame.src = `${HOST.HTTPS_NOTSAMESITE_ORIGIN}${BASE}/navigate-require-corp-same-site.sub.html?token=${id}`;
     88  document.body.append(frame);
     89 }, 'CORP: same-site is not checked.');
     90 
     91 </script>