summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/basic/keepalive.any.js
blob: 4f33284d0c74cbbdedb15ad1954722b5f1457531 (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
// META: global=window
// META: title=Fetch API: keepalive handling
// META: script=/resources/testharness.js
// META: script=/resources/testharnessreport.js
// META: script=/common/utils.js
// META: script=/common/get-host-info.sub.js
// META: script=../resources/keepalive-helper.js

'use strict';

const {
  HTTP_NOTSAMESITE_ORIGIN,
  HTTP_REMOTE_ORIGIN,
  HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT
} = get_host_info();

for (const method of ['GET', 'POST']) {
  promise_test(async (test) => {
    const token1 = token();
    const iframe = document.createElement('iframe');
    iframe.src = getKeepAliveIframeUrl(token1, method);
    document.body.appendChild(iframe);
    await iframeLoaded(iframe);
    assert_equals(await getTokenFromMessage(), token1);
    iframe.remove();

    assertStashedTokenAsync(`simple ${method} request: no payload`, token1);
  }, `simple ${method} request: no payload; setting up`);
}