Commit 65774ae7 authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Update TransformStream to fix transform algo error behaviour

Update TransformStream to standard version
78cfd1e22b717ce7e6d3aae4e36de0ef9101356e. This includes change
https://github.com/whatwg/streams/pull/948 which corrects the behaviour when the
transformAlgorithm rejects.

Also enable test TransformStreamTest.ThrowFromTransform which was disabled
pending this fix.

BUG=845427

Change-Id: If0eff40c5855bf662098eecc87e32256b97dc71e
Reviewed-on: https://chromium-review.googlesource.com/1167011Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586601}
parent 35e9b88a
......@@ -311,14 +311,8 @@
if (typeof transformMethod !== 'function') {
throw new TypeError('transformer.transform is not a function');
}
transformAlgorithm = chunk => {
const transformPromise =
PromiseCall2(transformMethod, transformer, chunk, controller);
return thenPromise(transformPromise, undefined, e => {
TransformStreamError(stream, e);
throw e;
});
};
transformAlgorithm = chunk =>
PromiseCall2(transformMethod, transformer, chunk, controller);
} else {
transformAlgorithm = chunk => {
try {
......@@ -369,6 +363,14 @@
TransformStreamError(controller[_controlledTransformStream], e);
}
function TransformStreamDefaultControllerPerformTransform(controller, chunk) {
const transformPromise = controller[_transformAlgorithm](chunk, controller);
return thenPromise(transformPromise, undefined, r => {
TransformStreamError(controller[_controlledTransformStream], r);
throw r;
});
}
function TransformStreamDefaultControllerTerminate(controller) {
const stream = controller[_controlledTransformStream];
const readableController =
......@@ -404,11 +406,12 @@
// assert(binding.isWritableStreamWritable(writable),
// `state is "writable"`);
return controller[_transformAlgorithm](chunk, controller);
return TransformStreamDefaultControllerPerformTransform(controller,
chunk);
});
}
return controller[_transformAlgorithm](chunk, controller);
return TransformStreamDefaultControllerPerformTransform(controller, chunk);
}
function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
......
......@@ -366,9 +366,7 @@ TEST_F(TransformStreamTest, EnqueueFromFlush) {
EXPECT_TRUE(chunkSeen);
}
// TODO(ricea): Re-enable this test when throwing from Transform() works
// properly. See https://github.com/whatwg/streams/issues/946.
TEST_F(TransformStreamTest, DISABLED_ThrowFromTransform) {
TEST_F(TransformStreamTest, ThrowFromTransform) {
static constexpr char kMessage[] = "errorInTransform";
class ThrowFromTransformTransformer : public TransformStreamTransformer {
public:
......
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