Skip to content

Commit

Permalink
Bug 1645251 [wpt PR 24124] - Add test for canceling one branch when s…
Browse files Browse the repository at this point in the history
…tream closes or errors, a=testonly

Automatic update from web-platform-tests
Test canceling one branch when stream closes or errors

Follows whatwg/streams#1039.
--

wpt-commits: e5e5e7a10cbb968b31c51ad87ce8a3da62bb1b34
wpt-pr: 24124

UltraBlame original commit: d835b5e68f7177a62bd9782ba6447e786ddac6c9
  • Loading branch information
marco-c committed Aug 16, 2020
1 parent a6df113 commit eb7cc76
Showing 1 changed file with 300 additions and 0 deletions.
300 changes: 300 additions & 0 deletions testing/web-platform/tests/streams/readable-streams/tee.any.js
Expand Up @@ -2178,6 +2178,306 @@ branches
'
)
;
promise_test
(
async
t
=
>
{
let
controller
;
const
rs
=
new
ReadableStream
(
{
start
(
c
)
{
controller
=
c
;
}
}
)
;
const
[
reader1
reader2
]
=
rs
.
tee
(
)
.
map
(
branch
=
>
branch
.
getReader
(
)
)
;
const
cancelPromise
=
reader2
.
cancel
(
)
;
controller
.
enqueue
(
'
a
'
)
;
const
read1
=
await
reader1
.
read
(
)
;
assert_object_equals
(
read1
{
value
:
'
a
'
done
:
false
}
'
first
read
(
)
from
branch1
should
fulfill
with
the
chunk
'
)
;
controller
.
close
(
)
;
const
read2
=
await
reader1
.
read
(
)
;
assert_object_equals
(
read2
{
value
:
undefined
done
:
true
}
'
second
read
(
)
from
branch1
should
be
done
'
)
;
await
Promise
.
all
(
[
reader1
.
closed
cancelPromise
]
)
;
}
'
ReadableStream
teeing
:
canceling
branch1
should
finish
when
branch2
reads
until
end
of
stream
'
)
;
promise_test
(
async
t
=
>
{
let
controller
;
const
theError
=
{
name
:
'
boo
!
'
}
;
const
rs
=
new
ReadableStream
(
{
start
(
c
)
{
controller
=
c
;
}
}
)
;
const
[
reader1
reader2
]
=
rs
.
tee
(
)
.
map
(
branch
=
>
branch
.
getReader
(
)
)
;
const
cancelPromise
=
reader2
.
cancel
(
)
;
controller
.
error
(
theError
)
;
await
Promise
.
all
(
[
promise_rejects_exactly
(
t
theError
reader1
.
read
(
)
)
cancelPromise
]
)
;
}
'
ReadableStream
teeing
:
canceling
branch1
should
finish
when
original
stream
errors
'
)
;
test
(
t
Expand Down

0 comments on commit eb7cc76

Please sign in to comment.