tor-browser

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

window-domain-failure.https.sub.html (1901B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Structured cloning of SharedArrayBuffers into same-origin-domain windows</title>
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#structuredserialize">
      5 <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <body>
      9 <script>
     10 "use strict";
     11 document.domain = "{{host}}";
     12 
     13 async_test(t => {
     14  const iframe = document.createElement("iframe");
     15  t.add_cleanup(() => iframe.remove());
     16  iframe.src = "//{{domains[www1]}}:{{location[port]}}/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/iframe-domain-failure.sub.html";
     17  let domain;
     18  let childCrossOriginIsolated;
     19  window.onmessage = t.step_func((e) => {
     20    if (e.data.name === "domain") {
     21      domain = e.data.value;
     22      return;
     23    }
     24    if (e.data.name === "crossOriginIsolated") {
     25      childCrossOriginIsolated = e.data.value;
     26      return;
     27    }
     28    if (e.data.name === "hasSharedArrayBuffer") {
     29      const hasSharedArrayBuffer = e.data.value;
     30 
     31      // document.domain mutation is no-op because the surrounding agent
     32      // cluster's cross-origin isolated is true.
     33      assert_equals(domain, "{{domains[www1]}}");
     34 
     35      // crossOriginIsolated is false in the nested frame because the frame is
     36      // cross-origin and hence the cross-origin isolated capability is false.
     37      // We use assert_equals instead of assert_false here to see if
     38      // `childCrossOriginIsolated` is set.
     39      assert_equals(childCrossOriginIsolated, false);
     40 
     41      assert_false(hasSharedArrayBuffer);
     42      t.done();
     43      return;
     44    }
     45    assert_unreached("Got a message event, expected a messageerror event");
     46  });
     47  document.body.append(iframe);
     48 }, "SharedArrayBuffer and a same-origin-domain (but not same-origin) iframe");
     49 </script>