mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
|
@ -12,7 +12,6 @@
|
|||
<body>
|
||||
<script src="../resources/utils.js"></script>
|
||||
<script>
|
||||
|
||||
promise_test(function(test) {
|
||||
return new Response(new Blob([], { "type" : "text/plain" })).body.cancel();
|
||||
}, "Cancelling a starting blob Response stream");
|
||||
|
@ -51,16 +50,19 @@ promise_test(function() {
|
|||
}, "Cancelling a loading Response stream");
|
||||
|
||||
promise_test(function() {
|
||||
async function readAll(reader) {
|
||||
while (true) {
|
||||
const {value, done} = await reader.read();
|
||||
if (done)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return fetch(RESOURCES_DIR + "top.txt").then(function(response) {
|
||||
var reader = response.body.getReader();
|
||||
var closedPromise = reader.closed.then(function() {
|
||||
return reader.cancel();
|
||||
});
|
||||
reader.read();
|
||||
return closedPromise;
|
||||
return readAll(reader).then(() => reader.cancel());
|
||||
});
|
||||
}, "Cancelling a closed Response stream");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -57,15 +57,16 @@ promise_test(function(test) {
|
|||
|
||||
promise_test(function(test) {
|
||||
var response = new Response(formData);
|
||||
return validateStreamFromString(response.body.getReader(), "name=value");
|
||||
return validateStreamFromPartialString(response.body.getReader(),
|
||||
"Content-Disposition: form-data; name=\"name\"\r\n\r\nvalue");
|
||||
}, "Read form data response's body as readableStream");
|
||||
|
||||
test(function() {
|
||||
assert_equals(Response.error().body, null);
|
||||
}, "Getting an error Response stream");
|
||||
|
||||
promise_test(function(test) {
|
||||
assert_equals(Response.redirect(301).body, null);
|
||||
test(function() {
|
||||
assert_equals(Response.redirect("/").body, null);
|
||||
}, "Getting a redirect Response stream");
|
||||
|
||||
</script>
|
||||
|
|
|
@ -58,6 +58,19 @@
|
|||
"Expect response.ok is " + isOkStatus(response.status));
|
||||
}
|
||||
}, "Check " + attributeName + " init values and associated getter");
|
||||
|
||||
test(function() {
|
||||
const response1 = new Response("");
|
||||
assert_equals(response1.headers, response1.headers);
|
||||
|
||||
const response2 = new Response("", {"headers": {"X-Foo": "bar"}});
|
||||
assert_equals(response2.headers, response2.headers);
|
||||
const headers = response2.headers;
|
||||
response2.headers.set("X-Foo", "quux");
|
||||
assert_equals(headers, response2.headers);
|
||||
headers.set("X-Other-Header", "baz");
|
||||
assert_equals(headers, response2.headers);
|
||||
}, "Test that Response.headers has the [SameObject] extended attribute");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>ReadableStream disturbed tests, via Response's bodyUsed property</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
<link rel="author" title="Takeshi Yoshino" href="mailto:tyoshino@chromium.org">
|
||||
|
||||
<link rel="help" href="https://streams.spec.whatwg.org/#is-readable-stream-disturbed">
|
||||
<link rel="help" href="https://fetch.spec.whatwg.org/#dom-body-bodyused">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
test(() => {
|
||||
const stream = new ReadableStream();
|
||||
const response = new Response(stream);
|
||||
assert_false(response.bodyUsed, "On construction");
|
||||
|
||||
const reader = stream.getReader();
|
||||
assert_false(response.bodyUsed, "After getting a reader");
|
||||
|
||||
reader.read();
|
||||
assert_true(response.bodyUsed, "After calling stream.read()");
|
||||
}, "A non-closed stream on which read() has been called");
|
||||
|
||||
test(() => {
|
||||
const stream = new ReadableStream();
|
||||
const response = new Response(stream);
|
||||
assert_false(response.bodyUsed, "On construction");
|
||||
|
||||
const reader = stream.getReader();
|
||||
assert_false(response.bodyUsed, "After getting a reader");
|
||||
|
||||
reader.cancel();
|
||||
assert_true(response.bodyUsed, "After calling stream.cancel()");
|
||||
}, "A non-closed stream on which cancel() has been called");
|
||||
|
||||
test(() => {
|
||||
const stream = new ReadableStream({
|
||||
start(c) {
|
||||
c.close();
|
||||
}
|
||||
});
|
||||
const response = new Response(stream);
|
||||
assert_false(response.bodyUsed, "On construction");
|
||||
|
||||
const reader = stream.getReader();
|
||||
assert_false(response.bodyUsed, "After getting a reader");
|
||||
|
||||
reader.read();
|
||||
assert_true(response.bodyUsed, "After calling stream.read()");
|
||||
}, "A closed stream on which read() has been called");
|
||||
|
||||
test(() => {
|
||||
const stream = new ReadableStream({
|
||||
start(c) {
|
||||
c.error(new Error("some error"));
|
||||
}
|
||||
});
|
||||
const response = new Response(stream);
|
||||
assert_false(response.bodyUsed, "On construction");
|
||||
|
||||
const reader = stream.getReader();
|
||||
assert_false(response.bodyUsed, "After getting a reader");
|
||||
|
||||
reader.read();
|
||||
assert_true(response.bodyUsed, "After calling stream.read()");
|
||||
}, "An errored stream on which read() has been called");
|
||||
|
||||
test(() => {
|
||||
const stream = new ReadableStream({
|
||||
start(c) {
|
||||
c.error(new Error("some error"));
|
||||
}
|
||||
});
|
||||
const response = new Response(stream);
|
||||
assert_false(response.bodyUsed, "On construction");
|
||||
|
||||
const reader = stream.getReader();
|
||||
assert_false(response.bodyUsed, "After getting a reader");
|
||||
|
||||
reader.cancel();
|
||||
assert_true(response.bodyUsed, "After calling stream.cancel()");
|
||||
}, "An errored stream on which cancel() has been called");
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue