mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Update web-platform-tests and CSS tests.
- Update CSS tests to revision e05bfd5e30ed662c2f8a353577003f8eed230180. - Update web-platform-tests to revision a052787dd5c069a340031011196b73affbd68cd9.
This commit is contained in:
parent
fb4f421c8b
commit
296fa2512b
21852 changed files with 2080936 additions and 892894 deletions
|
@ -18,6 +18,17 @@ function testUpload(desc, url, method, body, 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");
|
||||
|
@ -31,5 +42,30 @@ testUpload("Fetch with POST with Float32Array body", url, "POST", new Float32Arr
|
|||
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();
|
||||
|
|
|
@ -33,11 +33,8 @@ function corsPreflight(desc, corsUrl, method, allowed, headers, safeHeaders) {
|
|||
requestInit["headers"] = requestHeaders;
|
||||
|
||||
if (allowed) {
|
||||
urlParameters += "&allow_methods=" + method;
|
||||
urlParameters += "&allow_methods=" + method + "&control_request_headers";
|
||||
if (headers) {
|
||||
//Let's check prefligh request.
|
||||
//Server will send back headers from Access-Control-Request-Headers in x-control-request-headers
|
||||
urlParameters += "&control_request_headers"
|
||||
//Make the server allow the headers
|
||||
urlParameters += "&allow_headers=" + headerNames(headers).join("%20%2C");
|
||||
}
|
||||
|
@ -54,6 +51,8 @@ function corsPreflight(desc, corsUrl, method, allowed, headers, safeHeaders) {
|
|||
let accessControlAllowHeaders = headerNames(headers).sort().join(",");
|
||||
assert_equals(resp.headers.get("x-control-request-headers"), accessControlAllowHeaders, "Access-Control-Allow-Headers value");
|
||||
return fetch(RESOURCES_DIR + "clean-stash.py?token=" + uuid_token);
|
||||
} else {
|
||||
assert_equals(resp.headers.get("x-control-request-headers"), null, "Access-Control-Request-Headers should be omitted")
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf8>
|
||||
<meta name=timeout content=long>
|
||||
<title>Header value normalizing test</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
for(let i = 0; i < 0x21; i++) {
|
||||
let fail = false,
|
||||
strip = false
|
||||
|
||||
// REMOVE 0x0B/0x0C exception once https://github.com/w3c/wptserve/issues/111 is fixed
|
||||
if(i === 0x0B || i === 0x0C)
|
||||
continue
|
||||
|
||||
if(i === 0) {
|
||||
fail = true
|
||||
}
|
||||
|
||||
if(i === 0x09 || i === 0x0A || i === 0x0D || i === 0x20) {
|
||||
strip = true
|
||||
}
|
||||
|
||||
let url = "../resources/inspect-headers.py?headers=val1|val2|val3",
|
||||
val = String.fromCharCode(i),
|
||||
expectedVal = strip ? "" : val,
|
||||
val1 = val,
|
||||
expectedVal1 = expectedVal,
|
||||
val2 = "x" + val,
|
||||
expectedVal2 = "x" + expectedVal,
|
||||
val3 = val + "x",
|
||||
expectedVal3 = expectedVal + "x"
|
||||
|
||||
async_test((t) => {
|
||||
let xhr = new XMLHttpRequest()
|
||||
xhr.open("POST", url)
|
||||
if(fail) {
|
||||
assert_throws("SyntaxError", () => xhr.setRequestHeader("val1", val1))
|
||||
assert_throws("SyntaxError", () => xhr.setRequestHeader("val2", val2))
|
||||
assert_throws("SyntaxError", () => xhr.setRequestHeader("val3", val3))
|
||||
t.done()
|
||||
} else {
|
||||
xhr.setRequestHeader("val1", val1)
|
||||
xhr.setRequestHeader("val2", val2)
|
||||
xhr.setRequestHeader("val3", val3)
|
||||
xhr.onload = t.step_func_done(() => {
|
||||
assert_equals(xhr.getResponseHeader("x-request-val1"), expectedVal1)
|
||||
assert_equals(xhr.getResponseHeader("x-request-val2"), expectedVal2)
|
||||
assert_equals(xhr.getResponseHeader("x-request-val3"), expectedVal3)
|
||||
})
|
||||
xhr.send()
|
||||
}
|
||||
}, "XMLHttpRequest with value " + encodeURI(val))
|
||||
|
||||
promise_test((t) => {
|
||||
if(fail) {
|
||||
return Promise.all([
|
||||
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val1": val1} })),
|
||||
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val2": val2} })),
|
||||
promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"val3": val3} }))
|
||||
])
|
||||
} else {
|
||||
return fetch(url, { headers: {"val1": val1, "val2": val2, "val3": val3} }).then((res) => {
|
||||
assert_equals(res.headers.get("x-request-val1"), expectedVal1)
|
||||
assert_equals(res.headers.get("x-request-val2"), expectedVal2)
|
||||
assert_equals(res.headers.get("x-request-val3"), expectedVal3)
|
||||
})
|
||||
}
|
||||
}, "fetch() with value " + encodeURI(val))
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,59 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf8>
|
||||
<meta name=timeout content=long>
|
||||
<title>Header value test</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
// Invalid values
|
||||
[0, 0x0A, 0x0D].forEach(val => {
|
||||
val = "x" + String.fromCharCode(val) + "x"
|
||||
test(() => {
|
||||
let xhr = new XMLHttpRequest()
|
||||
xhr.open("POST", "/")
|
||||
assert_throws("SyntaxError", () => xhr.setRequestHeader("value-test", val))
|
||||
}, "XMLHttpRequest with value " + encodeURI(val) + " needs to throw")
|
||||
|
||||
promise_test(t => promise_rejects(t, new TypeError(), fetch("about:blank", { headers: {"value-test": val} })), "fetch() with value " + encodeURI(val) + " needs to throw")
|
||||
})
|
||||
|
||||
// Valid values
|
||||
let headerValues =[]
|
||||
for(let i = 0; i < 0x100; i++) {
|
||||
if(i === 0 || i === 0x0A || i === 0x0D) {
|
||||
continue
|
||||
}
|
||||
headerValues.push("x" + String.fromCharCode(i) + "x")
|
||||
}
|
||||
var url = "../resources/inspect-headers.py?headers="
|
||||
headerValues.forEach((_, i) => {
|
||||
url += "val" + i + "|"
|
||||
})
|
||||
|
||||
async_test((t) => {
|
||||
let xhr = new XMLHttpRequest()
|
||||
xhr.open("POST", url)
|
||||
headerValues.forEach((val, i) => {
|
||||
xhr.setRequestHeader("val" + i, val)
|
||||
})
|
||||
xhr.onload = t.step_func_done(() => {
|
||||
headerValues.forEach((val, i) => {
|
||||
assert_equals(xhr.getResponseHeader("x-request-val" + i), val)
|
||||
})
|
||||
})
|
||||
xhr.send()
|
||||
}, "XMLHttpRequest with all valid values")
|
||||
|
||||
promise_test((t) => {
|
||||
const headers = new Headers
|
||||
headerValues.forEach((val, i) => {
|
||||
headers.append("val" + i, val)
|
||||
})
|
||||
return fetch(url, { headers }).then((res) => {
|
||||
headerValues.forEach((val, i) => {
|
||||
assert_equals(res.headers.get("x-request-val" + i), val)
|
||||
})
|
||||
})
|
||||
}, "fetch() with all valid values")
|
||||
</script>
|
|
@ -69,11 +69,12 @@
|
|||
}, "Create headers with existing headers");
|
||||
|
||||
test(function() {
|
||||
var headers = new Headers({test:"test"});
|
||||
var headers2 = new Headers()
|
||||
headers2[Symbol.iterator] = headers[Symbol.iterator]
|
||||
var headers3 = new Headers(headers2)
|
||||
assert_equals(headers3.get("test"), "test")
|
||||
var headers = new Headers()
|
||||
headers[Symbol.iterator] = function *() {
|
||||
yield ["test", "test"]
|
||||
}
|
||||
var headers2 = new Headers(headers)
|
||||
assert_equals(headers2.get("test"), "test")
|
||||
}, "Create headers with existing headers with custom iterator");
|
||||
|
||||
test(function() {
|
||||
|
|
|
@ -16,7 +16,11 @@ promise_test(function(test) {
|
|||
|
||||
promise_test(function(test) {
|
||||
var referrerUrl = "http://{{domains[www]}}:{{ports[http][0]}}/";
|
||||
return promise_rejects(test, new TypeError(), fetch(fetchedUrl, { "referrer": referrerUrl}));
|
||||
}, "Throw a TypeError referrer is not same-origin with origin");
|
||||
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");
|
||||
assert_equals(resp.headers.get("x-request-referer"), referrerOrigin, "request's referrer is " + referrerOrigin);
|
||||
});
|
||||
}, "Cross-origin referrer is overridden by client origin");
|
||||
|
||||
done();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch in worker: rediraction loop</title>
|
||||
<meta name="timeout" content="long">
|
||||
<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>
|
||||
|
@ -13,4 +14,4 @@
|
|||
fetch_tests_from_worker(new Worker("redirect-count.js"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch: redirection loop</title>
|
||||
<meta name="timeout" content="long">
|
||||
<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>
|
||||
|
@ -13,4 +14,4 @@
|
|||
<script src="../resources/utils.js"></script>
|
||||
<script src="redirect-count.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch in worker: redirect referrer 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">
|
||||
<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("redirect-referrer.js"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,18 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fetch: redirect referrer 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">
|
||||
<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="../resources/utils.js"></script>
|
||||
<script src="/common/get-host-info.sub.js"></script>
|
||||
<script src="redirect-referrer.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,68 @@
|
|||
if (this.document === undefined) {
|
||||
importScripts("/common/utils.js");
|
||||
importScripts("/resources/testharness.js");
|
||||
importScripts("../resources/utils.js");
|
||||
importScripts("/common/get-host-info.sub.js");
|
||||
}
|
||||
|
||||
function testReferrerAfterRedirection(desc, redirectUrl, redirectLocation, referrerPolicy, redirectReferrerPolicy, expectedReferrer) {
|
||||
var url = redirectUrl;
|
||||
var urlParameters = "?location=" + encodeURIComponent(redirectLocation);
|
||||
|
||||
if (redirectReferrerPolicy)
|
||||
urlParameters += "&redirect_referrerpolicy=" + redirectReferrerPolicy;
|
||||
|
||||
var requestInit = {"redirect": "follow", "referrerPolicy": referrerPolicy};
|
||||
|
||||
promise_test(function(test) {
|
||||
return fetch(url + urlParameters, requestInit).then(function(response) {
|
||||
assert_equals(response.status, 200, "Inspect header response's status is 200");
|
||||
assert_equals(response.headers.get("x-request-referer"), expectedReferrer ? expectedReferrer : null, "Check referrer header");
|
||||
});
|
||||
}, desc);
|
||||
}
|
||||
|
||||
var referrerOrigin = get_host_info().HTTP_ORIGIN + "/";
|
||||
var referrerUrl = location.href;
|
||||
|
||||
var redirectUrl = RESOURCES_DIR + "redirect.py";
|
||||
var locationUrl = get_host_info().HTTP_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?headers=referer";
|
||||
var crossLocationUrl = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "inspect-headers.py?cors&headers=referer";
|
||||
|
||||
testReferrerAfterRedirection("Same origin redirection, empty init, unsafe-url redirect header ", redirectUrl, locationUrl, "", "unsafe-url", referrerUrl);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty init, no-referrer-when-downgrade redirect header ", redirectUrl, locationUrl, "", "no-referrer-when-downgrade", referrerUrl);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty init, same-origin redirect header ", redirectUrl, locationUrl, "", "same-origin", referrerUrl);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty init, origin redirect header ", redirectUrl, locationUrl, "", "origin", referrerOrigin);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty init, origin-when-cross-origin redirect header ", redirectUrl, locationUrl, "", "origin-when-cross-origin", referrerUrl);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty init, no-referrer redirect header ", redirectUrl, locationUrl, "", "no-referrer", null);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty init, strict-origin redirect header ", redirectUrl, locationUrl, "", "strict-origin", referrerOrigin);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty init, strict-origin-when-cross-origin redirect header ", redirectUrl, locationUrl, "", "strict-origin-when-cross-origin", referrerUrl);
|
||||
|
||||
testReferrerAfterRedirection("Same origin redirection, empty redirect header, unsafe-url init ", redirectUrl, locationUrl, "unsafe-url", "", referrerUrl);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty redirect header, no-referrer-when-downgrade init ", redirectUrl, locationUrl, "no-referrer-when-downgrade", "", referrerUrl);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty redirect header, same-origin init ", redirectUrl, locationUrl, "same-origin", "", referrerUrl);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty redirect header, origin init ", redirectUrl, locationUrl, "origin", "", referrerOrigin);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty redirect header, origin-when-cross-origin init ", redirectUrl, locationUrl, "origin-when-cross-origin", "", referrerUrl);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty redirect header, no-referrer init ", redirectUrl, locationUrl, "no-referrer", "", null);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty redirect header, strict-origin init ", redirectUrl, locationUrl, "strict-origin", "", referrerOrigin);
|
||||
testReferrerAfterRedirection("Same origin redirection, empty redirect header, strict-origin-when-cross-origin init ", redirectUrl, locationUrl, "strict-origin-when-cross-origin", "", referrerUrl);
|
||||
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty init, unsafe-url redirect header ", redirectUrl, crossLocationUrl, "", "unsafe-url", referrerUrl);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty init, no-referrer-when-downgrade redirect header ", redirectUrl, crossLocationUrl, "", "no-referrer-when-downgrade", referrerUrl);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty init, same-origin redirect header ", redirectUrl, crossLocationUrl, "", "same-origin", null);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty init, origin redirect header ", redirectUrl, crossLocationUrl, "", "origin", referrerOrigin);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty init, origin-when-cross-origin redirect header ", redirectUrl, crossLocationUrl, "", "origin-when-cross-origin", referrerOrigin);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty init, no-referrer redirect header ", redirectUrl, crossLocationUrl, "", "no-referrer", null);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty init, strict-origin redirect header ", redirectUrl, crossLocationUrl, "", "strict-origin", referrerOrigin);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty init, strict-origin-when-cross-origin redirect header ", redirectUrl, crossLocationUrl, "", "strict-origin-when-cross-origin", referrerOrigin);
|
||||
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty redirect header, unsafe-url init ", redirectUrl, crossLocationUrl, "unsafe-url", "", referrerUrl);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty redirect header, no-referrer-when-downgrade init ", redirectUrl, crossLocationUrl, "no-referrer-when-downgrade", "", referrerUrl);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty redirect header, same-origin init ", redirectUrl, crossLocationUrl, "same-origin", "", null);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty redirect header, origin init ", redirectUrl, crossLocationUrl, "origin", "", referrerOrigin);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty redirect header, origin-when-cross-origin init ", redirectUrl, crossLocationUrl, "origin-when-cross-origin", "", referrerOrigin);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty redirect header, no-referrer init ", redirectUrl, crossLocationUrl, "no-referrer", "", null);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty redirect header, strict-origin init ", redirectUrl, crossLocationUrl, "strict-origin", "", referrerOrigin);
|
||||
testReferrerAfterRedirection("Cross origin redirection, empty redirect header, strict-origin-when-cross-origin init ", redirectUrl, crossLocationUrl, "strict-origin-when-cross-origin", "", referrerOrigin);
|
||||
|
||||
done();
|
|
@ -16,8 +16,17 @@
|
|||
};
|
||||
|
||||
var noBodyConsumed = new Request("");
|
||||
noBodyConsumed.blob();
|
||||
var bodyConsumed = new Request("", initValuesDict);
|
||||
|
||||
test(() => {
|
||||
assert_equals(noBodyConsumed.body, null, "body's default value is null");
|
||||
assert_false(noBodyConsumed.bodyUsed , "bodyUsed is false when request is not disturbed");
|
||||
assert_not_equals(bodyConsumed.body, null, "non-null body");
|
||||
assert_true(bodyConsumed.body instanceof ReadableStream, "non-null body type");
|
||||
assert_false(noBodyConsumed.bodyUsed, "bodyUsed is false when request is not disturbed");
|
||||
}, "Request's body: initial state");
|
||||
|
||||
noBodyConsumed.blob();
|
||||
bodyConsumed.blob();
|
||||
|
||||
test(function() {
|
||||
|
@ -39,13 +48,37 @@
|
|||
assert_throws(new TypeError(), function() { new Request(bodyConsumed); });
|
||||
}, "Check creating a new request from a disturbed request");
|
||||
|
||||
test(function() {
|
||||
promise_test(function() {
|
||||
var bodyRequest = new Request("", initValuesDict);
|
||||
const originalBody = bodyRequest.body;
|
||||
assert_false(bodyRequest.bodyUsed , "bodyUsed is false when request is not disturbed");
|
||||
var requestFromRequest = new Request(bodyRequest);
|
||||
assert_true(bodyRequest.bodyUsed , "bodyUsed is true when request is disturbed");
|
||||
assert_equals(bodyRequest.body, originalBody, "body should not change");
|
||||
assert_not_equals(originalBody, undefined, "body should not be undefined");
|
||||
assert_not_equals(originalBody, null, "body should not be null");
|
||||
assert_not_equals(requestFromRequest.body, originalBody, "new request's body is new");
|
||||
return requestFromRequest.text(text => {
|
||||
assert_equals(text, "Request's body");
|
||||
});
|
||||
}, "Input request used for creating new request became disturbed");
|
||||
|
||||
promise_test(() => {
|
||||
const bodyRequest = new Request("", initValuesDict);
|
||||
const originalBody = bodyRequest.body;
|
||||
assert_false(bodyRequest.bodyUsed , "bodyUsed is false when request is not disturbed");
|
||||
const requestFromRequest = new Request(bodyRequest, { body : "init body" });
|
||||
assert_true(bodyRequest.bodyUsed , "bodyUsed is true when request is disturbed");
|
||||
assert_equals(bodyRequest.body, originalBody, "body should not change");
|
||||
assert_not_equals(originalBody, undefined, "body should not be undefined");
|
||||
assert_not_equals(originalBody, null, "body should not be null");
|
||||
assert_not_equals(requestFromRequest.body, originalBody, "new request's body is new");
|
||||
|
||||
return requestFromRequest.text(text => {
|
||||
assert_equals(text, "init body");
|
||||
});
|
||||
}, "Input request used for creating new request became disturbed even if body is not used");
|
||||
|
||||
promise_test(function(test) {
|
||||
assert_true(bodyConsumed.bodyUsed , "bodyUsed is true when request is disturbed");
|
||||
return promise_rejects(test, new TypeError(), bodyConsumed.blob());
|
||||
|
|
|
@ -26,21 +26,11 @@
|
|||
"Expect TypeError exception");
|
||||
},"Input URL has credentials");
|
||||
|
||||
test(function() {
|
||||
assert_throws(new TypeError() , function() { new Request("", {"mode" : "navigate"}); },
|
||||
"Expect TypeError exception");
|
||||
},"RequestInit's mode is navigate");
|
||||
|
||||
test(function() {
|
||||
assert_throws(new TypeError() , function() { new Request("", {"referrer" : "http://:not a valid URL"}); },
|
||||
"Expect TypeError exception");
|
||||
},"RequestInit's referrer is invalid");
|
||||
|
||||
test(function() {
|
||||
assert_throws(new TypeError() , function() { new Request("", {"referrer" : "http://test.url"}); },
|
||||
"Expect TypeError exception");
|
||||
},"RequestInit's referrer has invalid origin")
|
||||
|
||||
test(function() {
|
||||
assert_throws(new TypeError() , function() { new Request("", {"method" : "IN VALID"}); },
|
||||
"Expect TypeError exception");
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
[NoInterfaceObject,
|
||||
Exposed=(Window,Worker)]
|
||||
interface Body {
|
||||
readonly attribute ReadableStream? body;
|
||||
readonly attribute boolean bodyUsed;
|
||||
[NewObject] Promise<ArrayBuffer> arrayBuffer();
|
||||
[NewObject] Promise<Blob> blob();
|
||||
|
@ -70,7 +71,11 @@
|
|||
enum RequestCredentials { "omit", "same-origin", "include" };
|
||||
enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" };
|
||||
enum RequestRedirect { "follow", "error", "manual" };
|
||||
enum ReferrerPolicy { "", "no-referrer", "no-referrer-when-downgrade", "origin-only", "origin-when-cross-origin", "unsafe-url" };
|
||||
enum ReferrerPolicy {
|
||||
"", "no-referrer", "no-referrer-when-downgrade", "origin",
|
||||
"origin-when-cross-origin", "unsafe-url", "same-origin", "strict-origin",
|
||||
"strict-origin-when-cross-origin"
|
||||
};
|
||||
</script>
|
||||
<script>
|
||||
var idlsArray = new IdlArray();
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
var referrers = {"givenValues" : ["/relative/ressource",
|
||||
"http://{{host}}:{{ports[http][0]}}/relative/ressource?query=true#fragment",
|
||||
"http://{{host}}:{{ports[http][0]}}/",
|
||||
"http://test.url",
|
||||
"about:client",
|
||||
""
|
||||
],
|
||||
|
@ -23,6 +24,7 @@
|
|||
"http://{{host}}:{{ports[http][0]}}/relative/ressource?query=true#fragment",
|
||||
"http://{{host}}:{{ports[http][0]}}/",
|
||||
"about:client",
|
||||
"about:client",
|
||||
""
|
||||
]
|
||||
};
|
||||
|
@ -31,18 +33,24 @@
|
|||
"no-referrer-when-downgrade",
|
||||
"origin",
|
||||
"origin-when-cross-origin",
|
||||
"unsafe-url"
|
||||
"unsafe-url",
|
||||
"same-origin",
|
||||
"strict-origin",
|
||||
"strict-origin-when-cross-origin"
|
||||
],
|
||||
"expectedValues" : ["",
|
||||
"no-referrer",
|
||||
"no-referrer-when-downgrade",
|
||||
"origin",
|
||||
"origin-when-cross-origin",
|
||||
"unsafe-url"
|
||||
"unsafe-url",
|
||||
"same-origin",
|
||||
"strict-origin",
|
||||
"strict-origin-when-cross-origin"
|
||||
]
|
||||
};
|
||||
var modes = {"givenValues" : ["same-origin", "no-cors", "cors"],
|
||||
"expectedValues" : ["same-origin", "no-cors", "cors"]
|
||||
var modes = {"givenValues" : ["same-origin", "no-cors", "cors", "navigate"],
|
||||
"expectedValues" : ["same-origin", "no-cors", "cors", "same-origin"]
|
||||
};
|
||||
var credentials = {"givenValues" : ["omit", "same-origin", "include"],
|
||||
"expectedValues" : ["omit", "same-origin", "include"]
|
||||
|
|
|
@ -14,7 +14,7 @@ def main(request, response):
|
|||
return "ERROR: No access-control-request-method in preflight!"
|
||||
|
||||
if "control_request_headers" in request.GET:
|
||||
stashed_data['control_request_headers'] = request.headers.get("Access-Control-Request-Headers", "")
|
||||
stashed_data['control_request_headers'] = request.headers.get("Access-Control-Request-Headers", None)
|
||||
|
||||
if "max_age" in request.GET:
|
||||
headers.append(("Access-Control-Max-Age", request.GET['max_age']))
|
||||
|
@ -45,7 +45,8 @@ def main(request, response):
|
|||
#use x-* headers for returning value to bodyless responses
|
||||
headers.append(("Access-Control-Expose-Headers", "x-did-preflight, x-control-request-headers, x-referrer, x-preflight-referrer, x-origin"))
|
||||
headers.append(("x-did-preflight", stashed_data['preflight']))
|
||||
headers.append(("x-control-request-headers", stashed_data['control_request_headers']))
|
||||
if stashed_data['control_request_headers'] != None:
|
||||
headers.append(("x-control-request-headers", stashed_data['control_request_headers']))
|
||||
headers.append(("x-preflight-referrer", stashed_data['preflight_referrer']))
|
||||
headers.append(("x-referrer", request.headers.get("Referer", "") ))
|
||||
headers.append(("x-origin", request.headers.get("Origin", "") ))
|
||||
|
|
|
@ -45,6 +45,9 @@ def main(request, response):
|
|||
url += "&count=" + str(stashed_data['count'])
|
||||
headers.append(("Location", url))
|
||||
|
||||
if "redirect_referrerpolicy" in request.GET:
|
||||
headers.append(("Referrer-Policy", request.GET['redirect_referrerpolicy']))
|
||||
|
||||
if token:
|
||||
request.server.stash.put(request.GET.first("token"), stashed_data)
|
||||
if "max_count" in request.GET:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
[NoInterfaceObject,
|
||||
Exposed=(Window,Worker)]
|
||||
interface Body {
|
||||
readonly attribute ReadableStream? body;
|
||||
readonly attribute boolean bodyUsed;
|
||||
[NewObject] Promise<ArrayBuffer> arrayBuffer();
|
||||
[NewObject] Promise<Blob> blob();
|
||||
|
@ -40,7 +41,6 @@
|
|||
readonly attribute boolean ok;
|
||||
readonly attribute ByteString statusText;
|
||||
[SameObject] readonly attribute Headers headers;
|
||||
readonly attribute ReadableStream? body;
|
||||
|
||||
[NewObject] Response clone();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue