-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af0eee2
commit 963246a
Showing
31 changed files
with
1,249 additions
and
177 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
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
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
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
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
5 changes: 3 additions & 2 deletions
5
test/fixtures/wpt/fetch/fetch-later/permissions-policy/resources/helper.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
134 changes: 0 additions & 134 deletions
134
test/fixtures/wpt/fetch/fetch-later/quota.tentative.https.window.js
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
# Quota Tests | ||
|
||
This folder contains tests to cover the `fetchLater()` API's | ||
per-reporting-origin quota. | ||
|
||
See the following links: | ||
|
||
- Initial Proposal: https://github.com/WICG/pending-beacon/issues/87#issuecomment-1985358609. | ||
- fetch PR: https://github.com/whatwg/fetch/pull/1647 | ||
- html PR: https://github.com/whatwg/html/pull/10903 |
63 changes: 63 additions & 0 deletions
63
...tures/wpt/fetch/fetch-later/quota/accumulated-oversized-payload.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,63 @@ | ||
// META: script=/common/get-host-info.sub.js | ||
// META: script=/common/utils.js | ||
// META: script=/fetch/fetch-later/resources/fetch-later-helper.js | ||
// META: script=/fetch/fetch-later/quota/resources/helper.js | ||
'use strict'; | ||
|
||
const {HTTPS_ORIGIN, HTTPS_NOTSAMESITE_ORIGIN} = get_host_info(); | ||
|
||
// Skips FormData & URLSearchParams, as browser adds extra bytes to them | ||
// in addition to the user-provided content. It is difficult to test a | ||
// request right at the quota limit. | ||
// Skips File & Blob as it's difficult to estimate what additional data are | ||
// added into them. | ||
const dataType = BeaconDataType.String; | ||
|
||
// Request headers are counted into total request size. | ||
const headers = new Headers({'Content-Type': 'text/plain;charset=UTF-8'}); | ||
|
||
const requestUrl = `${HTTPS_ORIGIN}/`; | ||
const quota = getRemainingQuota(QUOTA_PER_ORIGIN, requestUrl, headers); | ||
const halfQuota = Math.ceil(quota / 2); | ||
|
||
|
||
// Tests that a reporting origin only allow queuing requests within its quota. | ||
test( | ||
() => { | ||
const controller = new AbortController(); | ||
|
||
// Queues with the 1st call (POST) that sends max/2 quota. | ||
fetchLater(requestUrl, { | ||
method: 'POST', | ||
signal: controller.signal, | ||
body: makeBeaconData(generatePayload(halfQuota), dataType), | ||
// Required, as the size of referrer also take up quota. | ||
referrer: '', | ||
}); | ||
|
||
// Makes the 2nd call (POST) to the same reporting origin that sends | ||
// max bytes, which should be rejected. | ||
assert_throws_dom('QuotaExceededError', () => { | ||
fetchLater(requestUrl, { | ||
method: 'POST', | ||
signal: controller.signal, | ||
body: makeBeaconData(generatePayload(quota), dataType), | ||
// Required, as the size of referrer also take up quota. | ||
referrer: '', | ||
}); | ||
}); | ||
|
||
// Makes the 3rd call (GET) to the same reporting origin, where its | ||
// request size is len(requestUrl) + headers, which should be accepted. | ||
fetchLater(requestUrl, { | ||
method: 'GET', | ||
signal: controller.signal, | ||
// Required, as the size of referrer also take up quota. | ||
referrer: '', | ||
}); | ||
|
||
// Release quota taken by the pending requests for subsequent tests. | ||
controller.abort(); | ||
}, | ||
`The 2nd fetchLater(same-origin) call in the top-level document is not allowed to exceed per-origin quota for its POST body of ${ | ||
dataType}.`); |
9 changes: 9 additions & 0 deletions
9
test/fixtures/wpt/fetch/fetch-later/quota/cross-origin-iframe/README.md
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,9 @@ | ||
# Quota Tests for Cross-Origin iframes | ||
|
||
This folder contains tests to cover fetchLater() requests from cross-origin | ||
iframe. | ||
|
||
According to [spec], up to 16 cross-origin iframes can get a minimal quota (8kb) | ||
to make fetchLater() calls. | ||
|
||
[spec]: https://whatpr.org/fetch/1647.html#available-deferred-fetch-quota |
Oops, something went wrong.