Skip to content

Commit c973f6f

Browse files
mingycchromium-wpt-export-bot
authored andcommittedOct 23, 2023
[fetch-later] Update to match latest spec proposal [1]
This CL mainly: - Rename activationTimeout to activateAfter - Update FetchLaterManager::FetchLater() to follow the latest algorithm steps from [1] and [2]. - Update tests affected by rename - Expose FetchLaterResult to Window (spec also suggests Worker, which is not supported in implementation). [1]: https://whatpr.org/fetch/1647/9ca4bda...9994c1d.html#dictdef-deferredrequestinit [2]: https://whatpr.org/fetch/1647/9ca4bda...9994c1d.html#request-a-deferred-fetch Bug: 1465781 Change-Id: If79f3892bf8e693217f1b6e34ea3f23105e967d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4957580 Reviewed-by: Adam Rice <ricea@chromium.org> Commit-Queue: Ming-Ying Chung <mych@chromium.org> Cr-Commit-Position: refs/heads/main@{#1213364}
1 parent 0742941 commit c973f6f

4 files changed

+11
-12
lines changed
 

‎fetch/fetch-later/timeout.tentative.https.window.js ‎fetch/fetch-later/activate-after.tentative.https.window.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ parallelPromiseTest(async t => {
1515

1616
// Loads an iframe that creates a fetchLater request w/ short timeout.
1717
const iframe = await loadScriptAsIframe(`
18-
fetchLater("${url}", {activationTimeout: 1000}); // 1s
18+
fetchLater("${url}", {activateAfter: 1000}); // 1s
1919
`);
2020
// Deletes the iframe to trigger deferred request sending.
2121
document.body.removeChild(iframe);
2222

2323
// The iframe should have sent all requests.
2424
await expectBeacon(uuid, {count: 1});
25-
}, 'fetchLater() sends out based on activationTimeout.');
25+
}, 'fetchLater() sends out based on activateAfter.');
2626

2727
parallelPromiseTest(async t => {
2828
const uuid = token();
@@ -35,9 +35,8 @@ parallelPromiseTest(async t => {
3535

3636
// Creates a fetchLater request with short timeout. It should be sent out
3737
// even if the document is then put into BFCache.
38-
// only be sent on page discarded (not on entering BFCache).
3938
await rc1.executeScript(url => {
40-
fetchLater(url, {activationTimeout: 1000}); // 1.
39+
fetchLater(url, {activateAfter: 1000}); // 1s.
4140
// Add a pageshow listener to stash the BFCache event.
4241
window.addEventListener('pageshow', e => {
4342
window.pageshowEvent = e;
@@ -53,4 +52,4 @@ parallelPromiseTest(async t => {
5352
}));
5453

5554
await expectBeacon(uuid, {count: 1});
56-
}, 'fetchLater() sends out based on activationTimeout, even if document is in BFCache.');
55+
}, 'fetchLater() sends out based on activateAfter, even if document is in BFCache.');

‎fetch/fetch-later/basic.tentative.https.window.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ test(() => {
1919
test(() => {
2020
assert_throws_js(
2121
RangeError,
22-
() => fetchLater('https://www.google.com', {activationTimeout: -1}));
23-
}, `fetchLater() throws RangeError on negative activationTimeout.`);
22+
() => fetchLater('https://www.google.com', {activateAfter: -1}));
23+
}, `fetchLater() throws RangeError on negative activateAfter.`);
2424

2525
test(() => {
2626
const result = fetchLater('/');

‎fetch/fetch-later/send-on-deactivate.tentative.https.window.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ parallelPromiseTest(async t => {
4848
/*config=*/ null, /*options=*/ {features: 'noopener'});
4949

5050
// When the remote is BFCached, creates a fetchLater request w/
51-
// activationTimeout = 0s. It should be sent out immediately.
51+
// activateAfter = 0s. It should be sent out immediately.
5252
await rc1.executeScript(url => {
5353
window.addEventListener('pagehide', e => {
5454
if (e.persisted) {
55-
fetchLater(url, {activationTimeout: 0});
55+
fetchLater(url, {activateAfter: 0});
5656
}
5757
});
5858
// Add a pageshow listener to stash the BFCache event.
@@ -70,7 +70,7 @@ parallelPromiseTest(async t => {
7070
}));
7171

7272
await expectBeacon(uuid, {count: 1});
73-
}, `Call fetchLater() when BFCached with activationTimeout=0 sends immediately.`);
73+
}, `Call fetchLater() when BFCached with activateAfter=0 sends immediately.`);
7474

7575
parallelPromiseTest(async t => {
7676
const uuid = token();

‎fetch/fetch-later/send-on-discard.tentative.https.window.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ parallelPromiseTest(async t => {
3636
const iframe = await loadScriptAsIframe(`
3737
const url = "${url}";
3838
for (let i = 0; i < ${numPerMethod}; i++) {
39-
fetchLater(url, {method: 'GET', activationTimeout: 10000}); // 10s
40-
fetchLater(url, {method: 'POST', activationTimeout: 8000}); // 8s
39+
fetchLater(url, {method: 'GET', activateAfter: 10000}); // 10s
40+
fetchLater(url, {method: 'POST', activateAfter: 8000}); // 8s
4141
}
4242
`);
4343
// Delete the iframe to trigger deferred request sending.

0 commit comments

Comments
 (0)
Please sign in to comment.