Skip to content

Commit 4602fd1

Browse files
committed
Streams: new test failure for canceling the branches of an errored tee'd stream
https://bugs.webkit.org/show_bug.cgi?id=223558 <rdar://problem/75924807> Reviewed by Alex Christensen. LayoutTests/imported/w3c: Rebased from WPT ToT. * web-platform-tests/streams/readable-streams/tee.any-expected.txt: * web-platform-tests/streams/readable-streams/tee.any.js: (promise_test.async const): (promise_test): (promise_test.async t): * web-platform-tests/streams/readable-streams/tee.any.worker-expected.txt: Source/WebCore: Align with latest version of the spec. Covered by updated test. * Modules/streams/ReadableStreamInternals.js: (readableStreamTee): (readableStreamTeePullFunction): Canonical link: https://commits.webkit.org/236303@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275667 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent fe736f9 commit 4602fd1

6 files changed

Lines changed: 83 additions & 6 deletions

File tree

LayoutTests/imported/w3c/ChangeLog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2021-04-08 Youenn Fablet <youenn@apple.com>
2+
3+
Streams: new test failure for canceling the branches of an errored tee'd stream
4+
https://bugs.webkit.org/show_bug.cgi?id=223558
5+
<rdar://problem/75924807>
6+
7+
Reviewed by Alex Christensen.
8+
9+
Rebased from WPT ToT.
10+
11+
* web-platform-tests/streams/readable-streams/tee.any-expected.txt:
12+
* web-platform-tests/streams/readable-streams/tee.any.js:
13+
(promise_test.async const):
14+
(promise_test):
15+
(promise_test.async t):
16+
* web-platform-tests/streams/readable-streams/tee.any.worker-expected.txt:
17+
118
2021-04-06 Zalan Bujtas <zalan@apple.com>
219

320
[LFC][Integration] Enable inline box support (RenderInline)

LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/tee.any-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ PASS ReadableStream teeing: closing the original should immediately close the br
2323
PASS ReadableStream teeing: erroring the original should immediately error the branches
2424
PASS ReadableStream teeing: canceling branch1 should finish when branch2 reads until end of stream
2525
PASS ReadableStream teeing: canceling branch1 should finish when original stream errors
26+
PASS ReadableStream teeing: canceling both branches in sequence with delay
27+
PASS ReadableStream teeing: failing to cancel when canceling both branches in sequence with delay
2628
PASS ReadableStreamTee should not use a modified ReadableStream constructor from the global object
2729
FAIL ReadableStreamTee should not pull more chunks than can fit in the branch queue assert_array_equals: pull should only be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2
2830
FAIL ReadableStreamTee should only pull enough to fill the emptiest queue assert_array_equals: pull should be called twice lengths differ, expected array ["pull", "pull"] length 2, got ["pull", "pull", "pull", "pull"] length 4

LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/tee.any.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,19 @@ promise_test(t => {
232232

233233
}, 'ReadableStream teeing: failing to cancel the original stream should cause cancel() to reject on branches');
234234

235-
test(() => {
235+
promise_test(t => {
236236

237+
const theError = { name: 'You just watch yourself!' };
237238
let controller;
238239
const stream = new ReadableStream({ start(c) { controller = c; } });
239240
const [branch1, branch2] = stream.tee();
240241

241-
controller.error("error");
242+
controller.error(theError);
242243

243-
branch1.cancel().catch(_=>_);
244-
branch2.cancel().catch(_=>_);
244+
return Promise.all([
245+
promise_rejects_exactly(t, theError, branch1.cancel()),
246+
promise_rejects_exactly(t, theError, branch2.cancel())
247+
]);
245248

246249
}, 'ReadableStream teeing: erroring a teed stream should properly handle canceled branches');
247250

@@ -368,6 +371,42 @@ promise_test(async t => {
368371

369372
}, 'ReadableStream teeing: canceling branch1 should finish when original stream errors');
370373

374+
promise_test(async () => {
375+
376+
const rs = new ReadableStream({});
377+
378+
const [branch1, branch2] = rs.tee();
379+
380+
const cancel1 = branch1.cancel();
381+
await flushAsyncEvents();
382+
const cancel2 = branch2.cancel();
383+
384+
await Promise.all([cancel1, cancel2]);
385+
386+
}, 'ReadableStream teeing: canceling both branches in sequence with delay');
387+
388+
promise_test(async t => {
389+
390+
const theError = { name: 'boo!' };
391+
const rs = new ReadableStream({
392+
cancel() {
393+
throw theError;
394+
}
395+
});
396+
397+
const [branch1, branch2] = rs.tee();
398+
399+
const cancel1 = branch1.cancel();
400+
await flushAsyncEvents();
401+
const cancel2 = branch2.cancel();
402+
403+
await Promise.all([
404+
promise_rejects_exactly(t, theError, cancel1),
405+
promise_rejects_exactly(t, theError, cancel2)
406+
]);
407+
408+
}, 'ReadableStream teeing: failing to cancel when canceling both branches in sequence with delay');
409+
371410
test(t => {
372411

373412
// Copy original global.

LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/tee.any.worker-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PASS ReadableStream teeing: closing the original should immediately close the br
1616
PASS ReadableStream teeing: erroring the original should immediately error the branches
1717
PASS ReadableStream teeing: canceling branch1 should finish when branch2 reads until end of stream
1818
PASS ReadableStream teeing: canceling branch1 should finish when original stream errors
19+
PASS ReadableStream teeing: canceling both branches in sequence with delay
20+
PASS ReadableStream teeing: failing to cancel when canceling both branches in sequence with delay
1921
PASS ReadableStreamTee should not use a modified ReadableStream constructor from the global object
2022
FAIL ReadableStreamTee should not pull more chunks than can fit in the branch queue assert_array_equals: pull should only be called once lengths differ, expected array ["pull"] length 1, got ["pull", "pull"] length 2
2123
FAIL ReadableStreamTee should only pull enough to fill the emptiest queue assert_array_equals: pull should be called twice lengths differ, expected array ["pull", "pull"] length 2, got ["pull", "pull", "pull", "pull"] length 4

Source/WebCore/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2021-04-08 Youenn Fablet <youenn@apple.com>
2+
3+
Streams: new test failure for canceling the branches of an errored tee'd stream
4+
https://bugs.webkit.org/show_bug.cgi?id=223558
5+
<rdar://problem/75924807>
6+
7+
Reviewed by Alex Christensen.
8+
9+
Align with latest version of the spec.
10+
Covered by updated test.
11+
12+
* Modules/streams/ReadableStreamInternals.js:
13+
(readableStreamTee):
14+
(readableStreamTeePullFunction):
15+
116
2021-04-08 Andres Gonzalez <andresg_22@apple.com>
217

318
VoiceOver does not echo text insertions and deletions when a contenteditable div has a non editable descendant element with a content editable child

Source/WebCore/Modules/streams/ReadableStreamInternals.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ function readableStreamTee(stream, shouldClone)
424424
@readableStreamDefaultControllerError(branch1.@readableStreamController, e);
425425
@readableStreamDefaultControllerError(branch2.@readableStreamController, e);
426426
teeState.closedOrErrored = true;
427-
teeState.cancelPromiseCapability.@resolve.@call();
427+
if (!teeState.canceled1 || !teeState.canceled2)
428+
teeState.cancelPromiseCapability.@resolve.@call();
428429
});
429430

430431
// Additional fields compared to the spec, as they are needed within pull/cancel functions.
@@ -464,7 +465,8 @@ function readableStreamTeePullFunction(teeState, reader, shouldClone)
464465
if (!teeState.canceled2)
465466
@readableStreamDefaultControllerClose(teeState.branch2.@readableStreamController);
466467
teeState.closedOrErrored = true;
467-
teeState.cancelPromiseCapability.@resolve.@call();
468+
if (!teeState.canceled1 || !teeState.canceled2)
469+
teeState.cancelPromiseCapability.@resolve.@call();
468470
}
469471
if (teeState.closedOrErrored)
470472
return;

0 commit comments

Comments
 (0)