Commit e33ce4df authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Update TransformStream to latest standard version

Update TransformStream to match the standard version
https://github.com/whatwg/streams/commit/7b8dffe8ec270bb918340e011349e2c1b5521a15.

Significant changes:

Method lookups are now cached at construction time. Changing
underlyingSink.write after construction will no longer do anything. This
is https://github.com/whatwg/streams/pull/860.

When the readable side is cancelled, the stored error on the writable side will
be set to the |reason| that was passed to cancel(), rather than a TypeError.
This is https://github.com/whatwg/streams/pull/903.

Bug: 780689, 820387

Change-Id: I33c59541eea1bfc5f96722bce750ba4fa7ff96ee
Reviewed-on: https://chromium-review.googlesource.com/964112Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545038}
parent 9e767b2f
This is a testharness.js-based test.
PASS TransformStream errors thrown in transform put the writable and readable in an errored state
PASS TransformStream errors thrown in flush put the writable and readable in an errored state
PASS errored TransformStream should not enqueue new chunks
PASS TransformStream transformer.start() rejected promise should error the stream
PASS when controller.error is followed by a rejection, the error reason should come from controller.error
PASS TransformStream constructor should throw when start does
PASS when strategy.size throws inside start(), the constructor should throw the same error
PASS when strategy.size calls controller.error() then throws, the constructor should throw the first error
PASS cancelling the readable side should error the writable
PASS it should be possible to error the readable between close requested and complete
PASS an exception from transform() should error the stream if terminate has been requested but not completed
PASS abort should set the close reason for the writable when it happens before cancel during start, but cancel should still succeed
PASS abort should set the close reason for the writable when it happens before cancel during underlying sink write, but cancel should still succeed
PASS controller.error() should do nothing the second time it is called
PASS controller.error() should do nothing after readable.cancel()
PASS controller.error() should do nothing after writable.abort() has completed
PASS controller.error() should do nothing after a transformer method has thrown an exception
PASS erroring during write with backpressure should result in the write failing
FAIL a write() that was waiting for backpressure should reject if the writable is aborted assert_throws: read() should reject function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: bad things are happening!" ("error1")
FAIL the readable should be errored with the reason passed to the writable abort() method assert_throws: read() should reject with thrownError function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: bad things are happening!" ("error1")
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS TransformStream errors thrown in transform put the writable and readable in an errored state
PASS TransformStream errors thrown in flush put the writable and readable in an errored state
PASS errored TransformStream should not enqueue new chunks
PASS TransformStream transformer.start() rejected promise should error the stream
PASS when controller.error is followed by a rejection, the error reason should come from controller.error
PASS TransformStream constructor should throw when start does
PASS when strategy.size throws inside start(), the constructor should throw the same error
PASS when strategy.size calls controller.error() then throws, the constructor should throw the first error
PASS cancelling the readable side should error the writable
PASS it should be possible to error the readable between close requested and complete
PASS an exception from transform() should error the stream if terminate has been requested but not completed
PASS abort should set the close reason for the writable when it happens before cancel during start, but cancel should still succeed
PASS abort should set the close reason for the writable when it happens before cancel during underlying sink write, but cancel should still succeed
PASS controller.error() should do nothing the second time it is called
PASS controller.error() should do nothing after readable.cancel()
PASS controller.error() should do nothing after writable.abort() has completed
PASS controller.error() should do nothing after a transformer method has thrown an exception
PASS erroring during write with backpressure should result in the write failing
FAIL a write() that was waiting for backpressure should reject if the writable is aborted assert_throws: read() should reject function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: bad things are happening!" ("error1")
FAIL the readable should be errored with the reason passed to the writable abort() method assert_throws: read() should reject with thrownError function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: bad things are happening!" ("error1")
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Service worker test setup
PASS TransformStream errors thrown in transform put the writable and readable in an errored state
PASS TransformStream errors thrown in flush put the writable and readable in an errored state
PASS errored TransformStream should not enqueue new chunks
PASS TransformStream transformer.start() rejected promise should error the stream
PASS when controller.error is followed by a rejection, the error reason should come from controller.error
PASS TransformStream constructor should throw when start does
PASS when strategy.size throws inside start(), the constructor should throw the same error
PASS when strategy.size calls controller.error() then throws, the constructor should throw the first error
PASS cancelling the readable side should error the writable
PASS it should be possible to error the readable between close requested and complete
PASS an exception from transform() should error the stream if terminate has been requested but not completed
PASS abort should set the close reason for the writable when it happens before cancel during start, but cancel should still succeed
PASS abort should set the close reason for the writable when it happens before cancel during underlying sink write, but cancel should still succeed
PASS controller.error() should do nothing the second time it is called
PASS controller.error() should do nothing after readable.cancel()
PASS controller.error() should do nothing after writable.abort() has completed
PASS controller.error() should do nothing after a transformer method has thrown an exception
PASS erroring during write with backpressure should result in the write failing
FAIL a write() that was waiting for backpressure should reject if the writable is aborted assert_throws: read() should reject function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: bad things are happening!" ("error1")
FAIL the readable should be errored with the reason passed to the writable abort() method assert_throws: read() should reject with thrownError function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: bad things are happening!" ("error1")
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS TransformStream errors thrown in transform put the writable and readable in an errored state
PASS TransformStream errors thrown in flush put the writable and readable in an errored state
PASS errored TransformStream should not enqueue new chunks
PASS TransformStream transformer.start() rejected promise should error the stream
PASS when controller.error is followed by a rejection, the error reason should come from controller.error
PASS TransformStream constructor should throw when start does
PASS when strategy.size throws inside start(), the constructor should throw the same error
PASS when strategy.size calls controller.error() then throws, the constructor should throw the first error
PASS cancelling the readable side should error the writable
PASS it should be possible to error the readable between close requested and complete
PASS an exception from transform() should error the stream if terminate has been requested but not completed
PASS abort should set the close reason for the writable when it happens before cancel during start, but cancel should still succeed
PASS abort should set the close reason for the writable when it happens before cancel during underlying sink write, but cancel should still succeed
PASS controller.error() should do nothing the second time it is called
PASS controller.error() should do nothing after readable.cancel()
PASS controller.error() should do nothing after writable.abort() has completed
PASS controller.error() should do nothing after a transformer method has thrown an exception
PASS erroring during write with backpressure should result in the write failing
FAIL a write() that was waiting for backpressure should reject if the writable is aborted assert_throws: read() should reject function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: bad things are happening!" ("error1")
FAIL the readable should be errored with the reason passed to the writable abort() method assert_throws: read() should reject with thrownError function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: bad things are happening!" ("error1")
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS TransformStreamDefaultController should not be exported on the global object
PASS TransformStream.prototype.constructor should have standard properties
PASS TransformStream.prototype.constructor should be a constructor
PASS TransformStream.prototype.readable should have standard properties
PASS TransformStream.prototype.readable should be a getter
PASS TransformStream.prototype.writable should have standard properties
PASS TransformStream.prototype.writable should be a getter
PASS TransformStream.prototype should have exactly the expected properties
PASS TransformStreamDefaultController.prototype.constructor should have standard properties
FAIL TransformStreamDefaultController.prototype.constructor should be a constructor assert_equals: constructor should take 0 arguments expected 0 but got 1
PASS TransformStreamDefaultController.prototype.desiredSize should have standard properties
PASS TransformStreamDefaultController.prototype.desiredSize should be a getter
PASS TransformStreamDefaultController.prototype.enqueue should have standard properties
PASS TransformStreamDefaultController.prototype.enqueue should be a method
PASS TransformStreamDefaultController.prototype.error should have standard properties
PASS TransformStreamDefaultController.prototype.error should be a method
PASS TransformStreamDefaultController.prototype.terminate should have standard properties
PASS TransformStreamDefaultController.prototype.terminate should be a method
PASS TransformStreamDefaultController.prototype should have exactly the expected properties
PASS transformer method start should be called with the right number of arguments
PASS transformer method start should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method start assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
PASS transformer method transform should be called with the right number of arguments
PASS transformer method transform should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method transform assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
PASS transformer method flush should be called with the right number of arguments
PASS transformer method flush should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method flush assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS TransformStreamDefaultController should not be exported on the global object
PASS TransformStream.prototype.constructor should have standard properties
PASS TransformStream.prototype.constructor should be a constructor
PASS TransformStream.prototype.readable should have standard properties
PASS TransformStream.prototype.readable should be a getter
PASS TransformStream.prototype.writable should have standard properties
PASS TransformStream.prototype.writable should be a getter
PASS TransformStream.prototype should have exactly the expected properties
PASS TransformStreamDefaultController.prototype.constructor should have standard properties
FAIL TransformStreamDefaultController.prototype.constructor should be a constructor assert_equals: constructor should take 0 arguments expected 0 but got 1
PASS TransformStreamDefaultController.prototype.desiredSize should have standard properties
PASS TransformStreamDefaultController.prototype.desiredSize should be a getter
PASS TransformStreamDefaultController.prototype.enqueue should have standard properties
PASS TransformStreamDefaultController.prototype.enqueue should be a method
PASS TransformStreamDefaultController.prototype.error should have standard properties
PASS TransformStreamDefaultController.prototype.error should be a method
PASS TransformStreamDefaultController.prototype.terminate should have standard properties
PASS TransformStreamDefaultController.prototype.terminate should be a method
PASS TransformStreamDefaultController.prototype should have exactly the expected properties
PASS transformer method start should be called with the right number of arguments
PASS transformer method start should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method start assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
PASS transformer method transform should be called with the right number of arguments
PASS transformer method transform should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method transform assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
PASS transformer method flush should be called with the right number of arguments
PASS transformer method flush should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method flush assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Service worker test setup
PASS TransformStreamDefaultController should not be exported on the global object
PASS TransformStream.prototype.constructor should have standard properties
PASS TransformStream.prototype.constructor should be a constructor
PASS TransformStream.prototype.readable should have standard properties
PASS TransformStream.prototype.readable should be a getter
PASS TransformStream.prototype.writable should have standard properties
PASS TransformStream.prototype.writable should be a getter
PASS TransformStream.prototype should have exactly the expected properties
PASS TransformStreamDefaultController.prototype.constructor should have standard properties
FAIL TransformStreamDefaultController.prototype.constructor should be a constructor assert_equals: constructor should take 0 arguments expected 0 but got 1
PASS TransformStreamDefaultController.prototype.desiredSize should have standard properties
PASS TransformStreamDefaultController.prototype.desiredSize should be a getter
PASS TransformStreamDefaultController.prototype.enqueue should have standard properties
PASS TransformStreamDefaultController.prototype.enqueue should be a method
PASS TransformStreamDefaultController.prototype.error should have standard properties
PASS TransformStreamDefaultController.prototype.error should be a method
PASS TransformStreamDefaultController.prototype.terminate should have standard properties
PASS TransformStreamDefaultController.prototype.terminate should be a method
PASS TransformStreamDefaultController.prototype should have exactly the expected properties
PASS transformer method start should be called with the right number of arguments
PASS transformer method start should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method start assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
PASS transformer method transform should be called with the right number of arguments
PASS transformer method transform should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method transform assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
PASS transformer method flush should be called with the right number of arguments
PASS transformer method flush should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method flush assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS TransformStreamDefaultController should not be exported on the global object
PASS TransformStream.prototype.constructor should have standard properties
PASS TransformStream.prototype.constructor should be a constructor
PASS TransformStream.prototype.readable should have standard properties
PASS TransformStream.prototype.readable should be a getter
PASS TransformStream.prototype.writable should have standard properties
PASS TransformStream.prototype.writable should be a getter
PASS TransformStream.prototype should have exactly the expected properties
PASS TransformStreamDefaultController.prototype.constructor should have standard properties
FAIL TransformStreamDefaultController.prototype.constructor should be a constructor assert_equals: constructor should take 0 arguments expected 0 but got 1
PASS TransformStreamDefaultController.prototype.desiredSize should have standard properties
PASS TransformStreamDefaultController.prototype.desiredSize should be a getter
PASS TransformStreamDefaultController.prototype.enqueue should have standard properties
PASS TransformStreamDefaultController.prototype.enqueue should be a method
PASS TransformStreamDefaultController.prototype.error should have standard properties
PASS TransformStreamDefaultController.prototype.error should be a method
PASS TransformStreamDefaultController.prototype.terminate should have standard properties
PASS TransformStreamDefaultController.prototype.terminate should be a method
PASS TransformStreamDefaultController.prototype should have exactly the expected properties
PASS transformer method start should be called with the right number of arguments
PASS transformer method start should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method start assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
PASS transformer method transform should be called with the right number of arguments
PASS transformer method transform should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method transform assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
PASS transformer method flush should be called with the right number of arguments
PASS transformer method flush should be called even when it's located on the prototype chain
FAIL unexpected properties should not be accessed when calling transformer method flush assert_array_equals: expected properties should be got lengths differ, expected 5 got 3
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS enqueue() inside size() should work
PASS terminate() inside size() should work
PASS error() inside size() should work
PASS desiredSize inside size() should work
PASS readable cancel() inside size() should work
PASS pipeTo() inside size() should work
PASS read() inside of size() should work
PASS writer.write() inside size() should work
PASS synchronous writer.write() inside size() should work
PASS writer.close() inside size() should work
FAIL writer.abort() inside size() should work assert_throws: read() should reject function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: error1" ("error1")
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS enqueue() inside size() should work
PASS terminate() inside size() should work
PASS error() inside size() should work
PASS desiredSize inside size() should work
PASS readable cancel() inside size() should work
PASS pipeTo() inside size() should work
PASS read() inside of size() should work
PASS writer.write() inside size() should work
PASS synchronous writer.write() inside size() should work
PASS writer.close() inside size() should work
FAIL writer.abort() inside size() should work assert_throws: read() should reject function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: error1" ("error1")
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Service worker test setup
PASS enqueue() inside size() should work
PASS terminate() inside size() should work
PASS error() inside size() should work
PASS desiredSize inside size() should work
PASS readable cancel() inside size() should work
PASS pipeTo() inside size() should work
PASS read() inside of size() should work
PASS writer.write() inside size() should work
PASS synchronous writer.write() inside size() should work
PASS writer.close() inside size() should work
FAIL writer.abort() inside size() should work assert_throws: read() should reject function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: error1" ("error1")
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS enqueue() inside size() should work
PASS terminate() inside size() should work
PASS error() inside size() should work
PASS desiredSize inside size() should work
PASS readable cancel() inside size() should work
PASS pipeTo() inside size() should work
PASS read() inside of size() should work
PASS writer.write() inside size() should work
PASS synchronous writer.write() inside size() should work
PASS writer.close() inside size() should work
FAIL writer.abort() inside size() should work assert_throws: read() should reject function "function() { throw e }" threw object "TypeError: The writable stream has been aborted" ("TypeError") expected object "error1: error1" ("error1")
Harness: the test ran to completion.
......@@ -193,7 +193,7 @@
// Internal utility functions. Not exported.
const callFunction = v8.uncurryThis(global.Function.prototype.call);
const errTmplMustBeFunctionOrUndefined = name =>
`${name} must be a function or undefined`;
`${name} must be a function or undefined`;
const Promise_resolve = Promise.resolve.bind(Promise);
const Promise_reject = Promise.reject.bind(Promise);
const Function_bind = v8.uncurryThis(global.Function.prototype.bind);
......@@ -213,13 +213,14 @@
// assert(underlyingObject !== undefined,
// 'underlyingObject is not undefined.');
// assert(IsPropertyKey(methodName),
// '! IsPropertyKey(methodName) is true.');
// '! IsPropertyKey(methodName) is true.');
// assert(algoArgCount === 0 || algoArgCount === 1,
// 'algoArgCount is 0 or 1.');
// assert(typeof methodNameForError === 'string',
// 'methodNameForError is a string');
const method = resolveMethod(underlyingObject, methodName,
methodNameForError);
// 'algoArgCount is 0 or 1.');
// assert(
// typeof methodNameForError === 'string',
// 'methodNameForError is a string');
const method =
resolveMethod(underlyingObject, methodName, methodNameForError);
// The implementation uses bound functions rather than lambdas where
// possible to give the compiler the maximum opportunity to optimise.
if (method === undefined) {
......@@ -234,27 +235,27 @@
}
function CreateAlgorithmFromUnderlyingMethodPassingController(
underlyingObject, methodName, algoArgCount, controller,
underlyingObject, methodName, algoArgCount, controller,
methodNameForError) {
// assert(underlyingObject !== undefined,
// 'underlyingObject is not undefined.');
// assert(IsPropertyKey(methodName),
// '! IsPropertyKey(methodName) is true.');
// '! IsPropertyKey(methodName) is true.');
// assert(algoArgCount === 0 || algoArgCount === 1,
// 'algoArgCount is 0 or 1.');
// assert(typeof controller === 'object'
// 'controller is an object');
// assert(typeof methodNameForError === 'string',
// 'methodNameForError is a string');
const method = resolveMethod(underlyingObject, methodName,
methodNameForError);
// 'algoArgCount is 0 or 1.');
// assert(typeof controller === 'object', 'controller is an object');
// assert(
// typeof methodNameForError === 'string',
// 'methodNameForError is a string');
const method =
resolveMethod(underlyingObject, methodName, methodNameForError);
if (method === undefined) {
return () => Promise_resolve();
}
if (algoArgCount === 0) {
return Function_bind(PromiseCall1, undefined, method, underlyingObject,
controller);
return Function_bind(
PromiseCall1, undefined, method, underlyingObject, controller);
}
return arg => PromiseCall2(method, underlyingObject, arg, controller);
......@@ -280,10 +281,8 @@
}
function PromiseCall0(F, V) {
// assert(typeof F === 'function',
// 'IsCallable(F) is true.');
// assert(V !== undefined,
// 'V is not undefined.');
// assert(typeof F === 'function', 'IsCallable(F) is true.');
// assert(V !== undefined, 'V is not undefined.');
try {
return Promise_resolve(callFunction(F, V));
} catch (e) {
......@@ -292,10 +291,8 @@
}
function PromiseCall1(F, V, arg0) {
// assert(typeof F === 'function',
// 'IsCallable(F) is true.');
// assert(V !== undefined,
// 'V is not undefined.');
// assert(typeof F === 'function', 'IsCallable(F) is true.');
// assert(V !== undefined, 'V is not undefined.');
try {
return Promise_resolve(callFunction(F, V, arg0));
} catch (e) {
......@@ -304,10 +301,8 @@
}
function PromiseCall2(F, V, arg0, arg1) {
// assert(typeof F === 'function',
// 'IsCallable(F) is true.');
// assert(V !== undefined,
// 'V is not undefined.');
// assert(typeof F === 'function', 'IsCallable(F) is true.');
// assert(V !== undefined, 'V is not undefined.');
try {
return Promise_resolve(callFunction(F, V, arg0, arg1));
} catch (e) {
......@@ -334,5 +329,6 @@
MakeSizeAlgorithmFromSizeFunction,
CallOrNoop1,
PromiseCallOrNoop1,
PromiseCall2
};
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment