File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,11 @@ class Blob {
360
360
queueMicrotask ( ( ) => {
361
361
if ( c . desiredSize <= 0 ) {
362
362
// A manual backpressure check.
363
+ if ( this . pendingPulls . length !== 0 ) {
364
+ // A case of waiting pull finished (= not yet canceled)
365
+ const pending = this . pendingPulls . shift ( ) ;
366
+ pending . resolve ( ) ;
367
+ }
363
368
return ;
364
369
}
365
370
readNext ( ) ;
Original file line number Diff line number Diff line change @@ -269,6 +269,29 @@ assert.throws(() => new Blob({}), {
269
269
reader . closed . then ( common . mustCall ( ) ) ;
270
270
} ) ( ) . then ( common . mustCall ( ) ) ;
271
271
272
+ ( async ( ) => {
273
+ const b = new Blob ( [ 'A' , 'B' , 'C' ] ) ;
274
+ const stream = b . stream ( ) ;
275
+ const chunks = [ ] ;
276
+ const decoder = new TextDecoder ( ) ;
277
+ await stream . pipeTo ( new WritableStream ( {
278
+ write ( chunk ) {
279
+ chunks . push ( decoder . decode ( chunk , { stream : true } ) ) ;
280
+ }
281
+ } ) ) ;
282
+ assert . strictEqual ( chunks . join ( '' ) , 'ABC' ) ;
283
+ } ) ( ) . then ( common . mustCall ( ) ) ;
284
+
285
+ ( async ( ) => {
286
+ const file = new Blob ( [ '<svg></svg>' ] , { type : 'image/svg+xml' } ) ;
287
+ const url = URL . createObjectURL ( file ) ;
288
+ const res = await fetch ( url ) ;
289
+ const blob = await res . blob ( ) ;
290
+ assert . strictEqual ( blob . size , 11 ) ;
291
+ assert . strictEqual ( blob . type , 'image/svg+xml' ) ;
292
+ assert . strictEqual ( await blob . text ( ) , '<svg></svg>' ) ;
293
+ } ) ( ) . then ( common . mustCall ( ) ) ;
294
+
272
295
( async ( ) => {
273
296
const b = new Blob ( Array ( 10 ) . fill ( 'hello' ) ) ;
274
297
const stream = b . stream ( ) ;
You can’t perform that action at this time.
0 commit comments