Update web-platform-tests to revision 58eb04cecbbec2e18531ab440225e38944a9c444

This commit is contained in:
Josh Matthews 2017-04-17 12:06:02 +10:00 committed by Anthony Ramine
parent 25e8bf69e6
commit 665817d2a6
35333 changed files with 1818077 additions and 16036 deletions

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: accept header</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#fetching">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("accept-header.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
promise_test(function() {
return fetch(RESOURCES_DIR + "inspect-headers.py?headers=Accept").then(function(response) {
@ -34,5 +31,3 @@ promise_test(function() {
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

@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: accept header</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#fetching">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="accept-header.js"></script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: same-origin mode</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#basic-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("mode-same-origin.js"));
</script>
</body>
</html>

View file

@ -1,8 +1,5 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js")
}
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function fetchSameOrigin(url, shouldPass) {
promise_test(function(test) {
@ -29,6 +26,3 @@ fetchSameOrigin(redirPath + RESOURCES_DIR + "top.txt", true);
fetchSameOrigin(redirPath + host_info.HTTP_ORIGIN + "/fetch/api/resources/top.txt", true);
fetchSameOrigin(redirPath + host_info.HTTPS_ORIGIN + "/fetch/api/resources/top.txt", false);
fetchSameOrigin(redirPath + host_info.HTTP_REMOTE_ORIGIN + "/fetch/api/resources/top.txt", false);
done();

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: same-origin mode</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#basic-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="mode-same-origin.js"></script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: same-origin mode</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#basic-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("referrer.js"));
</script>
</body>
</html>

View file

@ -1,8 +1,5 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js")
}
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function runTest(url, init, expectedReferrer, title) {
promise_test(function(test) {
@ -30,6 +27,3 @@ var referrerUrlWithCredentials = get_host_info().HTTP_ORIGIN.replace("http://",
runTest(fetchedUrl, {referrer: referrerUrlWithCredentials}, get_host_info().HTTP_ORIGIN + "/", "Referrer with credentials should be stripped");
var referrerUrlWithFragmentIdentifier = get_host_info().HTTP_ORIGIN + "#fragmentIdentifier";
runTest(fetchedUrl, {referrer: referrerUrlWithFragmentIdentifier}, get_host_info().HTTP_ORIGIN + "/", "Referrer with fragment ID should be stripped");
done();

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: same-origin mode</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#basic-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="referrer.js"></script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: forbidden request header management</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#forbidden-header-name">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("request-forbidden-headers.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function requestForbiddenHeaders(desc, forbiddenHeaders) {
var url = RESOURCES_DIR + "inspect-headers.py";
@ -43,6 +40,3 @@ requestForbiddenHeaders("Proxy- is a forbidden request header", {"Proxy-": "valu
requestForbiddenHeaders("Proxy-Test is a forbidden request header", {"Proxy-Test": "value"});
requestForbiddenHeaders("Sec- is a forbidden request header", {"Sec-": "value"});
requestForbiddenHeaders("Sec-Test is a forbidden request header", {"Sec-Test": "value"});
done();

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: forbidden request header management</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#forbidden-header-name">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="request-forbidden-headers.js"></script>
</body>
</html>

View file

@ -1,14 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: HEAD method</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("request-head.js"));
</script>
</body>
</html>

View file

@ -1,10 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
}
promise_test(function(test) {
var requestInit = {"method": "HEAD", "body": "test"};
return promise_rejects(test, new TypeError(), fetch(".", requestInit));
}, "Fetch with HEAD with body");
done();

View file

@ -1,12 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: HEAD method</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="request-head.js"></script>
</body>
</html>

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: User agent add headers to request</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("request-headers.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function checkContentType(contentType, body)
{
@ -82,5 +79,3 @@ requestOriginHeader("POST", "no-cors", true);
requestOriginHeader("PUT", "same-origin", true);
requestOriginHeader("TacO", "same-origin", true);
requestOriginHeader("TacO", "cors", true);
done();

View file

@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: User agent add headers to request</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="request-headers.js"></script>
</body>
</html>

View file

@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: referrer header</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
let finalURL = "/fetch/api/basic/request-referrer.any.worker.js";
let url = "/fetch/api/resources/redirect.py?location=" +
encodeURIComponent(finalURL);
fetch_tests_from_worker(new Worker(url));
</script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function testReferrer(referrer, expected) {
function testReferrer(referrer, expected, desc) {
promise_test(function(test) {
var url = RESOURCES_DIR + "inspect-headers.py?headers=referer"
var req = new Request(url, { referrer: referrer });
@ -17,12 +14,10 @@ function testReferrer(referrer, expected) {
assert_equals(actual, "", "request's referer should be empty");
}
});
});
}, desc);
}
testReferrer("about:client", window.location.href);
testReferrer("about:client", self.location.href, 'about:client referrer');
var fooURL = new URL("./foo", window.location).href;
testReferrer(fooURL, fooURL);
done();
var fooURL = new URL("./foo", self.location).href;
testReferrer(fooURL, fooURL, 'url referrer');

View file

@ -1,13 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: fetch() respects Request referrer value</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="request-referrer.js"></script>
</body>
</html>

View file

@ -0,0 +1,122 @@
// META: script=../resources/utils.js
function testUpload(desc, url, method, createBody, expectedBody) {
var requestInit = {"method": method}
promise_test(function(test){
let body = createBody();
if (body)
requestInit["body"] = body;
return fetch(url, requestInit).then(function(resp) {
return resp.text().then((text)=> {
assert_equals(text, expectedBody);
});
});
}, desc);
}
function testUploadFailure(desc, url, method, createBody) {
const requestInit = {"method": method};
promise_test(test => {
let body = createBody();
if (body)
requestInit["body"] = body;
return promise_rejects(new TypeError(), fetch(url, requestInit));
}, desc);
}
var url = RESOURCES_DIR + "echo-content.py"
testUpload("Fetch with PUT with body", url,
"PUT",
() => "Request's body",
"Request's body");
testUpload("Fetch with POST with text body", url,
"POST",
() => "Request's body",
"Request's body");
testUpload("Fetch with POST with URLSearchParams body", url,
"POST",
() => new URLSearchParams("name=value"),
"name=value");
testUpload("Fetch with POST with Blob body", url,
"POST",
() => new Blob(["Test"]),
"Test");
testUpload("Fetch with POST with ArrayBuffer body", url,
"POST",
() => new ArrayBuffer(4),
"\0\0\0\0");
testUpload("Fetch with POST with Uint8Array body", url,
"POST",
() => new Uint8Array(4),
"\0\0\0\0");
testUpload("Fetch with POST with Int8Array body", url,
"POST",
() => new Int8Array(4),
"\0\0\0\0");
testUpload("Fetch with POST with Float32Array body", url,
"POST",
() => new Float32Array(1),
"\0\0\0\0");
testUpload("Fetch with POST with Float64Array body", url,
"POST",
() => new Float64Array(1),
"\0\0\0\0\0\0\0\0");
testUpload("Fetch with POST with DataView body", url,
"POST",
() => new DataView(new ArrayBuffer(8), 0, 4),
"\0\0\0\0");
testUpload("Fetch with POST with Blob body with mime type", url,
"POST",
() => new Blob(["Test"], { type: "text/maybe" }),
"Test");
testUpload("Fetch with POST with ReadableStream", url,
"POST",
() => {
new ReadableStream({start: controller => {
const encoder = new TextEncoder();
controller.enqueue(encoder.encode("Test"));
controller.close();
}})
},
"Test");
testUploadFailure("Fetch with POST with ReadableStream containing String", url,
"POST",
() => {
new ReadableStream({start: controller => {
controller.enqueue("Test");
controller.close();
}})
});
testUploadFailure("Fetch with POST with ReadableStream containing null", url,
"POST",
() => {
new ReadableStream({start: controller => {
controller.enqueue(null);
controller.close();
}})
});
testUploadFailure("Fetch with POST with ReadableStream containing number", url,
"POST",
() => {
new ReadableStream({start: controller => {
controller.enqueue(99);
controller.close();
}})
});
testUploadFailure("Fetch with POST with ReadableStream containing ArrayBuffer", url,
"POST",
() => {
new ReadableStream({start: controller => {
controller.enqueue(new ArrayBuffer());
controller.close();
}})
});
testUploadFailure("Fetch with POST with ReadableStream containing Blob", url,
"POST",
() => {
new ReadableStream({start: controller => {
controller.enqueue(new Blob());
controller.close();
}})
});

View file

@ -1,71 +0,0 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
function testUpload(desc, url, method, body, expectedBody) {
var requestInit = {"method": method}
promise_test(function(test){
if (typeof body === "function")
body = body();
if (body)
requestInit["body"] = body;
return fetch(url, requestInit).then(function(resp) {
return resp.text().then((text)=> {
assert_equals(text, expectedBody);
});
});
}, desc);
}
function testUploadFailure(desc, url, method, body) {
const requestInit = {"method": method};
promise_test(test => {
if (typeof body === "function")
body = body();
if (body)
requestInit["body"] = body;
return promise_rejects(new TypeError(), fetch(url, requestInit));
}, desc);
}
var url = RESOURCES_DIR + "echo-content.py"
testUpload("Fetch with PUT with body", url, "PUT", "Request's body", "Request's body");
testUpload("Fetch with POST with text body", url, "POST", "Request's body", "Request's body");
testUpload("Fetch with POST with URLSearchParams body", url, "POST", function() { return new URLSearchParams("name=value"); }, "name=value");
testUpload("Fetch with POST with Blob body", url, "POST", new Blob(["Test"]), "Test");
testUpload("Fetch with POST with ArrayBuffer body", url, "POST", new ArrayBuffer(4), "\0\0\0\0");
testUpload("Fetch with POST with Uint8Array body", url, "POST", new Uint8Array(4), "\0\0\0\0");
testUpload("Fetch with POST with Int8Array body", url, "POST", new Int8Array(4), "\0\0\0\0");
testUpload("Fetch with POST with Float32Array body", url, "POST", new Float32Array(1), "\0\0\0\0");
testUpload("Fetch with POST with Float64Array body", url, "POST", new Float64Array(1), "\0\0\0\0\0\0\0\0");
testUpload("Fetch with POST with DataView body", url, "POST", new DataView(new ArrayBuffer(8), 0, 4), "\0\0\0\0");
testUpload("Fetch with POST with Blob body with mime type", url, "POST", new Blob(["Test"], { type: "text/maybe" }), "Test");
testUpload("Fetch with POST with ReadableStream", url, "POST", new ReadableStream({start: controller => {
const encoder = new TextEncoder();
controller.enqueue(encoder.encode("Test"));
controller.close();
}}), "Test");
testUploadFailure("Fetch with POST with ReadableStream containing String", url, "POST", new ReadableStream({start: controller => {
controller.enqueue("Test");
controller.close();
}}));
testUploadFailure("Fetch with POST with ReadableStream containing null", url, "POST", new ReadableStream({start: controller => {
controller.enqueue(null);
controller.close();
}}));
testUploadFailure("Fetch with POST with ReadableStream containing number", url, "POST", new ReadableStream({start: controller => {
controller.enqueue(99);
controller.close();
}}));
testUploadFailure("Fetch with POST with ReadableStream containing ArrayBuffer", url, "POST", new ReadableStream({start: controller => {
controller.enqueue(new ArrayBuffer());
controller.close();
}}));
testUploadFailure("Fetch with POST with ReadableStream containing Blob", url, "POST", new ReadableStream({start: controller => {
controller.enqueue(new Blob());
controller.close();
}}));
done();

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: about scheme</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#basic-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("scheme-about.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function checkFetchResponse(url, method, desc) {
if (!desc) {
@ -35,5 +32,3 @@ function checkKoUrl(url, desc) {
checkKoUrl("about:invalid.com");
checkKoUrl("about:config");
checkKoUrl("about:unicorn");
done();

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: about scheme</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#basic-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="scheme-about.js"></script>
</body>
</html>

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: data scheme</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#basic-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("scheme-data.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function checkFetchResponse(url, data, mime, fetchMode, method) {
var cut = (url.length >= 40) ? "[...]" : "";
@ -43,5 +40,3 @@ function checkKoUrl(url, method, desc) {
}
checkKoUrl("data:notAdataUrl.com", "GET");
done();

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: data scheme</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#basic-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="scheme-data.js"></script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function streamBody(reader, test, count) {
return reader.read().then(function(data) {
@ -29,5 +26,3 @@ promise_test(function(test) {
});
});
}, "Stream response's body");
done();

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: retrieve response's body progressively</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="stream-response.js"></script>
</body>
</html>

View file

@ -1,19 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: basic CORS</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-cors">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-cors-check">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-basic.js"));
</script>
</body>
</html>

View file

@ -1,8 +1,5 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js");
}
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function cors(desc, origin) {
var url = origin + dirname(location.pathname);
@ -38,5 +35,3 @@ cors("Same domain different protocol different port", host_info.HTTPS_ORIGIN);
cors("Cross domain basic usage", host_info.HTTP_REMOTE_ORIGIN);
cors("Cross domain different port", host_info.HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT);
cors("Cross domain different protocol", host_info.HTTPS_REMOTE_ORIGIN);
done();

View file

@ -1,19 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: basic CORS</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-cors">
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-cors-check">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-basic.js"></script>
</body>
</html>

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: cookies management for cors requests</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-cookies.js"));
</script>
</body>
</html>

View file

@ -1,8 +1,5 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js")
}
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function corsCookies(desc, baseURL1, baseURL2, credentialsMode, cookies) {
var urlSetCookie = baseURL1 + dirname(location.pathname) + RESOURCES_DIR + "top.txt";
@ -57,5 +54,3 @@ corsCookies("Include mode: local cookies are not sent with remote request", loca
corsCookies("Include mode: remote cookies are not sent with local request", remote, local, "include", ["d=4"]);
corsCookies("Same-origin mode: cookies are discarded in cors request", remote, remote, "same-origin", ["f=6"]);
corsCookies("Include mode: remote cookies are not sent with other remote request", remote, otherRemote, "include", ["e=5"]);
done();

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: cookies management for cors requests</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-cookies.js"></script>
</body>
</html>

View file

@ -2,13 +2,13 @@
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: Upload</title>
<title>Fetch in worker: Access-Control-Expose-Headers: *</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("request-upload.js"));
fetch_tests_from_worker(new Worker("cors-expose-star.js?pipe=sub"));
</script>
</body>
</html>

View file

@ -2,12 +2,12 @@
<html>
<head>
<meta charset="utf-8">
<title>Fetch: Uploading content</title>
<title>Fetch: Access-Control-Expose-Headers: *</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/utils.js"></script>
</head>
<body>
<script src="request-upload.js"></script>
<script src="../resources/utils.js"></script>
<script src="cors-expose-star.js?pipe=sub"></script>
</body>
</html>

View file

@ -0,0 +1,31 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
const url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "top.txt",
sharedHeaders = "?pipe=header(Access-Control-Expose-Headers,*)|header(Test,X)|header(Set-Cookie,X)|"
promise_test(() => {
const headers = "header(Access-Control-Allow-Origin,*)"
return fetch(url + sharedHeaders + headers).then(resp => {
assert_equals(resp.status, 200)
assert_equals(resp.type , "cors")
assert_equals(resp.headers.get("test"), "X")
assert_equals(resp.headers.get("set-cookie"), null)
})
}, "Basic Access-Control-Expose-Headers: * support")
promise_test(() => {
const origin = location.origin, // assuming an ASCII origin
headers = "header(Access-Control-Allow-Origin," + origin + ")|header(Access-Control-Allow-Credentials,true)"
return fetch(url + sharedHeaders + headers, { credentials:"include" }).then(resp => {
assert_equals(resp.status, 200)
assert_equals(resp.type , "cors")
assert_equals(resp.headers.get("content-type"), "text/plain") // safelisted
assert_equals(resp.headers.get("test"), null)
assert_equals(resp.headers.get("set-cookie"), null)
})
}, "Cannot use * for credentialed fetches")
done();

View file

@ -20,13 +20,17 @@ function corsFilter(corsUrl, headerName, headerValue, isFiltered) {
}, "CORS filter on " + headerName + " header");
}
function corsExposeFilter(corsUrl, headerName, headerValue, isForbidden) {
function corsExposeFilter(corsUrl, headerName, headerValue, isForbidden, withCredentials) {
var url = corsUrl + "?pipe=header(" + headerName + "," + encodeURIComponent(headerValue) +")|" +
"header(Access-Control-Allow-Origin,*)" +
"header(Access-Control-Allow-Origin, http://{{host}}:{{ports[http][0]}})" +
"header(Access-Control-Allow-Credentials, true)" +
"header(Access-Control-Expose-Headers," + headerName + ")";
var title = "CORS filter on " + headerName + " header, header is " + (isForbidden ? "forbidden" : "exposed");
if (withCredentials)
title+= "(credentials = include)";
promise_test(function(test) {
return fetch(url).then(function(resp) {
return fetch(new Request(url, { credentials: withCredentials ? "include" : "omit" })).then(function(resp) {
assert_equals(resp.status, 200, "Fetch success with code 200");
assert_equals(resp.type , "cors", "CORS fetch's response has cors type");
if (!isForbidden) {
@ -37,7 +41,7 @@ function corsExposeFilter(corsUrl, headerName, headerValue, isForbidden) {
}
test.done();
});
}, "CORS filter on " + headerName + " header, header is exposed");
}, title);
}
var url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "top.txt";
@ -60,7 +64,10 @@ corsExposeFilter(url, "Age", "27", false);
corsExposeFilter(url, "Server", "wptServe" , false);
corsExposeFilter(url, "Warning", "Mind the gap" , false);
corsExposeFilter(url, "Content-Length", "0" , false);
corsExposeFilter(url, "Set-Cookie", "name=value" , true);
corsExposeFilter(url, "Set-Cookie2", "name=value" , true);
corsExposeFilter(url, "Set-Cookie", "name=value" , true, true);
corsExposeFilter(url, "Set-Cookie2", "name=value" , true, true);
done();

View file

@ -1,20 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: CORS request with simple methods and headers</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#simple-method">
<meta name="help" href="https://fetch.spec.whatwg.org/#simple-header">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-no-preflight.js"));
</script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/common/utils.js");
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js")
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function corsNoPreflight(desc, baseURL, method, headerName, headerValue) {
@ -42,5 +39,3 @@ corsNoPreflight("Cross domain [GET] [Content-Type: multipart/form-data]", host_i
corsNoPreflight("Cross domain [GET] [Content-Type: text/plain]", host_info.HTTP_REMOTE_ORIGIN, "GET" , "Content-Type", "text/plain");
corsNoPreflight("Cross domain [GET] [Content-Type: text/plain;charset=utf-8]", host_info.HTTP_REMOTE_ORIGIN, "GET" , "Content-Type", "text/plain;charset=utf-8");
corsNoPreflight("Cross domain [GET] [Content-Type: Text/Plain;charset=utf-8]", host_info.HTTP_REMOTE_ORIGIN, "GET" , "Content-Type", "Text/Plain;charset=utf-8");
done();

View file

@ -1,21 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: CORS request with simple methods and headers</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#simple-method">
<meta name="help" href="https://fetch.spec.whatwg.org/#simple-header">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-no-preflight.js"></script>
</body>
</html>

View file

@ -1,19 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: check Access-Control-Allow-Origin header management</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#cors-check">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-origin.js"));
</script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/common/utils.js");
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js")
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
/* If origin is undefined, it is set to fetched url's origin*/
function corsOrigin(desc, baseURL, method, origin, shouldPass) {
@ -52,5 +49,3 @@ corsOrigin("Cross domain [HEAD] [origin KO]", host_info.HTTP_REMOTE_ORIGIN, "HEA
corsOrigin("CORS preflight [PUT] [origin OK]", host_info.HTTP_REMOTE_ORIGIN, "PUT", origin, true);
corsOrigin("CORS preflight [PUT] [origin KO]", host_info.HTTP_REMOTE_ORIGIN, "PUT", undefined, false);
corsOrigin("Allowed origin: \"\" [origin KO]", host_info.HTTP_REMOTE_ORIGIN, "GET", "" , false);
done();

View file

@ -1,20 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: check Access-Control-Allow-Origin header management</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#cors-check">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-origin.js"></script>
</body>
</html>

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: redirection handling for cors with preflight</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-preflight-redirect.js"));
</script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/utils.js");
importScripts("/common/get-host-info.sub.js");
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function corsPreflightRedirect(desc, redirectUrl, redirectLocation, redirectStatus, redirectPreflight) {
var uuid_token = token();
@ -37,5 +34,3 @@ for (var code of [301, 302, 303, 307, 308]) {
/* preflight is done before redirection: preflight force redirect to error */
corsPreflightRedirect("Redirection " + code + " after preflight failed", redirectUrl, locationUrl, code, false);
}
done();

View file

@ -1,19 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: redirection handling for cors with preflight</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-preflight-redirect.js"></script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("/common/utils.js");
importScripts("/common/get-host-info.sub.js");
importScripts("../resources/utils.js");
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function corsPreflightReferrer(desc, corsUrl, referrerPolicy, referrer, expectedReferrer) {
var uuid_token = token();
@ -49,5 +46,3 @@ corsPreflightReferrer("Referrer policy: origin-when-cross-origin", corsUrl, "ori
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

@ -1,19 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: Referer header management in CORS request with preflight</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#cors-preflight-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-preflight-referrer.js"></script>
</body>
</html>

View file

@ -0,0 +1,42 @@
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
const url = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "preflight.py",
origin = location.origin // assuming an ASCII origin
function preflightTest(succeeds, withCredentials, allowMethod, allowHeader, useMethod, useHeader) {
return promise_test(t => {
let testURL = url + "?",
requestInit = {}
if (withCredentials) {
testURL += "origin=" + origin + "&"
testURL += "credentials&"
requestInit.credentials = "include"
}
if (useMethod) {
requestInit.method = useMethod
}
if (useHeader) {
requestInit.headers = [useHeader]
}
testURL += "allow_methods=" + allowMethod + "&"
testURL += "allow_headers=" + allowHeader + "&"
if (succeeds) {
return fetch(testURL, requestInit).then(resp => {
assert_equals(resp.headers.get("x-origin"), origin)
})
} else {
return promise_rejects(t, new TypeError(), fetch(testURL, requestInit))
}
}, "CORS that " + (succeeds ? "succeeds" : "fails") + " with credentials: " + withCredentials + "; method: " + useMethod + " (allowed: " + allowMethod + "); header: " + useHeader + " (allowed: " + allowHeader + ")")
}
preflightTest(true, false, "get", "x-test", "GET", ["X-Test", "1"])
preflightTest(true, false, "*", "x-test", "SUPER", ["X-Test", "1"])
preflightTest(true, false, "*", "*", "OK", ["X-Test", "1"])
preflightTest(false, true, "*", "*", "OK", ["X-Test", "1"])
preflightTest(false, true, "*", "", "PUT", undefined)
preflightTest(false, true, "put", "*", "PUT", undefined)
preflightTest(false, true, "get", "*", "GET", ["X-Test", "1"])
preflightTest(false, true, "*", "*", "GET", ["X-Test", "1"])

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/utils.js");
importScripts("/common/get-host-info.sub.js");
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
/* Check preflight is ok if status is ok status (200 to 299)*/
function corsPreflightStatus(desc, corsUrl, preflightStatus) {
@ -18,7 +15,7 @@ function corsPreflightStatus(desc, corsUrl, preflightStatus) {
urlParameters += "&preflight_status=" + preflightStatus;
promise_test(function(test) {
fetch(RESOURCES_DIR + "clean-stash.py?token=" + uuid_token).then(function(resp) {
return fetch(RESOURCES_DIR + "clean-stash.py?token=" + uuid_token).then(function(resp) {
assert_equals(resp.status, 200, "Clean stash response's status is 200");
if (200 <= preflightStatus && 299 >= preflightStatus) {
return fetch(url + urlParameters, requestInit).then(function(resp) {
@ -38,5 +35,3 @@ for (status of [200, 201, 202, 203, 204, 205, 206,
400, 401, 402, 403, 404, 405,
501, 502, 503, 504, 505])
corsPreflightStatus("Preflight answered with status " + status, corsUrl, status);
done();

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: preflight status code handling</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#cors-preflight-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-preflight-status.js"></script>
</body>
</html>

View file

@ -1,20 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: Check cors fetches requiring prefligh</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#simple-method">
<meta name="help" href="https://fetch.spec.whatwg.org/#simple-header">
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-preflight.js"));
</script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("/common/utils.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js");
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function headerNames(headers)
{
@ -99,4 +96,4 @@ corsPreflight("CORS [GET] [several headers], server refuses", corsUrl, "GET", fa
corsPreflight("CORS [PUT] [several headers], server allows", corsUrl, "PUT", true, headers, safeHeaders);
corsPreflight("CORS [PUT] [several headers], server refuses", corsUrl, "PUT", false, headers, safeHeaders);
done();
corsPreflight("CORS [PUT] [only safe headers], server allows", corsUrl, "PUT", true, null, safeHeaders);

View file

@ -1,21 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: Check cors fetches requiring preflight</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-cors-protocol">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#simple-method">
<meta name="help" href="https://fetch.spec.whatwg.org/#simple-header">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/utils.js"></script>
<script src="cors-preflight.js"></script>
</body>
</html>

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: redirection url has credentials</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-redirect-credentials.js"));
</script>
</body>
</html>

View file

@ -1,19 +1,20 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js")
}
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function corsRedirectCredentials(desc, redirectUrl, redirectLocation, redirectStatus, locationCredentials) {
var url = redirectUrl
var urlParameters = "?redirect_status=" + redirectStatus;
urlParameters += "&location=" + encodeURIComponent(redirectLocation.replace("://", "://" + locationCredentials + "@"));
urlParameters += "&location=" + redirectLocation.replace("://", "://" + locationCredentials + "@");
var requestInit = {"mode": "cors", "redirect": "follow", "credentials":"include"};
var requestInit = {"mode": "cors", "redirect": "follow"};
promise_test(function(test) {
return promise_rejects(test, new TypeError(), fetch(url + urlParameters, requestInit));
promise_test(t => {
const result = fetch(url + urlParameters, requestInit)
if(locationCredentials === "") {
return result;
} else {
return promise_rejects(t, new TypeError(), result);
}
}, desc);
}
@ -30,6 +31,8 @@ var remoteLocation = host_info.HTTP_ORIGIN_WITH_DIFFERENT_PORT + preflightPath;
var remoteLocation2 = host_info.HTTP_REMOTE_ORIGIN + preflightPath;
for (var code of [301, 302, 303, 307, 308]) {
corsRedirectCredentials("Redirect " + code + " from same origin to remote without user and password", localRedirect, remoteLocation, code, "");
corsRedirectCredentials("Redirect " + code + " from same origin to remote with user and password", localRedirect, remoteLocation, code, "user:password");
corsRedirectCredentials("Redirect " + code + " from same origin to remote with user", localRedirect, remoteLocation, code, "user:");
corsRedirectCredentials("Redirect " + code + " from same origin to remote with password", localRedirect, remoteLocation, code, ":password");
@ -46,5 +49,3 @@ for (var code of [301, 302, 303, 307, 308]) {
corsRedirectCredentials("Redirect " + code + " from remote to another remote with user", remoteRedirect, remoteLocation2, code, "user:");
corsRedirectCredentials("Redirect " + code + " from remote to another remote with password", remoteRedirect, remoteLocation2, code, ":password");
}
done();

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: redirection url has credentials</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-redirect-credentials.js"></script>
</body>
</html>

View file

@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: CORS preflight after redirection</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#http-redirect-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-redirect-preflight.js"));
</script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("/common/utils.js");
importScripts("/common/get-host-info.sub.js");
importScripts("../resources/utils.js");
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function corsRedirect(desc, redirectUrl, redirectLocation, redirectStatus, expectSuccess) {
var urlBaseParameters = "&redirect_status=" + redirectStatus;
@ -46,5 +43,3 @@ for (var code of [301, 302, 303, 307, 308]) {
corsRedirect("Redirect " + code + ": cors to same origin", remoteRedirect, localLocation, code);
corsRedirect("Redirect " + code + ": cors to another cors", remoteRedirect, remoteLocation2, code);
}
done();

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: CORS preflight after redirection</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#http-redirect-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../resources/utils.js"></script>
<script src="cors-redirect-preflight.js"></script>
</body>
</html>

View file

@ -1,9 +1,6 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("/common/utils.js");
importScripts("../resources/utils.js");
importScripts("/common/get-host-info.sub.js");
}
// META: script=/common/utils.js
// META: script=../resources/utils.js
// META: script=/common/get-host-info.sub.js
function corsRedirect(desc, redirectUrl, redirectLocation, redirectStatus, expectedOrigin) {
var uuid_token = token();
@ -43,5 +40,3 @@ for (var code of [301, 302, 303, 307, 308]) {
corsRedirect("Redirect " + code + ": same origin to cors", localRedirect, remoteLocation, code, location.origin);
corsRedirect("Redirect " + code + ": cors to same origin", remoteRedirect, localLocation, code, "null");
}
done();

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: CORS Redirection with several origins</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="/common/utils.js"></script>
<script src="../resources/utils.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="cors-redirect.js"></script>
</body>
</html>

View file

@ -1,16 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: Authorisation header management for basic authentication</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("authentication-basic.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function basicAuth(desc, user, pass, mode, status) {
promise_test(function(test) {
@ -17,5 +14,3 @@ function basicAuth(desc, user, pass, mode, status) {
basicAuth("User-added Authorization header with include mode", "user", "password", "include", 200);
basicAuth("User-added Authorization header with same-origin mode", "user", "password", "same-origin", 200);
basicAuth("User-added Authorization header with omit mode", "user", "password", "omit", 200);
done();

View file

@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: Authorisation header management for basic authentication</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="authentication-basic.js"></script>
</body>
</html>

View file

@ -1,18 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: cookies management</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cookies.js"));
</script>
</body>
</html>

View file

@ -1,7 +1,4 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
}
// META: script=../resources/utils.js
function cookies(desc, credentials1, credentials2 ,cookies) {
var url = RESOURCES_DIR + "top.txt"
@ -49,5 +46,3 @@ cookies("Omit mode: no cookie is stored", "omit", "include", ["e=5"]);
cookies("Omit mode: no cookie is sent", "include", "omit", ["f=6"]);
cookies("Same-origin mode: 1 cookie", "same-origin", "same-origin", ["a=1"]);
cookies("Same-origin mode: 2 cookies", "same-origin", "same-origin", ["b=2", "c=3"]);
done();

View file

@ -1,17 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: cookies management</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script src="../resources/utils.js"></script>
<script src="cookies.js"></script>
</body>
</html>

View file

@ -18,15 +18,14 @@
["triple", "tripleValue3"]
];
var expectedDict = {"single": "singleValue",
"double": "doubleValue1,doubleValue2",
"triple": "tripleValue1,tripleValue2,tripleValue3"
"double": "doubleValue1, doubleValue2",
"triple": "tripleValue1, tripleValue2, tripleValue3"
};
test(function() {
var headers = new Headers(headerSeqCombine);
for (name in expectedDict)
assert_equals(headers.get(name), expectedDict[name],
"name: " + name + " has value: " + expectedDict[name]);
assert_equals(headers.get(name), expectedDict[name]);
}, "Create headers using same name for different values");
test(function() {
@ -51,8 +50,7 @@
for (name in expectedDict) {
var value = headers.get(name);
headers.append(name,"newSingleValue");
assert_equals(headers.get(name), (value + "," + "newSingleValue"),
"name: " + name + " has value: " + headers.get(name));
assert_equals(headers.get(name), (value + ", " + "newSingleValue"));
}
}, "Check append methods when called with already used name");
</script>

View file

@ -0,0 +1,4 @@
test(() => {
assert_false("getAll" in new Headers)
assert_false("getAll" in Headers.prototype)
}, "Headers object no longer has a getAll() method")

View file

@ -0,0 +1 @@
// empty, but referrer-policy set on this file

View file

@ -0,0 +1 @@
Referrer-Policy: no-referrer

View file

@ -2,17 +2,17 @@
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: Referer header management in CORS request with preflight</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#cors-preflight-fetch">
<title>Fetch in service worker: referrer with no-referrer policy</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-preflight-referrer.js"));
service_worker_test("referrer-no-referrer.js?pipe=sub");
</script>
</body>
</html>

View file

@ -2,16 +2,17 @@
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: CORS Redirection with several origins</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<title>Fetch in service worker: referrer with no-referrer policy</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-redirect.js"));
service_worker_test("referrer-origin.js?pipe=sub");
</script>
</body>
</html>

View file

@ -2,16 +2,16 @@
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: retrieve response's body progressively</title>
<title>Fetch in service worker: referrer with origin-when-cross-origin policy</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("stream-response.js"));
service_worker_test("referrer-origin-when-cross-origin.js?pipe=sub");
</script>
</body>
</html>
</html>

View file

@ -1,10 +1,14 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
// A nested importScripts() with a referrer-policy should have no effect
// on overall worker policy.
importScripts("nested-policy.js");
}
var referrerOrigin = "http://{{host}}:{{ports[http][0]}}/";
var fetchedUrl = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?cors&headers=referer";
var referrerOrigin = location.origin + '/';
var fetchedUrl = "https://{{domains[www]}}:{{ports[https][0]}}" + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?cors&headers=referer";
promise_test(function(test) {
return fetch(fetchedUrl).then(function(resp) {

View file

@ -13,4 +13,4 @@
<script src="../resources/utils.js"></script>
<script src="referrer-origin.js?pipe=sub"></script>
</body>
</html>
</html>

View file

@ -1,9 +1,13 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
// A nested importScripts() with a referrer-policy should have no effect
// on overall worker policy.
importScripts("nested-policy.js");
}
var referrerOrigin = "http://{{host}}:{{ports[http][0]}}/";
var referrerOrigin = (new URL("/", location.href)).href;
var fetchedUrl = RESOURCES_DIR + "inspect-headers.py?headers=referer";
promise_test(function(test) {
@ -15,7 +19,7 @@ promise_test(function(test) {
}, "Request's referrer is origin");
promise_test(function(test) {
var referrerUrl = "http://{{domains[www]}}:{{ports[http][0]}}/";
var referrerUrl = "https://{{domains[www]}}:{{ports[https][0]}}/";
return fetch(fetchedUrl, { "referrer": referrerUrl }).then(function(resp) {
assert_equals(resp.status, 200, "HTTP status is 200");
assert_equals(resp.type , "basic", "Response's type is basic");

View file

@ -2,17 +2,17 @@
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: preflight status code handling</title>
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<meta name="help" href="https://fetch.spec.whatwg.org/#cors-preflight-fetch">
<title>Fetch in worker: referrer with unsafe-url policy</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
<meta name="help" href="https://fetch.spec.whatwg.org/#http-network-or-cache-fetch">
<meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
</head>
<body>
<script>
fetch_tests_from_worker(new Worker("cors-preflight-status.js"));
service_worker_test("referrer-unsafe-url.js?pipe=sub");
</script>
</body>
</html>

View file

@ -1,6 +1,10 @@
if (this.document === undefined) {
importScripts("/resources/testharness.js");
importScripts("../resources/utils.js");
// A nested importScripts() with a referrer-policy should have no effect
// on overall worker policy.
importScripts("nested-policy.js");
}
var referrerUrl = location.href;

View file

@ -14,7 +14,7 @@ function redirectLocation(desc, redirectUrl, redirectLocation, redirectStatus, r
promise_test(function(test) {
if (redirectMode === "error" || !shouldPass)
return promise_rejects(test, new TypeError(), fetch(url + urlParameters, requestInit));
if (redirectLocation && redirectMode === "manual")
if (redirectMode === "manual")
return fetch(url + urlParameters, requestInit).then(function(resp) {
assert_equals(resp.status, 0, "Response's status is 0");
assert_equals(resp.type, "opaqueredirect", "Response's type is opaqueredirect");
@ -22,7 +22,7 @@ function redirectLocation(desc, redirectUrl, redirectLocation, redirectStatus, r
assert_true(resp.headers.entries().next().done, "Headers should be empty");
});
if (redirectMode === "manual" || redirectMode === "follow")
if (redirectMode === "follow")
return fetch(url + urlParameters, requestInit).then(function(resp) {
assert_equals(resp.status, redirectStatus, "Response's status is " + redirectStatus);
});

View file

@ -218,6 +218,6 @@ function run_tests(tests)
{
tests.forEach(function(info) {
promise_test(make_test("tag", info), info.name + " with Etag and " + info.state + " response");
promise_test(make_test("date", info), info.name + " with date and " + info.state + " response");
promise_test(make_test("date", info), info.name + " with Last-Modified and " + info.state + " response");
});
}

View file

@ -41,7 +41,7 @@
var expectedDefault = {"method" : "GET",
"url" : location.href,
"referrer" : "http://{{host}}:{{ports[http][0]}}/",
"referrer" : "about:client",
"referrerPolicy" : "",
"mode" : "cors",
"credentials" : "omit",

View file

@ -0,0 +1,93 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Request Keepalive Quota Tests</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#request">
<meta name="help" href="https://fetch.spec.whatwg.org/#body-mixin">
<meta name="author" title="Microsoft Edge" href="https://www.microsoft.com">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
"use strict";
// We want to ensure that our keepalive requests hang slightly before completing so we can validate
// the effects of a rolling quota. To do this we will utilize trickle.py with a 1s delay. This should
// prevent any of the Fetch's from finishing in this window.
var trickleURL = "../resources/trickle.py?count=1&ms=";
var standardDelay = 1000;
// We should expect 64KiB of rolling quota for any type of keep-alive request sent.
var expectedQuota = 65536;
function CreateKeepAliveRequest(delay, bodySize) {
// Create a body of the specified size that's filled with *'s
var requestBody = "*".repeat(bodySize);
return new Request(trickleURL+delay, {keepalive: true, body: requestBody, method: "POST"});
}
// Test 1 Byte
promise_test(function(test) {
return fetch(CreateKeepAliveRequest(0 /* delay */, 1 /* bodySize */));
}, "A Keep-Alive fetch() with a small body should succeed.");
// Test Quota full limit
promise_test(function(test) {
return fetch(CreateKeepAliveRequest(0 /* delay */, expectedQuota));
}, "A Keep-Alive fetch() with a body at the Quota Limit should succeed.");
// Test Quota + 1 Byte
promise_test(function(test) {
return promise_rejects(test, new TypeError(), fetch(CreateKeepAliveRequest(0 /* delay */, expectedQuota + 1)));
}, "A Keep-Alive fetch() with a body over the Quota Limit should reject.");
// Test the Quota becomes available upon promise completion.
promise_test(function (test) {
// Fill our Quota then try to send a second fetch.
var firstFetch = fetch(CreateKeepAliveRequest(standardDelay, expectedQuota)).then(function(response) {
// Now validate that we can send another Keep-Alive fetch for the full size of the quota.
return fetch(CreateKeepAliveRequest(0 /* delay */, expectedQuota));
});
return firstFetch;
}, "A Keep-Alive fetch() should return it's allocated Quota upon promise resolution.");
// Ensure only the correct amount of Quota becomes available when a fetch completes.
promise_test(function(test) {
var lastFetchSucceeded = false;
// Create a fetch that uses all but 1 Byte of the Quota and runs for 2x as long as the other requests.
var firstFetch = fetch(CreateKeepAliveRequest(standardDelay * 2, expectedQuota - 1)).then(function(response) {
// This should be our last completing fetch(). We need to validate that the last fetch we sent out actually
// completed.
assert_true(lastFetchSucceeded, "Out last fetch after gaining Quota back should have succeeded.");
});
// Now create a single Byte request that will complete quicker.
fetch(CreateKeepAliveRequest(standardDelay, 1 /* bodySize */)).then(function(response) {
// We shouldn't be able to create a 2 Byte request right now as only 1 Byte should have freed up.
assert_throws(new TypeError(), fetch(CreateKeepAliveRequest(0 /* delay */, 2 /* bodySize */)), "Only 1 Byte of Quota should be available right now.");
// Now validate that we can send another Keep-Alive fetch for just 1 Byte.
fetch(CreateKeepAliveRequest(0 /* delay */, 1 /* bodySize */)).then(function(response) {
// Flag we got a response from this request.
lastFetchSucceeded = true;
});
});
return firstFetch;
}, "A Keep-Alive fetch() should return only it's allocated Quota upon promise resolution.");
// Test rejecting a fetch() after the quota is used up.
promise_test(function (test) {
// Fill our Quota then try to send a second fetch.
fetch(CreateKeepAliveRequest(standardDelay, expectedQuota));
return promise_rejects(test, new TypeError(), fetch(CreateKeepAliveRequest(0 /* delay */, 1 /* bodySize */)));
}, "A Keep-Alive fetch() should not be allowed if the Quota is used up.");
</script>
</body>
</html>

View file

@ -17,6 +17,9 @@ def main(request, response):
cache_control = request.headers.get("Cache-Control", None)
ignore = "ignore" in request.GET
if tag:
tag = '"%s"' % tag
server_state = request.server.stash.take(token)
if not server_state:
server_state = []
@ -34,7 +37,7 @@ def main(request, response):
request.server.stash.put(token, server_state)
if tag:
response.headers.set("ETag", '"%s"' % tag)
response.headers.set("ETag", '%s' % tag)
elif date:
response.headers.set("Last-Modified", date)
if expires:

View file

@ -2,12 +2,19 @@ def main(request, response):
headers = [("Content-Type", "text/plain")]
stashed_data = {'control_request_headers': "", 'preflight': "0", 'preflight_referrer': ""}
token = None
if "token" in request.GET:
token = request.GET.first("token")
if "origin" in request.GET:
for origin in request.GET['origin'].split(", "):
headers.append(("Access-Control-Allow-Origin", origin))
else:
headers.append(("Access-Control-Allow-Origin", "*"))
if "credentials" in request.GET:
headers.append(("Access-Control-Allow-Credentials", "true"))
if request.method == "OPTIONS":
if not "Access-Control-Request-Method" in request.headers:
response.set_error(400, "No Access-Control-Request-Method header")
@ -31,13 +38,13 @@ def main(request, response):
stashed_data['preflight'] = "1"
stashed_data['preflight_referrer'] = request.headers.get("Referer", "")
request.server.stash.put(request.GET.first("token"), stashed_data)
if token:
request.server.stash.put(token, stashed_data)
return preflight_status, headers, ""
token = None
if "token" in request.GET:
token = request.GET.first("token")
if token:
data = request.server.stash.take(token)
if data:
stashed_data = data

View file

@ -41,6 +41,7 @@
readonly attribute boolean ok;
readonly attribute ByteString statusText;
[SameObject] readonly attribute Headers headers;
readonly attribute Promise<Headers> trailer;
[NewObject] Response clone();
};

View file

@ -0,0 +1,24 @@
<!doctype html>
<title>trailer() test</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<!-- based on /XMLHttpRequest/getresponseheader-chunked-trailer.htm -->
<script>
promise_test(() => {
return fetch("/XMLHttpRequest/resources/chunked.py").then(res => {
assert_equals(res.headers.get("Trailer"), "X-Test-Me")
assert_equals(res.headers.get("X-Test-Me"), null)
assert_equals(res.headers.get("Content-Type"), "text/plain")
return Promise.all([
res.text().then(text => {
assert_equals(text, "First chunk\r\nSecond chunk\r\nYet another (third) chunk\r\nYet another (fourth) chunk\r\n")
}),
res.trailer.then(trailers => {
assert_equals(trailers.get("X-Test-Me"), "Trailer header value")
assert_throws(new TypeError, () => trailers.append("Immutable-My-Ass", "Hi!"))
})
])
})
})
</script>