From 7cbcf3efcc5df419361c9687ebdc4501e6075fa9 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Sun, 16 Aug 2020 00:38:44 +0000 Subject: [PATCH] Bug 1645251 [wpt PR 24124] - Add test for canceling one branch when stream closes or errors, a=testonly Automatic update from web-platform-tests Test canceling one branch when stream closes or errors Follows https://github.com/whatwg/streams/pull/1039. -- wpt-commits: e5e5e7a10cbb968b31c51ad87ce8a3da62bb1b34 wpt-pr: 24124 UltraBlame original commit: d835b5e68f7177a62bd9782ba6447e786ddac6c9 --- .../tests/streams/readable-streams/tee.any.js | 300 ++++++++++++++++++ 1 file changed, 300 insertions(+) diff --git a/testing/web-platform/tests/streams/readable-streams/tee.any.js b/testing/web-platform/tests/streams/readable-streams/tee.any.js index 39b84000582a9..d220a5b831b9c 100644 --- a/testing/web-platform/tests/streams/readable-streams/tee.any.js +++ b/testing/web-platform/tests/streams/readable-streams/tee.any.js @@ -2093,6 +2093,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