Update web-platform-tests to revision 3b3585e368841b77caea8576fa56cef91c3fbdf0

This commit is contained in:
Ms2ger 2016-09-26 10:52:50 +02:00
parent d00639c55f
commit 3b4f0ec0bb
541 changed files with 14609 additions and 3288 deletions

View file

@ -11,4 +11,28 @@ promise_test(function() {
});
}, "Request through fetch should have 'accept' header with value '*/*'");
promise_test(function() {
return fetch(RESOURCES_DIR + "inspect-headers.py?headers=Accept", {"headers": [["Accept", "custom/*"]]}).then(function(response) {
assert_equals(response.status, 200, "HTTP status is 200");
assert_equals(response.type , "basic", "Response's type is basic");
assert_equals(response.headers.get("x-request-accept"), "custom/*", "Request has accept header with value 'custom/*'");
});
}, "Request through fetch should have 'accept' header with value 'custom/*'");
promise_test(function() {
return fetch(RESOURCES_DIR + "inspect-headers.py?headers=Accept-Language").then(function(response) {
assert_equals(response.status, 200, "HTTP status is 200");
assert_equals(response.type , "basic", "Response's type is basic");
assert_true(response.headers.has("x-request-accept-language"));
});
}, "Request through fetch should have a 'accept-language' header");
promise_test(function() {
return fetch(RESOURCES_DIR + "inspect-headers.py?headers=Accept-Language", {"headers": [["Accept-Language", "bzh"]]}).then(function(response) {
assert_equals(response.status, 200, "HTTP status is 200");
assert_equals(response.type , "basic", "Response's type is basic");
assert_equals(response.headers.get("x-request-accept-language"), "bzh", "Request has accept header with value 'bzh'");
});
}, "Request through fetch should have 'accept-language' header with value 'bzh'");
done();

View file

@ -5,12 +5,15 @@ if (this.document === undefined) {
importScripts("../resources/utils.js");
}
function corsPreflightReferrer(desc, corsUrl, referrerPolicy, expectedReferrer) {
function corsPreflightReferrer(desc, corsUrl, referrerPolicy, referrer, expectedReferrer) {
var uuid_token = token();
var url = corsUrl;
var urlParameters = "?token=" + uuid_token + "&max_age=0";
var requestInit = {"mode": "cors", "referrerPolicy": referrerPolicy};
if (referrer)
requestInit.referrer = referrer;
/* Force preflight */
requestInit["headers"] = {"x-force-preflight": ""};
urlParameters += "&allow_headers=x-force-preflight";
@ -23,19 +26,28 @@ function corsPreflightReferrer(desc, corsUrl, referrerPolicy, expectedReferrer)
assert_equals(resp.headers.get("x-did-preflight"), "1", "Preflight request has been made");
assert_equals(resp.headers.get("x-preflight-referrer"), expectedReferrer, "Preflight's referrer is correct");
assert_equals(resp.headers.get("x-referrer"), expectedReferrer, "Request's referrer is correct");
assert_equals(resp.headers.get("x-control-request-headers"), "", "Access-Control-Allow-Headers value");
});
});
}, desc);
}, desc + " and referrer: " + (referrer ? "'" + referrer + "'" : "default"));
}
var corsUrl = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "preflight.py";
var origin = get_host_info().HTTP_ORIGIN + "/";
corsPreflightReferrer("Referrer policy: no-referrer", corsUrl, "no-referrer", "");
corsPreflightReferrer("Referrer policy: \"\"", corsUrl, "", location.toString())
corsPreflightReferrer("Referrer policy: no-referrer", corsUrl, "no-referrer", undefined, "");
corsPreflightReferrer("Referrer policy: no-referrer", corsUrl, "no-referrer", "myreferrer", "");
corsPreflightReferrer("Referrer policy: origin", corsUrl, "origin", origin);
corsPreflightReferrer("Referrer policy: origin-when-cross-origin", corsUrl, "origin-when-cross-origin", origin);
corsPreflightReferrer("Referrer policy: unsafe-url", corsUrl, "unsafe-url", location.toString());
corsPreflightReferrer("Referrer policy: \"\"", corsUrl, "", undefined, location.toString())
corsPreflightReferrer("Referrer policy: \"\"", corsUrl, "", "myreferrer", new URL("myreferrer", location).toString());
corsPreflightReferrer("Referrer policy: origin", corsUrl, "origin", undefined, origin);
corsPreflightReferrer("Referrer policy: origin", corsUrl, "origin", "myreferrer", origin);
corsPreflightReferrer("Referrer policy: origin-when-cross-origin", corsUrl, "origin-when-cross-origin", undefined, origin);
corsPreflightReferrer("Referrer policy: origin-when-cross-origin", corsUrl, "origin-when-cross-origin", "myreferrer", origin);
corsPreflightReferrer("Referrer policy: unsafe-url", corsUrl, "unsafe-url", undefined, location.toString());
corsPreflightReferrer("Referrer policy: unsafe-url", corsUrl, "unsafe-url", "myreferrer", new URL("myreferrer", location).toString());
done();

View file

@ -52,7 +52,7 @@ function corsPreflight(desc, corsUrl, method, allowed, headers, safeHeaders) {
assert_in_array(header[0].toLowerCase(), actualHeaders, "Preflight asked permission for header: " + header);
let accessControlAllowHeaders = headerNames(headers).sort().join(",");
assert_equals(resp.headers.get("x-control-request-headers").replace(new RegExp(" ", "g"), ""), accessControlAllowHeaders, "Access-Control-Allow-Headers value");
assert_equals(resp.headers.get("x-control-request-headers"), accessControlAllowHeaders, "Access-Control-Allow-Headers value");
return fetch(RESOURCES_DIR + "clean-stash.py?token=" + uuid_token);
}
});

View file

@ -7,29 +7,24 @@ var dataURL = "data:text/plain;base64,cmVzcG9uc2UncyBib2R5";
var body = "response's body";
var contentType = "text/plain";
function redirectDataURL(desc, redirectUrl, mode, isOK) {
function redirectDataURL(desc, redirectUrl, mode) {
var url = redirectUrl + "?cors&location=" + encodeURIComponent(dataURL);
var requestInit = {"mode": mode};
promise_test(function(test) {
var promise = fetch(url, requestInit).then(function(response) {
assert_equals(response.type, "opaque", "Response's type should be opaque");
assert_equals(response.url, "", "Response URL is empty");
assert_equals(response.status, 0, "Response's status should be 0");
});
return isOK ? promise : promise_rejects(test, new TypeError(), promise);
return promise_rejects(test, new TypeError(), fetch(url, requestInit));
}, desc);
}
var redirUrl = get_host_info().HTTP_ORIGIN + "/fetch/api/resources/redirect.py";
var corsRedirUrl = get_host_info().HTTP_REMOTE_ORIGIN + "/fetch/api/resources/redirect.py";
redirectDataURL("Testing data URL loading after same-origin redirection (cors mode)", redirUrl, "cors", false);
redirectDataURL("Testing data URL loading after same-origin redirection (no-cors mode)", redirUrl, "no-cors", true);
redirectDataURL("Testing data URL loading after same-origin redirection (same-origin mode)", redirUrl, "same-origin", false);
redirectDataURL("Testing data URL loading after same-origin redirection (cors mode)", redirUrl, "cors");
redirectDataURL("Testing data URL loading after same-origin redirection (no-cors mode)", redirUrl, "no-cors");
redirectDataURL("Testing data URL loading after same-origin redirection (same-origin mode)", redirUrl, "same-origin");
redirectDataURL("Testing data URL loading after cross-origin redirection (cors mode)", corsRedirUrl, "cors", false);
redirectDataURL("Testing data URL loading after cross-origin redirection (no-cors mode)", corsRedirUrl, "no-cors", true);
redirectDataURL("Testing data URL loading after cross-origin redirection (cors mode)", corsRedirUrl, "cors");
redirectDataURL("Testing data URL loading after cross-origin redirection (no-cors mode)", corsRedirUrl, "no-cors");
done();