Update web-platform-tests to revision dc5cbf088edcdb266541d4e5a76149a2c6e716a0

This commit is contained in:
Ms2ger 2016-09-09 09:40:35 +02:00
parent 1d40075f03
commit 079092dfea
2381 changed files with 90360 additions and 17722 deletions

View file

@ -3,19 +3,39 @@ if (this.document === undefined) {
importScripts("../resources/utils.js");
}
function checkContentType(contentType, body)
{
if (self.FormData && body instanceof self.FormData) {
assert_true(contentType.startsWith("multipart/form-data;boundary="), "Request should have header content-type starting with multipart/form-data;boundary=, but got " + contentType);
return;
}
var expectedContentType = "text/plain;charset=UTF-8";
if(body === null || body instanceof ArrayBuffer || body.buffer instanceof ArrayBuffer)
expectedContentType = null;
else if (body instanceof Blob)
expectedContentType = body.type ? body.type : null;
assert_equals(contentType , expectedContentType, "Request should have header content-type: " + expectedContentType);
}
function requestHeaders(desc, url, method, body, expectedOrigin, expectedContentLength) {
var urlParameters = "?headers=origin|user-agent|accept-charset|content-length";
var urlParameters = "?headers=origin|user-agent|accept-charset|content-length|content-type";
var requestInit = {"method": method}
if (body)
requestInit["body"] = body;
promise_test(function(test){
if (typeof body === "function")
body = body();
if (body)
requestInit["body"] = body;
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");
assert_equals(resp.headers.get("x-request-origin") , expectedOrigin, "Request should have header origin: " + expectedOrigin);
if (expectedContentLength !== undefined)
assert_equals(resp.headers.get("x-request-content-length") , expectedContentLength, "Request should have header content-length: " + expectedContentLength);
checkContentType(resp.headers.get("x-request-content-type"), body);
});
}, desc);
}
@ -23,12 +43,20 @@ function requestHeaders(desc, url, method, body, expectedOrigin, expectedContent
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 HEAD", url, "HEAD", null, location.origin, null);
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 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 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");
requestHeaders("Fetch with POST with Int8Array body", url, "POST", new Int8Array(4), location.origin, "4");
requestHeaders("Fetch with POST with Float32Array body", url, "POST", new Float32Array(1), location.origin, "4");
requestHeaders("Fetch with POST with Float64Array body", url, "POST", new Float64Array(1), location.origin, "8");
requestHeaders("Fetch with POST with DataView body", url, "POST", new DataView(new ArrayBuffer(8), 0, 4), location.origin, "4");
requestHeaders("Fetch with POST with Blob body with mime type", url, "POST", new Blob(["Test"], { type: "text/maybe" }), location.origin, "4");
requestHeaders("Fetch with Chicken", url, "Chicken", null, location.origin, null);
requestHeaders("Fetch with Chicken with body", url, "Chicken", "Request's body", location.origin, "14");