mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 7f2f85a88f434798e9d643427b34b05fab8278c6
This commit is contained in:
parent
6b1a08c051
commit
73bc5cf1b8
180 changed files with 5807 additions and 169 deletions
|
@ -0,0 +1,16 @@
|
|||
<!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>
|
|
@ -0,0 +1,15 @@
|
|||
<!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>
|
|
@ -0,0 +1,14 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
promise_test(function() {
|
||||
return fetch(RESOURCES_DIR + "inspect-headers.py?headers=Accept").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"), "*/*", "Request has accept header with value '*/*'");
|
||||
});
|
||||
}, "Request through fetch should have 'accept' header with value '*/*'");
|
||||
|
||||
done();
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch in worker: integrity handling</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">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
fetch_tests_from_worker(new Worker("integrity.js?pipe=sub"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
15
tests/wpt/web-platform-tests/fetch/api/basic/integrity.html
Normal file
15
tests/wpt/web-platform-tests/fetch/api/basic/integrity.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch: integrity handling</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">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script src="../resources/utils.js"></script>
|
||||
<script src="integrity.js?pipe=sub"></script>
|
||||
</body>
|
||||
</html>
|
45
tests/wpt/web-platform-tests/fetch/api/basic/integrity.js
Normal file
45
tests/wpt/web-platform-tests/fetch/api/basic/integrity.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function integrity(desc, url, integrity, shouldPass) {
|
||||
if (shouldPass) {
|
||||
promise_test(function(test) {
|
||||
return fetch(url, {'integrity': integrity}).then(function(resp) {
|
||||
assert_equals(resp.status, 200, "Response's status is 200");
|
||||
});
|
||||
}, desc);
|
||||
} else {
|
||||
promise_test(function(test) {
|
||||
return promise_rejects(test, new TypeError(), fetch(url, {'integrity': integrity}));
|
||||
}, desc);
|
||||
}
|
||||
}
|
||||
|
||||
var topSha256 = "sha256-KHIDZcXnR2oBHk9DrAA+5fFiR6JjudYjqoXtMR1zvzk=";
|
||||
var topSha384 = "sha384-MgZYnnAzPM/MjhqfOIMfQK5qcFvGZsGLzx4Phd7/A8fHTqqLqXqKo8cNzY3xEPTL";
|
||||
var topSha512 = "sha512-D6yns0qxG0E7+TwkevZ4Jt5t7Iy3ugmAajG/dlf6Pado1JqTyneKXICDiqFIkLMRExgtvg8PlxbKTkYfRejSOg==";
|
||||
var invalidSha256 = "sha256-dKUcPOn/AlUjWIwcHeHNqYXPlvyGiq+2dWOdFcE+24I=";
|
||||
var invalidSha512 = "sha512-oUceBRNxPxnY60g/VtPCj2syT4wo4EZh2CgYdWy9veW8+OsReTXoh7dizMGZafvx9+QhMS39L/gIkxnPIn41Zg==";
|
||||
|
||||
var url = "../resources/top.txt";
|
||||
var corsUrl = "http://www1.{{host}}:{{ports[http][0]}}" + dirname(location.pathname) + RESOURCES_DIR + "top.txt";
|
||||
/* Enable CORS*/
|
||||
corsUrl += "?pipe=header(Access-Control-Allow-Origin,*)";
|
||||
|
||||
integrity("Empty string integrity", url, "", true);
|
||||
integrity("SHA-256 integrity", url, topSha256, true);
|
||||
integrity("SHA-384 integrity", url, topSha384, true);
|
||||
integrity("SHA-512 integrity", url, topSha512, true);
|
||||
integrity("Invalid integrity", url, invalidSha256, false);
|
||||
integrity("Multiple integrities: valid stronger than invalid", url, invalidSha256 + " " + topSha384, true);
|
||||
integrity("Multiple integrities: invalid stronger than valid", url, invalidSha512 + " " + topSha384, false);
|
||||
integrity("Multiple integrities: invalid as strong as valid", url, invalidSha512 + " " + topSha512, true);
|
||||
integrity("Multiple integrities: both are valid", url, topSha384 + " " + topSha512, true);
|
||||
integrity("Multiple integrities: both are invalid", url, invalidSha256 + " " + invalidSha512, false);
|
||||
integrity("CORS empty integrity", corsUrl, "", true);
|
||||
integrity("CORS SHA-512 integrity", corsUrl, topSha512, true);
|
||||
integrity("CORS invalid integrity", corsUrl, invalidSha512, false);
|
||||
|
||||
done();
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch in worker: no-cors mode and opaque filtering</title>
|
||||
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
|
||||
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-opaque">
|
||||
<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-no-cors.js?pipe=sub"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch: no-cors mode and opaque filtering</title>
|
||||
<meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
|
||||
<meta name="help" href="https://fetch.spec.whatwg.org/#concept-filtered-response-opaque">
|
||||
<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="mode-no-cors.js?pipe=sub"></script>
|
||||
</body>
|
||||
</html>
|
31
tests/wpt/web-platform-tests/fetch/api/basic/mode-no-cors.js
Normal file
31
tests/wpt/web-platform-tests/fetch/api/basic/mode-no-cors.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function fetchNoCors(url, isOpaqueFiltered) {
|
||||
var urlQuery = "?pipe=header(x-is-filtered,value)"
|
||||
promise_test(function(test) {
|
||||
if (isOpaqueFiltered)
|
||||
return fetch(url + urlQuery, {"mode": "no-cors"}).then(function(resp) {
|
||||
assert_equals(resp.status, 0, "Opaque filter: status is 0");
|
||||
assert_equals(resp.statusText, "", "Opaque filter: statusText is \"\"");
|
||||
assert_equals(resp.type , "opaque", "Opaque filter: response's type is opaque");
|
||||
assert_equals(resp.headers.get("x-is-filtered"), null, "Header x-is-filtered is filtered");
|
||||
});
|
||||
else
|
||||
return fetch(url + urlQuery, {"mode": "no-cors"}).then(function(resp) {
|
||||
assert_equals(resp.status, 200, "HTTP status is 200");
|
||||
assert_equals(resp.type , "basic", "Response's type is basic");
|
||||
assert_equals(resp.headers.get("x-is-filtered"), "value", "Header x-is-filtered is not filtered");
|
||||
});
|
||||
}, "Fetch "+ url + " with no-cors mode");
|
||||
}
|
||||
|
||||
fetchNoCors(RESOURCES_DIR + "top.txt", false);
|
||||
fetchNoCors("http://{{host}}:{{ports[http][0]}}/fetch/api/resources/top.txt", false);
|
||||
fetchNoCors("https://{{host}}:{{ports[https][0]}}/fetch/api/resources/top.txt", true);
|
||||
fetchNoCors("http://{{domains[www]}}:{{ports[http][0]}}/fetch/api/resources/top.txt", true);
|
||||
|
||||
done();
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<!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?pipe=sub"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<!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="mode-same-origin.js?pipe=sub"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,24 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function fetchSameOrigin(url, shouldPass) {
|
||||
promise_test(function(test) {
|
||||
if (shouldPass)
|
||||
return fetch(url , {"mode": "same-origin"}).then(function(resp) {
|
||||
assert_equals(resp.status, 200, "HTTP status is 200");
|
||||
assert_equals(resp.type, "basic", "response type is basic");
|
||||
});
|
||||
else
|
||||
return promise_rejects(test, new TypeError, fetch(url, {mode: "same-origin"}));
|
||||
}, "Fetch "+ url + " with same-origin mode");
|
||||
}
|
||||
|
||||
fetchSameOrigin(RESOURCES_DIR + "top.txt", true);
|
||||
fetchSameOrigin("http://{{host}}:{{ports[http][0]}}/fetch/api/resources/top.txt", true);
|
||||
fetchSameOrigin("https://{{host}}:{{ports[https][0]}}/fetch/api/resources/top.txt", false);
|
||||
fetchSameOrigin("http://{{domains[www]}}:{{ports[http][0]}}/fetch/api/resources/top.txt", false);
|
||||
|
||||
done();
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<!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>
|
|
@ -0,0 +1,16 @@
|
|||
<!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>
|
|
@ -0,0 +1,48 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function requestForbiddenHeaders(desc, forbiddenHeaders) {
|
||||
var url = RESOURCES_DIR + "inspect-headers.py";
|
||||
var requestInit = {"headers": forbiddenHeaders}
|
||||
var urlParameters = "?headers=" + Object.keys(forbiddenHeaders).join("|");
|
||||
|
||||
promise_test(function(test){
|
||||
return fetch(url + urlParameters, requestInit).then(function(resp) {
|
||||
assert_equals(resp.status, 200, "HTTP status is 200");
|
||||
assert_equals(resp.type , "basic", "Response's type is basic");
|
||||
for (var header in forbiddenHeaders)
|
||||
assert_not_equals(resp.headers.get("x-request-" + header), forbiddenHeaders[header], header + " does not have the value we defined");
|
||||
});
|
||||
}, desc);
|
||||
}
|
||||
|
||||
requestForbiddenHeaders("Accept-Charset is a forbidden request header", {"Accept-Charset": "utf-8"});
|
||||
requestForbiddenHeaders("Accept-Encoding is a forbidden request header", {"Accept-Encoding": ""});
|
||||
|
||||
requestForbiddenHeaders("Access-Control-Request-Headers is a forbidden request header", {"Access-Control-Request-Headers": ""});
|
||||
requestForbiddenHeaders("Access-Control-Request-Method is a forbidden request header", {"Access-Control-Request-Method": ""});
|
||||
requestForbiddenHeaders("Connection is a forbidden request header", {"Connection": "close"});
|
||||
requestForbiddenHeaders("Content-Length is a forbidden request header", {"Content-Length": "42"});
|
||||
requestForbiddenHeaders("Cookie is a forbidden request header", {"Cookie": "cookie=none"});
|
||||
requestForbiddenHeaders("Cookie2 is a forbidden request header", {"Cookie2": "cookie2=none"});
|
||||
requestForbiddenHeaders("Date is a forbidden request header", {"Date": "Wed, 04 May 1988 22:22:22 GMT"});
|
||||
requestForbiddenHeaders("DNT is a forbidden request header", {"DNT": "4"});
|
||||
requestForbiddenHeaders("Expect is a forbidden request header", {"Expect": "100-continue"});
|
||||
requestForbiddenHeaders("Host is a forbidden request header", {"Host": "http://wrong-host.com"});
|
||||
requestForbiddenHeaders("Keep-Alive is a forbidden request header", {"Keep-Alive": "timeout=15"});
|
||||
requestForbiddenHeaders("Origin is a forbidden request header", {"Origin": "http://wrong-origin.com"});
|
||||
requestForbiddenHeaders("Referer is a forbidden request header", {"Referer": "http://wrong-referer.com"});
|
||||
requestForbiddenHeaders("TE is a forbidden request header", {"TE": "trailers"});
|
||||
requestForbiddenHeaders("Trailer is a forbidden request header", {"Trailer": "Accept"});
|
||||
requestForbiddenHeaders("Transfer-Encoding is a forbidden request header", {"Transfer-Encoding": "chunked"});
|
||||
requestForbiddenHeaders("Upgrade is a forbidden request header", {"Upgrade": "HTTP/2.0"});
|
||||
requestForbiddenHeaders("Via is a forbidden request header", {"Via": "1.1 nowhere.com"});
|
||||
requestForbiddenHeaders("Proxy- is a forbidden request header", {"Proxy-": "value"});
|
||||
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();
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<!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>
|
|
@ -0,0 +1,15 @@
|
|||
<!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>
|
|
@ -0,0 +1,35 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function requestHeaders(desc, url, method, body, expectedOrigin, expectedContentLength) {
|
||||
var urlParameters = "?headers=origin|user-agent|accept-charset|content-length";
|
||||
var requestInit = {"method": method}
|
||||
if (body)
|
||||
requestInit["body"] = body;
|
||||
promise_test(function(test){
|
||||
return fetch(url + urlParameters, requestInit).then(function(resp) {
|
||||
assert_equals(resp.status, 200, "HTTP status is 200");
|
||||
assert_equals(resp.type , "basic", "Response's type is basic");
|
||||
assert_equals(resp.headers.get("x-request-origin") , expectedOrigin, "Request has header origin: " + expectedOrigin);
|
||||
assert_equals(resp.headers.get("x-request-content-length") , expectedContentLength, "Request has header content-length: " + expectedContentLength);
|
||||
assert_true(resp.headers.has("x-request-user-agent"), "Request has header user-agent");
|
||||
assert_false(resp.headers.has("accept-charset"), "Request has header accept-charset");
|
||||
});
|
||||
}, desc);
|
||||
}
|
||||
|
||||
var url = RESOURCES_DIR + "inspect-headers.py"
|
||||
|
||||
requestHeaders("Fetch with GET", url, "GET", null, location.origin, null);
|
||||
requestHeaders("Fetch with HEAD", url, "HEAD", null, location.origin, "0");
|
||||
requestHeaders("Fetch with HEAD with body", url, "HEAD", "Request's body", location.origin, "14");
|
||||
requestHeaders("Fetch with PUT without body", url, "POST", null, location.origin, "0");
|
||||
requestHeaders("Fetch with PUT with body", url, "PUT", "Request's body", location.origin, "14");
|
||||
requestHeaders("Fetch with POST without body", url, "POST", null, location.origin, "0");
|
||||
requestHeaders("Fetch with POST with body", url, "POST", "Request's body", location.origin, "14");
|
||||
requestHeaders("Fetch with Chicken", url, "Chicken", null, location.origin, null);
|
||||
requestHeaders("Fetch with Chicken with body", url, "Chicken", "Request's body", location.origin, "14");
|
||||
|
||||
done();
|
|
@ -0,0 +1,17 @@
|
|||
<!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>
|
|
@ -0,0 +1,16 @@
|
|||
<!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>
|
40
tests/wpt/web-platform-tests/fetch/api/basic/scheme-about.js
Normal file
40
tests/wpt/web-platform-tests/fetch/api/basic/scheme-about.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
var unicorn = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2361 1572" fill="hotpink"><path d="m1648 1570c-42-12 6-93 55-94 46 0 50-10 46-123-5-122-7-126-119-202-81-55-145-128-175-201-12-30-26-59-31-63s-58-4-119 0c-70 6-131 5-170-2-59-10-84-21-220-93-68-36-72-37-145-31-41 4-100 11-131 17-55 10-57 12-62 47-16 95 3 152 49 152 14 0 29 8 34 19 14 25 13 101-0 101-12 0-60-46-60-58 0-4-17-18-38-31l-38-23-2-115c-1-64 2-124 8-133s24-21 42-25c59-12 128-37 128-46 0-5-4-9-10-9-14 0-28-30-45-95-12-47-13-69-3-124 11-62 10-71-10-109-12-23-22-50-22-60s-7-27-15-37c-18-23-19-18-5 24 8 24 7 50-5 110-10 48-14 96-10 120 8 47-9 72-48 72-40 0-66-26-77-81-6-28-30-88-53-133-23-45-45-88-48-96-4-8-22-20-41-26-26-9-34-17-34-36 0-22 4-24 37-21l37 3-9-33c-12-43-6-47 31-20l30 22 26-20c14-11 39-38 55-61 39-53 63-62 139-49 46 8 64 8 75-2 8-7 15-8 15-4-0 15-14 30-34 37-37 14-6 19 44 7 49-12 53-11 90 15 28 19 48 26 69 23 37-6 29 10-16 28-19 8-32 19-28 24 4 6 15 5 30-2 18-8 35-7 71 5 27 9 58 16 71 16 32 0 29 17-7 35-16 9-30 17-30 20 0 2 22 2 49-2 44-5 52-3 96 31 27 20 54 34 62 32 25-10 14 4-16 19-16 8-39 15-50 15-29 0-26 16 20 87 45 68 96 101 189 123 149 35 239 59 268 71 27 12 36 11 67-4 21-10 41-29 47-45 23-59 39-78 80-101 60-32 141-27 175 12 23 28 25 34 43 178 15 118 36 182 72 224 28 32 35 35 90 35 75 0 125-21 167-68l33-37-17 40c-16 41-65 98-100 117-11 6-42 17-70 24l-50 12 62 1c48 0 72-5 116-28 50-25 55-26 45-8-17 33-98 115-136 139-29 18-51 22-113 22-71 1-80-2-115-30-21-17-86-28-99-128-7-56 0-176 0-176s18-102-6-175c-19-57-81-86-123-20-19 30-43 60-54 67-18 12-18 13 6 59 34 67 38 144 14 260l-20 95 24 35c13 20 40 51 59 70 40 38 41 50 29 252-6 92-9 107-25 111-10 3-19 12-19 20s-7 18-17 20c-32 10-87 15-105 10zm-1228-1255c0-18-2-19-16-8-12 10-13 15-3 21 18 11 18 11 18-13zm743 1151c-12-5-23-14-23-20 0-17 57-69 76-69 21 0 130-65 167-99 47-43 36-101-38-198-30-39-73-148-63-158 2-2 30-5 63-7l60-3 32 60c41 77 38 69 63 145 40 115 41 112-31 166-34 27-79 62-98 79-20 17-43 34-53 38-10 3-22 17-27 30-5 14-13 27-17 29-19 12-90 16-111 7zm-913-440c0-23 28-113 44-145 6-11 32-51 57-90 26-39 50-81 53-95 5-21 22-30 103-59 53-19 102-36 108-38 6-2 18 11 27 30l16 34-92 28c-105 32-126 47-161 122-16 34-35 58-50 63-32 13-40 42-22 85l15 36-37 25c-45 30-62 31-62 4zm-48-843c-41-18-25-52 19-39 21 6 23 10 14 28-9 17-15 19-33 11zm-74-25c-28-6-31-32-4-32 13 0 26 4 29 8 8 13-8 28-25 24zm-78-37c0-9 6-12 15-9 19 7 19 24 0 24-8 0-15-7-15-15zm-50-15c0-5 7-7 15-4 19 7 19 14 0 14-8 0-15-4-15-10z"/></svg>';
|
||||
|
||||
function checkFetchResponse(url, data, mime, desc) {
|
||||
if (!desc) {
|
||||
var cut = (url.length >= 45) ? "[...]" : "";
|
||||
desc = "Fetching " + url.substring(0, 45) + cut + " is OK"
|
||||
}
|
||||
promise_test(function(test) {
|
||||
return fetch(url).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"), mime, "Content-Type is " + resp.headers.get("Content-Type"));
|
||||
return resp.text();
|
||||
}).then(function(bodyAsText) {
|
||||
assert_equals(bodyAsText, data, "Response's body is " + data);
|
||||
})
|
||||
}, desc);
|
||||
}
|
||||
|
||||
checkFetchResponse("about:blank", "", "text/html;charset=utf-8");
|
||||
checkFetchResponse("about:unicorn", unicorn, "image/svg+xml");
|
||||
|
||||
function checkKoUrl(url, desc) {
|
||||
if (!desc)
|
||||
desc = "Fetching " + url.substring(0, 45) + " is KO"
|
||||
promise_test(function(test) {
|
||||
var promise = fetch(url);
|
||||
return promise_rejects(test, new TypeError(), promise);
|
||||
}, desc);
|
||||
}
|
||||
|
||||
checkKoUrl("about:invalid.com");
|
||||
checkKoUrl("about:config");
|
||||
|
||||
done();
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch in worker: blob 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-blob.js?pipe=sub"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch: blob 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-blob.js?pipe=sub"></script>
|
||||
</body>
|
||||
</html>
|
41
tests/wpt/web-platform-tests/fetch/api/basic/scheme-blob.js
Normal file
41
tests/wpt/web-platform-tests/fetch/api/basic/scheme-blob.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function checkFetchResponse(url, data, mime, size, desc) {
|
||||
if (!desc)
|
||||
var cut = (url.length >= 45) ? "[...]" : "";
|
||||
desc = "Fetching " + url.substring(0, 45) + cut + " is OK"
|
||||
promise_test(function(test) {
|
||||
size = size.toString();
|
||||
return fetch(url).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"), mime, "Content-Type is " + resp.headers.get("Content-Type"));
|
||||
assert_equals(resp.headers.get("Content-Length"), size, "Content-Length is " + resp.headers.get("Content-Length"));
|
||||
return resp.text();
|
||||
}).then(function(bodyAsText) {
|
||||
assert_equals(bodyAsText, data, "Response's body is " + data);
|
||||
})
|
||||
}, desc);
|
||||
}
|
||||
|
||||
var blob = new Blob(["Blob's data"], { "type" : "text/plain" });
|
||||
checkFetchResponse(URL.createObjectURL(blob), "Blob's data", "text/plain", blob.size);
|
||||
|
||||
function checkKoUrl(url, method, desc) {
|
||||
if (!desc)
|
||||
var cut = (url.length >= 45) ? "[...]" : "";
|
||||
desc = "Fetching [" + method + "] " + url.substring(0, 45) + cut + " is KO"
|
||||
promise_test(function(test) {
|
||||
var promise = fetch(url, {"method": method});
|
||||
return promise_rejects(test, new TypeError(), promise);
|
||||
}, desc);
|
||||
}
|
||||
|
||||
var blob2 = new Blob(["Blob's data"], { "type" : "text/plain" });
|
||||
checkKoUrl("blob:http://{{domains[www]}}:{{ports[http][0]}}/", "GET");
|
||||
checkKoUrl(URL.createObjectURL(blob2), "POST");
|
||||
|
||||
done();
|
|
@ -0,0 +1,17 @@
|
|||
<!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>
|
|
@ -0,0 +1,16 @@
|
|||
<!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>
|
39
tests/wpt/web-platform-tests/fetch/api/basic/scheme-data.js
Normal file
39
tests/wpt/web-platform-tests/fetch/api/basic/scheme-data.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function checkFetchResponse(url, data, mime) {
|
||||
var cut = (url.length >= 40) ? "[...]" : "";
|
||||
desc = "Fetching " + url.substring(0, 40) + cut + " is OK"
|
||||
promise_test(function(test) {
|
||||
return fetch(url).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"), mime, "Content-Type is " + resp.headers.get("Content-Type"));
|
||||
return resp.text();
|
||||
}).then(function(body) {
|
||||
assert_equals(body, data, "Response's body is correct");
|
||||
});
|
||||
}, desc);
|
||||
}
|
||||
|
||||
checkFetchResponse("data:,response%27s%20body", "response's body", "text/plain;charset=US-ASCII");
|
||||
checkFetchResponse("data:text/plain;base64,cmVzcG9uc2UncyBib2R5", "response's body", "text/plain");
|
||||
checkFetchResponse("data:image/png;base64,cmVzcG9uc2UncyBib2R5",
|
||||
"response's body",
|
||||
"image/png");
|
||||
|
||||
function checkKoUrl(url, method, desc) {
|
||||
var cut = (url.length >= 40) ? "[...]" : "";
|
||||
desc = "Fetching [" + method + "] " + url.substring(0, 45) + cut + " is KO"
|
||||
promise_test(function(test) {
|
||||
return promise_rejects(test, new TypeError(), fetch(url, {"method": method}));
|
||||
}, desc);
|
||||
}
|
||||
|
||||
checkKoUrl("data:notAdataUrl.com", "GET");
|
||||
checkKoUrl("data:,response%27s%20body", "POST");
|
||||
checkKoUrl("data:,response%27s%20body", "HEAD");
|
||||
|
||||
done();
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch in worker: urls with unsupported schemes</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-others.js?pipe=sub"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch: urls with unsupported schemes</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-others.js?pipe=sub"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,33 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function checkKoUrl(url, desc) {
|
||||
if (!desc)
|
||||
desc = "Fetching " + url.substring(0, 45) + " is KO"
|
||||
promise_test(function(test) {
|
||||
var promise = fetch(url);
|
||||
return promise_rejects(test, new TypeError(), promise);
|
||||
}, desc);
|
||||
}
|
||||
|
||||
var urlWithoutScheme = "://{{host}}:{{ports[http][0]}}/";
|
||||
checkKoUrl("aaa" + urlWithoutScheme);
|
||||
checkKoUrl("cap" + urlWithoutScheme);
|
||||
checkKoUrl("cid" + urlWithoutScheme);
|
||||
checkKoUrl("dav" + urlWithoutScheme);
|
||||
checkKoUrl("dict" + urlWithoutScheme);
|
||||
checkKoUrl("dns" + urlWithoutScheme);
|
||||
checkKoUrl("geo" + urlWithoutScheme);
|
||||
checkKoUrl("im" + urlWithoutScheme);
|
||||
checkKoUrl("imap" + urlWithoutScheme);
|
||||
checkKoUrl("ipp" + urlWithoutScheme);
|
||||
checkKoUrl("ldap" + urlWithoutScheme);
|
||||
checkKoUrl("mailto" + urlWithoutScheme);
|
||||
checkKoUrl("nfs" + urlWithoutScheme);
|
||||
checkKoUrl("pop" + urlWithoutScheme);
|
||||
checkKoUrl("rtsp" + urlWithoutScheme);
|
||||
checkKoUrl("snmp" + urlWithoutScheme);
|
||||
|
||||
done();
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch in worker: 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>
|
||||
fetch_tests_from_worker(new Worker("stream-response.js"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,16 @@
|
|||
<!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>
|
|
@ -0,0 +1,37 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
}
|
||||
|
||||
function streamBody(reader, test, count) {
|
||||
return reader.read().then(function(data) {
|
||||
if (!data.done && count < 2) {
|
||||
count += 1;
|
||||
return streamBody(reader, test, count);
|
||||
} else {
|
||||
test.step(function() {
|
||||
assert_true(count >= 2, "Retrieve body progressively");
|
||||
test.done();
|
||||
return;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//simulate streaming:
|
||||
//count is large enough to let the UA deliver the body before it is completely retrieved
|
||||
async_test(function(test) {
|
||||
fetch(RESOURCES_DIR + "trickle.py?ms=30&count=100").then(function(resp) {
|
||||
var count = 0;
|
||||
if (resp.body)
|
||||
return streamBody(resp.body.getReader(), test, count);
|
||||
else
|
||||
test.step(function() {
|
||||
assert_unreached( "Body does not exist in response");
|
||||
test.done();
|
||||
return;
|
||||
});
|
||||
});
|
||||
}, "Stream response's body");
|
||||
|
||||
done();
|
Loading…
Add table
Add a link
Reference in a new issue