Bug 1691099 [wpt PR 27512] - Reorganize and augment beacon wpt, a=testonly
[gecko.git] / testing / web-platform / tests / beacon / beacon-navigate.https.window.js
blob8b42a47cd9886af4e6b2a074ee8578295f4a3289
1 // META: timeout=long
2 // META: script=/common/utils.js
3 // META: script=/common/get-host-info.sub.js
4 // META: script=beacon-common.sub.js
6 'use strict';
8 const {HTTP_REMOTE_ORIGIN} = get_host_info();
10 for (const type of [STRING, ARRAYBUFFER, FORM, BLOB]) {
11   parallelPromiseTest(async (t) => {
12     const iframe = document.createElement('iframe');
13     document.body.appendChild(iframe);
14     t.add_cleanup(() => iframe.remove());
16     const payload = makePayload(SMALL, type);
17     const id = token();
18     const url = `/beacon/resources/beacon.py?cmd=store&id=${id}`;
19     assert_true(iframe.contentWindow.navigator.sendBeacon(url, payload));
21     iframe.src = `${HTTP_REMOTE_ORIGIN}/common/blank.html`;
22   }, `The frame navigates away after calling sendBeacon[type = ${type}].`);