forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkeepalive.html
More file actions
31 lines (31 loc) · 1.01 KB
/
keepalive.html
File metadata and controls
31 lines (31 loc) · 1.01 KB
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
<!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>