Skip to content
Merged
Show file tree
Hide file tree
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*
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
Expand Up @@ -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) {
Expand Down
23 changes: 17 additions & 6 deletions test/fixtures/wpt/fetch/http-cache/http-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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) {
Expand All @@ -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()
})
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -225,6 +233,9 @@ function checkRequests (requests, testState) {
})
}
}
if (test?.check_count && testState) {
assert_equals(requests.length, testState.length);
}
}

function pause () {
Expand Down
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
Expand Up @@ -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()
})
}
Expand Down

This file was deleted.

Loading