From 9cfa60db24ee38f9e74d87855e6763b8528e1850 Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:07:56 +0300 Subject: [PATCH] stream: fix test failures --- lib/internal/webstreams/readablestream.js | 17 +++++++++-------- lib/internal/webstreams/transformstream.js | 12 ++++++------ lib/internal/webstreams/writablestream.js | 13 ++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/internal/webstreams/readablestream.js b/lib/internal/webstreams/readablestream.js index 56dd2f31070dc9..0fe98299446c02 100644 --- a/lib/internal/webstreams/readablestream.js +++ b/lib/internal/webstreams/readablestream.js @@ -1021,7 +1021,7 @@ class ReadableStreamDefaultController { [kType] = 'ReadableStreamDefaultController'; constructor(skipThrowSymbol) { - if (new.target === ReadableStreamDefaultController || skipThrowSymbol !== kSkipThrow) { + if (skipThrowSymbol !== kSkipThrow) { throw new ERR_ILLEGAL_CONSTRUCTOR(); } } @@ -1079,12 +1079,13 @@ ObjectDefineProperties(ReadableStreamDefaultController.prototype, { [SymbolToStringTag]: getNonWritablePropertyDescriptor(ReadableStreamDefaultController.name), }); -class ReadableStreamDefaultControllerClazz extends ReadableStreamDefaultController { - constructor(skipThrowSymbol) { - super(skipThrowSymbol); - this[kType] = 'ReadableStreamDefaultController'; - this[kState] = {}; - } +function createReadableStreamDefaultController() { + const controller = new ReadableStreamDefaultController(kSkipThrow); + + controller[kType] = 'ReadableStreamDefaultController'; + controller[kState] = {}; + + return controller; } class ReadableByteStreamController { @@ -2415,7 +2416,7 @@ function setupReadableStreamDefaultControllerFromSource( source, highWaterMark, sizeAlgorithm) { - const controller = new ReadableStreamDefaultControllerClazz(kSkipThrow); + const controller = createReadableStreamDefaultController(); const start = source?.start; const pull = source?.pull; const cancel = source?.cancel; diff --git a/lib/internal/webstreams/transformstream.js b/lib/internal/webstreams/transformstream.js index 76780f12748b62..311f2ca50be66f 100644 --- a/lib/internal/webstreams/transformstream.js +++ b/lib/internal/webstreams/transformstream.js @@ -8,6 +8,7 @@ const { PromiseResolve, ReflectConstruct, SymbolToStringTag, + Symbol, } = primordials; const { @@ -334,11 +335,10 @@ ObjectDefineProperties(TransformStreamDefaultController.prototype, { [SymbolToStringTag]: getNonWritablePropertyDescriptor(TransformStreamDefaultController.name), }); -class TransformStreamDefaultControllerClazz extends TransformStreamDefaultController { - constructor(skipThrowSymbol) { - super(skipThrowSymbol); - this[kType] = 'TransformStreamDefaultController'; - } +function createTransformStreamDefaultController() { + const controller = new TransformStreamDefaultController(kSkipThrow); + controller[kType] = 'TransformStreamDefaultController'; + return controller; } const isTransformStream = @@ -455,7 +455,7 @@ function setupTransformStreamDefaultController( function setupTransformStreamDefaultControllerFromTransformer( stream, transformer) { - const controller = new TransformStreamDefaultControllerClazz(kSkipThrow); + const controller = createTransformStreamDefaultController(); const transform = transformer?.transform || defaultTransformAlgorithm; const flush = transformer?.flush || nonOpFlush; const transformAlgorithm = diff --git a/lib/internal/webstreams/writablestream.js b/lib/internal/webstreams/writablestream.js index 64de11a61a6280..0a83450fab4c2e 100644 --- a/lib/internal/webstreams/writablestream.js +++ b/lib/internal/webstreams/writablestream.js @@ -524,7 +524,7 @@ class WritableStreamDefaultController { [kType] = 'WritableStreamDefaultController'; constructor(skipThrowSymbol) { - if (new.target === WritableStreamDefaultController || skipThrowSymbol !== kSkipThrow) { + if (skipThrowSymbol !== kSkipThrow) { throw new ERR_ILLEGAL_CONSTRUCTOR(); } } @@ -572,11 +572,10 @@ ObjectDefineProperties(WritableStreamDefaultController.prototype, { [SymbolToStringTag]: getNonWritablePropertyDescriptor(WritableStreamDefaultController.name), }); -class WritableStreamDefaultControllerClazz extends WritableStreamDefaultController { - constructor(skipThrowSymbol) { - super(skipThrowSymbol); - this[kType] = 'WritableStreamDefaultController'; - } +function createWritableStreamDefaultController() { + const controller = new WritableStreamDefaultController(kSkipThrow); + controller[kType] = 'WritableStreamDefaultController'; + return controller; } const isWritableStream = @@ -1235,7 +1234,7 @@ function setupWritableStreamDefaultControllerFromSink( sink, highWaterMark, sizeAlgorithm) { - const controller = new WritableStreamDefaultControllerClazz(kSkipThrow); + const controller = createWritableStreamDefaultController(); const start = sink?.start; const write = sink?.write; const close = sink?.close;