Update web-platform-tests to revision 4a5223502fa660ce03e470af6a61c8bc26c5a8ee

This commit is contained in:
WPT Sync Bot 2018-04-23 21:13:37 -04:00
parent c5f7c9ccf3
commit e891345f26
1328 changed files with 36632 additions and 20588 deletions

View file

@ -57,7 +57,7 @@ for (const { args, testName } of badRequestArgTests) {
// Add signal to 2nd arg
args[1] = args[1] || {};
args[1].signal = controller.signal;
await promise_rejects(t, err, fetch(...args));
await promise_rejects(t, new TypeError, fetch(...args));
}
}, `TypeError from request constructor takes priority - ${testName}`);
}

View file

@ -0,0 +1,5 @@
promise_test(t => {
const mediaSource = new MediaSource(),
mediaSourceURL = URL.createObjectURL(mediaSource);
return promise_rejects(t, new TypeError(), fetch(mediaSourceURL));
}, "Cannot fetch blob: URL from a MediaSource");

View file

@ -1,34 +1,17 @@
// META: script=../resources/utils.js
function checkFetchResponse(url, method, desc) {
if (!desc) {
var cut = (url.length >= 40) ? "[...]" : "";
cut += " (" + method + ")"
desc = "Fetching " + url.substring(0, 40) + cut + " is OK"
}
function checkNetworkError(url, method) {
method = method || "GET";
const desc = "Fetching " + url.substring(0, 45) + " with method " + method + " is KO"
promise_test(function(test) {
return fetch(url, { method: method }).then(function(resp) {
assert_equals(resp.status, 200, "HTTP status is 200");
assert_equals(resp.type, "basic", "response type is basic");
assert_equals(resp.headers.get("Content-Type"), "text/html;charset=utf-8", "Content-Type is " + resp.headers.get("Content-Type"));
return resp.text();
})
}, desc);
}
checkFetchResponse("about:blank", "GET");
checkFetchResponse("about:blank", "PUT");
checkFetchResponse("about:blank", "POST");
function checkKoUrl(url, desc) {
if (!desc)
desc = "Fetching " + url.substring(0, 45) + " is KO"
promise_test(function(test) {
var promise = fetch(url);
var promise = fetch(url, { method: method });
return promise_rejects(test, new TypeError(), promise);
}, desc);
}
checkKoUrl("about:invalid.com");
checkKoUrl("about:config");
checkKoUrl("about:unicorn");
checkNetworkError("about:blank", "GET");
checkNetworkError("about:blank", "PUT");
checkNetworkError("about:blank", "POST");
checkNetworkError("about:invalid.com");
checkNetworkError("about:config");
checkNetworkError("about:unicorn");

View file

@ -56,9 +56,9 @@ for(let i = 0; i < 0x21; i++) {
promise_test((t) => {
if(fail) {
return Promise.all([
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val1": val1} })),
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val2": val2} })),
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val3": val3} }))
promise_rejects(t, new TypeError(), fetch(url, { headers: {"val1": val1} })),
promise_rejects(t, new TypeError(), fetch(url, { headers: {"val2": val2} })),
promise_rejects(t, new TypeError(), fetch(url, { headers: {"val3": val3} }))
])
} else {
return fetch(url, { headers: {"val1": val1, "val2": val2, "val3": val3} }).then((res) => {

View file

@ -15,7 +15,7 @@
assert_throws("SyntaxError", () => xhr.setRequestHeader("value-test", val))
}, "XMLHttpRequest with value " + encodeURI(val) + " needs to throw")
promise_test(t => promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"value-test": val} })), "fetch() with value " + encodeURI(val) + " needs to throw")
promise_test(t => promise_rejects(t, new TypeError(), fetch("/", { headers: {"value-test": val} })), "fetch() with value " + encodeURI(val) + " needs to throw")
})
// Valid values

View file

@ -3,15 +3,22 @@ if (this.document === undefined) {
importScripts("/common/get-host-info.sub.js")
}
function redirectMode(desc, redirectUrl, redirectLocation, redirectStatus, redirectMode) {
var url = redirectUrl;
var redirectLocation = "cors-top.txt";
function testRedirect(origin, redirectStatus, redirectMode, corsMode) {
var url = new URL("../resources/redirect.py", self.location);
if (origin === "cross-origin") {
url.host = get_host_info().REMOTE_HOST;
}
var urlParameters = "?redirect_status=" + redirectStatus;
urlParameters += "&location=" + encodeURIComponent(redirectLocation);
var requestInit = {"redirect": redirectMode};
var requestInit = {redirect: redirectMode, mode: corsMode};
promise_test(function(test) {
if (redirectMode === "error")
if (redirectMode === "error" ||
(corsMode === "no-cors" && redirectMode !== "follow" && origin !== "same-origin"))
return promise_rejects(test, new TypeError(), fetch(url + urlParameters, requestInit));
if (redirectMode === "manual")
return fetch(url + urlParameters, requestInit).then(function(resp) {
@ -22,20 +29,24 @@ function redirectMode(desc, redirectUrl, redirectLocation, redirectStatus, redir
});
if (redirectMode === "follow")
return fetch(url + urlParameters, requestInit).then(function(resp) {
assert_true(new URL(resp.url).pathname.endsWith(locationUrl), "Response's url should be the redirected one");
assert_equals(resp.status, 200, "Response's status is 200");
if (corsMode !== "no-cors" || origin === "same-origin") {
assert_true(new URL(resp.url).pathname.endsWith(redirectLocation), "Response's url should be the redirected one");
assert_equals(resp.status, 200, "Response's status is 200");
} else {
assert_equals(resp.type, "opaque", "Response is opaque");
}
});
assert_unreached(redirectMode + " is no a valid redirect mode");
}, desc);
}, origin + " redirect " + redirectStatus + " in " + redirectMode + " redirect and " + corsMode + " mode");
}
var redirUrl = get_host_info().HTTP_ORIGIN + "/fetch/api/resources/redirect.py";
var locationUrl = "top.txt";
for (var statusCode of [301, 302, 303, 307, 308]) {
redirectMode("Redirect " + statusCode + " in \"error\" mode ", redirUrl, locationUrl, statusCode, "error");
redirectMode("Redirect " + statusCode + " in \"follow\" mode ", redirUrl, locationUrl, statusCode, "follow");
redirectMode("Redirect " + statusCode + " in \"manual\" mode ", redirUrl, locationUrl, statusCode, "manual");
for (var origin of ["same-origin", "cross-origin"]) {
for (var statusCode of [301, 302, 303, 307, 308]) {
for (var redirect of ["error", "manual", "follow"]) {
for (var mode of ["cors", "no-cors"])
testRedirect(origin, statusCode, redirect, mode);
}
}
}
done();

View file

@ -9,7 +9,8 @@ let frame;
// Set up the service worker and the frame.
promise_test(t => {
const kScope = 'resources/empty.https.html';
const kScope = 'resources/';
const kFrame = 'resources/empty.https.html';
const kScript = 'resources/fetch-destination-worker-no-load-event.js';
return service_worker_unregister_and_register(t, kScript, kScope)
.then(registration => {
@ -20,7 +21,7 @@ promise_test(t => {
return wait_for_state(t, registration.installing, 'activated');
})
.then(() => {
return with_iframe(kScope);
return with_iframe(kFrame);
})
.then(f => {
frame = f;
@ -111,7 +112,6 @@ promise_test(async t => {
// style destination
/////////////////////
// @import - style destination
promise_test(async t => {
let node = frame.contentWindow.document.createElement("style");

View file

@ -2,11 +2,13 @@ self.addEventListener('fetch', function(event) {
if (event.request.url.includes('dummy')) {
event.waitUntil(async function() {
let destination = new URL(event.request.url).searchParams.get("dest");
let client = await self.clients.get(event.clientId);
var result = "FAIL";
if (event.request.destination == destination) {
client.postMessage("PASS");
} else {
client.postMessage("FAIL");
result = "PASS";
}
let cl = await clients.matchAll({includeUncontrolled: true});
for (i = 0; i < cl.length; i++) {
cl[i].postMessage(result);
}
}())
}

View file

@ -43,7 +43,7 @@
//not equals: cannot guess formData exact value
assert_true( bodyAsText.search(expectedTextBody) > -1, "Retrieve and verify request body");
});
}, "Initialize Request's body with " + bodyType);
}, `Initialize Request's body with "${body}", ${bodyType}`);
}
var blob = new Blob(["This is a blob"], {type: "application/octet-binary"});
@ -56,6 +56,7 @@
checkRequestInit(blob, "application/octet-binary", "This is a blob");
checkRequestInit(formaData, "multipart/form-data", "name=\"name\"\r\n\r\nvalue");
checkRequestInit(usvString, "text/plain;charset=UTF-8", "This is a USVString");
checkRequestInit({toString: () => "hi!"}, "text/plain;charset=UTF-8", "hi!");
// Ensure test does not time out in case of missing URLSearchParams support.
if (window.URLSearchParams) {

View file

@ -44,7 +44,7 @@
"referrer" : "about:client",
"referrerPolicy" : "",
"mode" : "cors",
"credentials" : "omit",
"credentials" : "same-origin",
"cache" : "default",
"redirect" : "follow",
"integrity" : "",

View file

@ -76,7 +76,7 @@
break;
case "credentials":
defaultValue = "omit";
defaultValue = "same-origin";
newValue = "cors";
break;

View file

@ -0,0 +1 @@
top

View file

@ -0,0 +1 @@
Access-Control-Allow-Origin: *