-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Uzlopak <[email protected]>
- Loading branch information
1 parent
4269dab
commit 608d5f6
Showing
55 changed files
with
1,489 additions
and
228 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
test/fixtures/wpt/common/dispatcher/remote-executor-worker.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,5 @@ | ||
importScripts('./dispatcher.js'); | ||
|
||
const params = new URLSearchParams(location.search); | ||
const uuid = params.get('uuid'); | ||
const executor = new Executor(uuid); // `execute()` is called in constructor. |
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
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}.`); |
Oops, something went wrong.