Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d

This commit is contained in:
Ms2ger 2016-11-14 11:07:09 +01:00
parent 65dd6d4340
commit ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions

View file

@ -0,0 +1,51 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Request ETag</title>
<meta name="help" href="https://fetch.spec.whatwg.org/#request">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
</head>
<body>
<script>
promise_test(function() {
var cacheBuster = token(); // ensures first request is uncached
var url = "../resources/cache.py?v=" + cacheBuster;
var etag;
// make the first request
return fetch(url).then(function(response) {
// ensure we're getting the regular, uncached response
assert_equals(response.status, 200);
assert_equals(response.headers.get("X-HTTP-STATUS"), null)
return response.text(); // consuming the body, just to be safe
}).then(function(body) {
// make a second request
return fetch(url);
}).then(function(response) {
// while the server responds with 304 if our browser sent the correct
// If-None-Match request header, at the JavaScript level this surfaces
// as 200
assert_equals(response.status, 200);
assert_equals(response.headers.get("X-HTTP-STATUS"), "304")
etag = response.headers.get("ETag")
return response.text(); // consuming the body, just to be safe
}).then(function(body) {
// make a third request, explicitly setting If-None-Match request header
var headers = { "If-None-Match": etag }
return fetch(url, { headers: headers })
}).then(function(response) {
// 304 now surfaces thanks to the explicit If-None-Match request header
assert_equals(response.status, 304);
});
}, "Testing conditional GET with ETags");
done();
</script>
</body>
</html>

View file

@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<title>Fetch: network timeout after receiving the HTTP response headers</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/utils.js"></script>
</head>
<body>
<div id="log"></div>
<script>
function checkReader(test, reader, promiseToTest)
{
return reader.read().then((value) => {
validateBufferFromString(value.value, "TEST_CHUNK", "Should receive first chunk");
return promise_rejects(test, new TypeError(), promiseToTest(reader));
});
}
promise_test((test) => {
return fetch("../resources/bad-chunk-encoding.py?count=1").then((response) => {
return checkReader(test, response.body.getReader(), reader => reader.read());
});
}, "Response reader read() promise should reject after a network error happening after resolving fetch promise");
promise_test((test) => {
return fetch("../resources/bad-chunk-encoding.py?count=1").then((response) => {
return checkReader(test, response.body.getReader(), reader => reader.closed);
});
}, "Response reader closed promise should reject after a network error happening after resolving fetch promise");
</script>
</body>
</html>

View file

@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in sharedworker: integrity handling</title>
<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 SharedWorker("integrity.js?pipe=sub"));
</script>
</body>
</html>

View file

@ -15,6 +15,8 @@ function checkContentType(contentType, body)
expectedContentType = null;
else if (body instanceof Blob)
expectedContentType = body.type ? body.type : null;
else if (body instanceof URLSearchParams)
expectedContentType = "application/x-www-form-urlencoded;charset=UTF-8";
assert_equals(contentType , expectedContentType, "Request should have header content-type: " + expectedContentType);
}
@ -49,6 +51,7 @@ requestHeaders("Fetch with PUT with body", url, "PUT", "Request's body", locatio
requestHeaders("Fetch with POST without body", url, "POST", null, location.origin, "0");
requestHeaders("Fetch with POST with text body", url, "POST", "Request's body", location.origin, "14");
requestHeaders("Fetch with POST with FormData body", url, "POST", function() { return new FormData(); }, location.origin);
requestHeaders("Fetch with POST with URLSearchParams body", url, "POST", function() { return new URLSearchParams("name=value"); }, location.origin, "10");
requestHeaders("Fetch with POST with Blob body", url, "POST", new Blob(["Test"]), location.origin, "4");
requestHeaders("Fetch with POST with ArrayBuffer body", url, "POST", new ArrayBuffer(4), location.origin, "4");
requestHeaders("Fetch with POST with Uint8Array body", url, "POST", new Uint8Array(4), location.origin, "4");

View file

@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch in worker: Upload</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"));
</script>
</body>
</html>

View file

@ -0,0 +1,13 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fetch: Uploading content</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>
</body>
</html>

View file

@ -0,0 +1,35 @@
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);
}
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");
done();

View file

@ -3,10 +3,10 @@ if (this.document === undefined) {
importScripts("../resources/utils.js");
}
function checkFetchResponse(url, data, mime, fetchMode) {
function checkFetchResponse(url, data, mime, fetchMode, method) {
var cut = (url.length >= 40) ? "[...]" : "";
desc = "Fetching " + url.substring(0, 40) + cut + " is OK";
var init = { };
desc = "Fetching " + (method ? "[" + method + "] " : "") + url.substring(0, 40) + cut + " is OK";
var init = {"method": method || "GET"};
if (fetchMode) {
init.mode = fetchMode;
desc += " (" + fetchMode + ")";
@ -31,6 +31,8 @@ checkFetchResponse("data:text/plain;base64,cmVzcG9uc2UncyBib2R5", "response's bo
checkFetchResponse("data:image/png;base64,cmVzcG9uc2UncyBib2R5",
"response's body",
"image/png");
checkFetchResponse("data:,response%27s%20body", "response's body", "text/plain;charset=US-ASCII", null, "POST");
checkFetchResponse("data:,response%27s%20body", "response's body", "text/plain;charset=US-ASCII", null, "HEAD");
function checkKoUrl(url, method, desc) {
var cut = (url.length >= 40) ? "[...]" : "";
@ -41,7 +43,5 @@ function checkKoUrl(url, method, desc) {
}
checkKoUrl("data:notAdataUrl.com", "GET");
checkKoUrl("data:,response%27s%20body", "POST");
checkKoUrl("data:,response%27s%20body", "HEAD");
done();

View file

@ -41,6 +41,19 @@ function testTextDecoding(body, expectedText, urlParameter, title)
});
});
}, title + " with fetched data (UTF-16 charset)");
promise_test(function(test) {
return new Response(body).arrayBuffer().then(function(buffer) {
assert_array_equals(new Uint8Array(buffer), encode_utf8(body), "Response.arrayBuffer() should contain data encoded as UTF-8");
});
}, title + " (Response object)");
promise_test(function(test) {
return new Request("", {method: "POST", body: body}).arrayBuffer().then(function(buffer) {
assert_array_equals(new Uint8Array(buffer), encode_utf8(body), "Request.arrayBuffer() should contain data encoded as UTF-8");
});
}, title + " (Request object)");
}
var utf8WithBOM = "\xef\xbb\xbf\xe4\xb8\x89\xe6\x9d\x91\xe3\x81\x8b\xe3\x81\xaa\xe5\xad\x90";