summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/response/response-clone-iframe.window.js
blob: da54616c376d9105b024d668846ea5dc1c1cb143 (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
29
30
31
32
// Verify that calling Response clone() in a detached iframe doesn't crash.
// Regression test for https://crbug.com/1082688.

'use strict';

promise_test(async () => {
  // Wait for the document body to be available.
  await new Promise(resolve => {
    onload = resolve;
  });

  window.iframe = document.createElement('iframe');
  document.body.appendChild(iframe);
  iframe.srcdoc = `<!doctype html>
<script>
const response = new Response('body');
window.parent.postMessage('okay', '*');
window.parent.iframe.remove();
response.clone();
</script>
`;

  await new Promise(resolve => {
    onmessage = evt => {
      if (evt.data === 'okay') {
        resolve();
      }
    };
  });

  // If it got here without crashing, the test passed.
}, 'clone within removed iframe should not crash');