summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/workers/SharedWorker-detach-frame-in-error-event.html
blob: 7363265fbc3c42f498c78afda01a1cd51cb0aeac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<title>Test frame detach in shared worker's error handler</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<iframe id="frame"></iframe>
</body>
<script>
promise_test(t => {
  const frame = document.getElementById('frame');

  const promise = new Promise(resolve => {
    window.detachFrame = () => {
      frame.remove();
      resolve();
    };
  });

  // Start a new worker with an invalid script in the frame, and detach the
  // frame in the worker's error handler. This shouldn't crash.
  const s = frame.contentWindow.document.createElement('script');
  s.innerHTML = "const worker = new SharedWorker('error');" +
                "worker.onerror = () => { window.parent.detachFrame(); };";
  frame.contentWindow.document.body.appendChild(s);

  return promise;
});
</script>