tor-browser

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

identity-not-preserved.https.html (2014B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>SharedArrayBuffers, when cloned, do not give back the same object</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 <script src="/common/utils.js"></script>
      9 <script src="resources/test-sab.js"></script>
     10 
     11 <div id="log"></div>
     12 
     13 <script>
     14 "use strict";
     15 
     16 async_test(t => {
     17  const testId = token();
     18  const sab = new SharedArrayBuffer(1);
     19  window.addEventListener("message", t.step_func(({ data }) => {
     20    if (data.testId !== testId) {
     21      return;
     22    }
     23 
     24    assertSABsHaveSameBackingBlock(sab, data.sab);
     25 
     26    t.done();
     27  }));
     28 
     29  window.postMessage({ testId, sab }, "*");
     30 }, "postMessaging to this window does not give back the same SharedArrayBuffer (but does use the same backing block)");
     31 
     32 async_test(t => {
     33  const testId = token();
     34  const sab = new SharedArrayBuffer();
     35  const worker = new Worker("../resources/echo-worker.js");
     36 
     37  worker.addEventListener("message", t.step_func(({ data }) => {
     38    if (data.testId !== testId) {
     39      return;
     40    }
     41 
     42    assert_not_equals(data.sab, sab);
     43    t.done();
     44  }));
     45 
     46  worker.postMessage({ testId, sab });
     47 }, "postMessaging to a worker and back does not give back the same SharedArrayBuffer");
     48 
     49 async_test(t => {
     50  const testId = token();
     51  const sab = new SharedArrayBuffer();
     52  window.addEventListener("message", t.step_func(({ data }) => {
     53    if (data.testId !== testId) {
     54      return;
     55    }
     56 
     57    assert_not_equals(data.sab, sab);
     58    t.done();
     59  }));
     60 
     61  const iframe = document.createElement("iframe");
     62  iframe.onload = t.step_func(() => {
     63    iframe.contentWindow.postMessage({ testId, sab }, "*");
     64  });
     65  iframe.src = "../resources/echo-iframe.html";
     66  document.body.appendChild(iframe);
     67 }, "postMessaging to an iframe and back does not give back the same SharedArrayBuffer");
     68 </script>