Bug 1632233 [wpt PR 23176] - XHR: correct 303 redirect logic, a=testonly

Automatic update from web-platform-tests
XHR: correct 303 redirect logic

And add a relevant case for it.

--
expected results were wrong for some tests

--

wpt-commits: c814858d49abf943734fb28e0a13747ef875e49b, ad7bb0fa63d2e68646842a99b75a97270436e571
wpt-pr: 23176
This commit is contained in:
Anne van Kesteren 2020-04-28 11:41:20 +00:00 коммит произвёл moz-wptsync-bot
Родитель b48e9fc1f9
Коммит 3a09e5c40e
1 изменённых файлов: 14 добавлений и 13 удалений

Просмотреть файл

@ -24,20 +24,20 @@
function redirect(code, name = code, method = "GET", body = null, explicitType = null, safelistContentType = false) {
async_test(t => {
var client = new XMLHttpRequest()
let { body: expectedBody, type: expectedType } = extractBody(body);
if (explicitType !== null) {
expectedType = explicitType;
}
let expectedMethod = method;
if (((code === "301" || code === "302") && method === "POST") || (code === "303" && method !== "GET" && method !== "HEAD")) {
expectedMethod = "GET";
expectedBody = "";
expectedType = "NO";
}
const client = new XMLHttpRequest();
client.onreadystatechange = t.step_func(() => {
if (client.readyState === 4) {
if (explicitType !== "application/x-pony" || safelistContentType) {
let { body: expectedBody, type: expectedType } = extractBody(body);
if (explicitType !== null) {
expectedType = explicitType
}
let expectedMethod = method;
if (((code === "301" || code === "302") && method === "POST") || code === "303") {
expectedMethod = "GET";
expectedBody = "";
expectedType = "NO";
}
if ((expectedMethod === "GET" && expectedType === "NO") || explicitType !== "application/x-pony" || safelistContentType) {
assert_equals(client.status, 200);
assert_equals(client.getResponseHeader("x-request-method"), expectedMethod);
assert_equals(client.getResponseHeader("x-request-content-type"), expectedType);
@ -51,7 +51,7 @@
}
t.done();
}
})
});
let safelist = "";
if (safelistContentType) {
safelist = "?safelist_content_type";
@ -67,6 +67,7 @@
redirect("301")
redirect("301", "301 GET with explicit Content-Type", "GET", null, "application/x-pony")
redirect("301", "301 GET with explicit Content-Type safelisted", "GET", null, "application/x-pony", true)
redirect("303", "303 GET with explicit Content-Type safelisted", "GET", null, "application/x-pony", true)
redirect("302")
redirect("303")
redirect("302", "302 FOO with string and explicit Content-Type safelisted", "FOO", "test", "application/x-pony", true)