tor-browser

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

SharedWorker-detach-frame-in-error-event.html (870B)


      1 <!DOCTYPE html>
      2 <title>Test frame detach in shared worker's error handler</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <body>
      6 <iframe id="frame"></iframe>
      7 </body>
      8 <script>
      9 promise_test(t => {
     10  const frame = document.getElementById('frame');
     11 
     12  const promise = new Promise(resolve => {
     13    window.detachFrame = () => {
     14      frame.remove();
     15      resolve();
     16    };
     17  });
     18 
     19  // Start a new worker with an invalid script in the frame, and detach the
     20  // frame in the worker's error handler. This shouldn't crash.
     21  const s = frame.contentWindow.document.createElement('script');
     22  s.innerHTML = "const worker = new SharedWorker('error');" +
     23                "worker.onerror = () => { window.parent.detachFrame(); };";
     24  frame.contentWindow.document.body.appendChild(s);
     25 
     26  return promise;
     27 });
     28 </script>