Files
firefox/testing/web-platform/tests/fetch/api/basic/keepalive.any.js
T
Blink WPT Bot 2bd70d5047 Bug 1874526 [wpt PR 43984] - [wptrunner] Do not include testharness{,report}.js twice, a=testonly
Automatic update from web-platform-tests
[wptrunner] Do not include `testharness{,report}.js` twice (#43984)

Injecting `<script src="/resources/testharness{,report}.js">` is an
implicit behavior of `wptserve` for `.js` files [0].

Including `testharnessreport.js` twice for `content_shell` appears
benign, but causes issues for the default WebDriver testharness
implementation. Exporting this change will enable useful coverage for
such browsers.

A follow-up PR upstream will have `wpt lint` ban such duplicate scripts.

[0]: https://github.com/web-platform-tests/wpt/blob/9e0d5be/tools/serve/serve.py#L273-L451

Bug: 1518022
Change-Id: I7a6e344c82bbaa33adfa578feeb966fa92f08040
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5195267
Commit-Queue: Jonathan Lee <[email protected]>
Reviewed-by: Weizhong Xia <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1247652}

Co-authored-by: Jonathan Lee <[email protected]>
--

wpt-commits: f66439a5ca42e416c30740cb25a7a72f3dda6d54
wpt-pr: 43984
2024-01-20 10:35:41 +00:00

43 lines
1.2 KiB
JavaScript

// META: global=window
// META: timeout=long
// META: title=Fetch API: keepalive handling
// 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();
/**
* In a different-site iframe, test to fetch a keepalive URL on the specified
* document event.
*/
function keepaliveSimpleRequestTest(method) {
for (const evt of ['load', 'pagehide', 'unload']) {
const desc =
`[keepalive] simple ${method} request on '${evt}' [no payload]`;
promise_test(async (test) => {
const token1 = token();
const iframe = document.createElement('iframe');
iframe.src = getKeepAliveIframeUrl(token1, method, {sendOn: evt});
document.body.appendChild(iframe);
await iframeLoaded(iframe);
if (evt != 'load') {
iframe.remove();
}
assert_equals(await getTokenFromMessage(), token1);
assertStashedTokenAsync(desc, token1);
}, `${desc}; setting up`);
}
}
for (const method of ['GET', 'POST']) {
keepaliveSimpleRequestTest(method);
}