mirror of
https://github.com/servo/servo.git
synced 2025-09-01 10:38:25 +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
|
@ -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