Skip to content

Update WPT #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/fixtures/wpt/fetch/api/basic/WEB_FEATURES.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
features:
- name: fetch-request-streams
files:
- request-upload*
2 changes: 1 addition & 1 deletion test/fixtures/wpt/fetch/api/body/mime-type.any.js
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@

[
() => new Request("about:blank", { method: "POST", body: new Blob([""], { type: "Text/Plain" }), headers: [["Content-Type", "Text/Html"]] }),
() => new Response(new Blob([""], { type: "Text/Plain" }, { headers: [["Content-Type", "Text/Html"]] }))
() => new Response(new Blob([""], { type: "Text/Plain" }), { headers: [["Content-Type", "Text/Html"]] })
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
const cloned = bodyContainer.clone();
2 changes: 1 addition & 1 deletion test/fixtures/wpt/fetch/api/resources/keepalive-helper.js
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ function assertStashedTokenAsync(
*
* `unloadIframe` to unload the iframe before verifying stashed token to
* simulate the situation that unloads after fetching. Note that this test is
* different from `keepaliveRedirectInUnloadTest()` in that the the latter
* different from `keepaliveRedirectInUnloadTest()` in that the latter
* performs fetch() call directly in `unload` event handler, while this test
* does it in `load`.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
features:
- name: zstd
files: "**"
2 changes: 1 addition & 1 deletion test/fixtures/wpt/fetch/http-cache/README.md
Original file line number Diff line number Diff line change
@@ -62,11 +62,11 @@ Possible members of a request object:
- expected_response_headers - An array of `[header_name_string, header_value_string]` representing
headers to check the response for. See also response_headers.
- expected_response_text - A string to check the response body against. If not present, `response_body` will be checked if present and non-null; otherwise the response body will be checked for the test uuid (unless the status code disallows a body). Set to `null` to disable all response body checking.
- url_params - A string of url parameters that will be appended to the end of the url, separated by "&" and without leading "&".

Some headers in `response_headers` are treated specially:

* For date-carrying headers, if the value is a number, it will be interpreted as a delta to the time of the first request at the server.
* For URL-carrying headers, the value will be appended as a query parameter for `target`.

See the source for exact details.

27 changes: 25 additions & 2 deletions test/fixtures/wpt/fetch/http-cache/heuristic.any.js
Original file line number Diff line number Diff line change
@@ -32,10 +32,33 @@ var tests = [
],
},
{
expected_type: "not_cached"
expected_type: "not_cached",
}
]
}
},
{
name: "HTTP cache does not reuse a redirected response with no max-age and no Last-Modified header",
requests: [
{
response_status: [301, "Moved Permanently"],
response_headers: [
["Cache-Control", "private"],
["Location", "redirect_target"]
],
},
{ skip: true}, // Response to first redirect
{
response_status: [301, "Moved Permanently"],
response_headers: [
["Cache-Control", "private"],
["Location", "redirect_target"]
],
expected_type: "not_cached",
},
{ skip: true}, // response to second redirect
],
check_count: true,
},
];

function check_status(status) {
26 changes: 20 additions & 6 deletions test/fixtures/wpt/fetch/http-cache/http-cache.js
Original file line number Diff line number Diff line change
@@ -43,17 +43,25 @@ function makeTest (test) {
var uuid = token()
var requests = expandTemplates(test)
var fetchFunctions = makeFetchFunctions(requests, uuid)
return runTest(fetchFunctions, requests, uuid)
return runTest(fetchFunctions, test, requests, uuid)
}
}

function makeFetchFunctions(requests, uuid) {
var fetchFunctions = []
for (let i = 0; i < requests.length; ++i) {
var config = requests[i];
if (config.skip) {
// Skip request are ones that we expect the browser to make in
// response to a redirect. We don't fetch them again, but
// the server needs them in the config to be able to respond to
// them.
continue;
}
fetchFunctions.push({
code: function (idx) {
var config = requests[idx]
var url = makeTestUrl(uuid, config)
var url = makeTestUrl(uuid, config);
var init = fetchInit(requests, config)
return fetch(url, init)
.then(makeCheckResponse(idx, config))
@@ -71,7 +79,7 @@ function makeFetchFunctions(requests, uuid) {
return fetchFunctions
}

function runTest(fetchFunctions, requests, uuid) {
function runTest(fetchFunctions, test, requests, uuid) {
var idx = 0
function runNextStep () {
if (fetchFunctions.length) {
@@ -93,7 +101,7 @@ function runTest(fetchFunctions, requests, uuid) {
.then(function () {
return getServerState(uuid)
}).then(function (testState) {
checkRequests(requests, testState)
checkRequests(test, requests, testState)
return Promise.resolve()
})
}
@@ -153,7 +161,7 @@ function makeCheckResponse (idx, config) {
if ('expected_status' in config) {
assert_equals(response.status, config.expected_status,
`Response ${reqNum} status is ${response.status}, not ${config.expected_status}`)
} else if ('response_status' in config) {
} else if ('response_status' in config && config.response_status[0] != 301) {
assert_equals(response.status, config.response_status[0],
`Response ${reqNum} status is ${response.status}, not ${config.response_status[0]}`)
} else {
@@ -197,7 +205,7 @@ function makeCheckResponseBody (config, uuid) {
}
}

function checkRequests (requests, testState) {
function checkRequests (test, requests, testState) {
var testIdx = 0
for (let i = 0; i < requests.length; ++i) {
var expectedValidatingHeaders = []
@@ -225,6 +233,9 @@ function checkRequests (requests, testState) {
})
}
}
if (test?.check_count && testState) {
assert_equals(requests.length, testState.length);
}
}

function pause () {
@@ -244,6 +255,9 @@ function makeTestUrl (uuid, config) {
if ('query_arg' in config) {
arg = `&target=${config.query_arg}`
}
if ('url_params' in config) {
arg = `${arg}&${config.url_params}`
}
return `${base_url}resources/http-cache.py?dispatch=test&uuid=${uuid}${arg}`
}

91 changes: 91 additions & 0 deletions test/fixtures/wpt/fetch/http-cache/no-vary-search.tentative.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// META: global=window,worker
// META: title=NoVarySearch HTTP Cache
// META: timeout=long
// META: script=/common/utils.js
// META: script=/common/get-host-info.sub.js
// META: script=http-cache.js
/*
NOTE for testing No-Vary-Search-Header:
- If `params` is set to true, `expect=("dispatch" "uuid")` must be specified.
Otherwise:
- The same HTTP Cache will be used by other tests, which are supposed
to be distinguished by uuid.
- The test utility cannot get the server's states because UA will use the HTTP
Cache instead of sending a new request to server to ask for the latest state.
- Do not test not_cached cases and cached cases within one test. Test infra
checks the number of requests and responses without considering if the
previous responses should be served from cache or not.
*/
var tests = [
{
name: "When params is set to true, URL differs only by their parameters (other than `dispatch` and `uuid`) should not be cached as different entries.",
requests: [
{
url_params: "a=1&b=2",
response_headers: [
["Cache-Control", "max-age=10000"],
["No-Vary-Search", "params, except=(\"dispatch\" \"uuid\")"],
],
},
{
expected_type: "cached"
}
]
},
{
name: "Ground truth: When key-order is not set, URLs should be compared in an order-sensitive way.",
requests: [
{
url_params: "a=1&b=2",
response_headers: [
["Cache-Control", "max-age=10000"],
],
},
{
url_params: "b=2&a=1",
expected_type: "not_cached"
}
]
},
{
name: "When key-order is set , URLs should be compared in an order-insensitive way. Matched cases:",
requests: [
{
url_params: "a=1&b=2",
response_headers: [
["Cache-Control", "max-age=10000"],
["No-Vary-Search", "key-order"],
],
},
{
url_params: "b=2&a=1",
expected_type: "cached"
}
]
},
{
name: "When key-order is set , URLs should be compared in an order-insensitive way. Not matched cases",
requests: [
{
url_params: "a=1&b=2",
response_headers: [
["Cache-Control", "max-age=10000"],
["No-Vary-Search", "key-order"],
],
},
{
url_params: "b=2",
expected_type: "not_cached"
},
{
url_params: "a=2&b=2",
expected_type: "not_cached"
},
{
url_params: "a=1&b=2&c=3",
expected_type: "not_cached"
}
]
}
];
run_tests(tests);
2 changes: 1 addition & 1 deletion test/fixtures/wpt/fetch/http-cache/split-cache.html
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@
function check_server_info() {
return getServerState(uuid)
.then(function (testState) {
checkRequests(local_requests, testState)
checkRequests(undefined, local_requests, testState)
return Promise.resolve()
})
}
3 changes: 3 additions & 0 deletions test/fixtures/wpt/fetch/private-network-access/README.md
Original file line number Diff line number Diff line change
@@ -8,3 +8,6 @@ See also:
* [The specification](https://wicg.github.io/private-network-access/)
* [The repository](https://github.com/WICG/private-network-access/)
* [Open issues](https://github.com/WICG/private-network-access/issues/)

Private Network Access is deprecated and will eventually be replaced by [Local
Network Access](https://github.com/explainers-by-googlers/local-network-access).

This file was deleted.

Loading