| <!doctype html> |
| <html> |
| <meta charset="utf-8"> |
| <title>Fetch API: keepalive handling</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/common/get-host-info.sub.js"></script> |
| <body> |
| <script> |
| const host_info = get_host_info(); |
| promise_test(async (test) => { |
| const iframe = document.createElement('iframe'); |
| iframe.src = host_info.HTTP_REMOTE_ORIGIN + |
| '/fetch/api/resources/keepalive-iframe.html'; |
| document.body.appendChild(iframe); |
| const uuid_promise = new Promise((resolve) => { |
| window.addEventListener('message', (event) => { |
| resolve(event.data); |
| }); |
| }); |
| await (new Promise((resolve) => iframe.addEventListener('load', resolve))); |
| const uuid = await uuid_promise; |
| iframe.remove(); |
| await (new Promise((resolve) => test.step_timeout(resolve, 1000))); |
| const response = await fetch(`../resources/stash-take.py?key=${uuid}`); |
| const json = await response.json(); |
| assert_equals(json, 'on'); |
| }); |
| </script> |
| </body> |
| </html> |