forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fetch-later] Implement basic FetchLater method
Add the basic algorithm steps from [FetchLater method][1], which mostly includes: - Checks abort signal - Checks request URL - Adds extra abort steps Subsequent CL will implement the missing steps: - Add quota checking steps from [Deferred fetch][2] https://crrev.com/c/4835437 - Add backgroundTimeout https://crrev.com/c/4803283 - throw TypeError for ReadableStream (TBD from spec discussion) [1]: https://whatpr.org/fetch/1647/53e4c3d...71fd383.html#fetch-later-method [2]: https://whatpr.org/fetch/1647/53e4c3d...71fd383.html#deferred-fetching Bug: 1465781 Change-Id: Ifc1a401ae000aa695dbdb3dc375557fac972b519 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4820528 Commit-Queue: Ming-Ying Chung <[email protected]> Reviewed-by: Nidhi Jaju <[email protected]> Cr-Commit-Position: refs/heads/main@{#1191973}
- Loading branch information
1 parent
4688de7
commit 068c242
Showing
3 changed files
with
69 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
fetch/fetch-later/send-on-discard.tentative.https.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// META: script=/resources/testharness.js | ||
// META: script=/resources/testharnessreport.js | ||
// META: script=/common/utils.js | ||
// META: script=/pending-beacon/resources/pending_beacon-helper.js | ||
|
||
'use strict'; | ||
|
||
parallelPromiseTest(async t => { | ||
const uuid = token(); | ||
const url = generateSetBeaconURL(uuid); | ||
const numPerMethod = 20; | ||
const total = numPerMethod * 2; | ||
|
||
// Loads an iframe that creates `numPerMethod` GET & POST fetchLater requests. | ||
const iframe = await loadScriptAsIframe(` | ||
const url = "${url}"; | ||
for (let i = 0; i < ${numPerMethod}; i++) { | ||
fetchLater(url); | ||
fetchLater(url, {method: 'POST'}); | ||
} | ||
`); | ||
// Delete the iframe to trigger deferred request sending. | ||
document.body.removeChild(iframe); | ||
|
||
// The iframe should have sent all requests. | ||
await expectBeacon(uuid, {count: total}); | ||
}, 'A discarded document sends all its fetchLater requests.'); | ||
|
||
parallelPromiseTest(async t => { | ||
const uuid = token(); | ||
const url = generateSetBeaconURL(uuid); | ||
|
||
// Loads an iframe that creates 2 fetchLater requests. One of them is aborted. | ||
const iframe = await loadScriptAsIframe(` | ||
const url = "${url}"; | ||
const controller = new AbortController(); | ||
fetchLater(url, {signal: controller.signal}); | ||
fetchLater(url, {method: 'POST'}); | ||
controller.abort(); | ||
`); | ||
// Delete the iframe to trigger deferred request sending. | ||
document.body.removeChild(iframe); | ||
|
||
// The iframe should not send the aborted request. | ||
await expectBeacon(uuid, {count: 1}); | ||
}, 'A discarded document does not send an already aborted fetchLater request.'); |
This file was deleted.
Oops, something went wrong.