Re: [whatwg/streams] Check precisely the way that transformer.transform() is called (#689)

ricea commented on this pull request.



> @@ -300,4 +300,36 @@ promise_test(() => {
   return readableStreamToArray(ts.readable);
 }, 'methods should not not have .apply() or .call() called');
 
+promise_test(t => {
+  const transformer = {
+    transform() {
+      transformer.transform = undefined;
+      throw new TypeError();
+    }
+  };
+  const ts = new TransformStream(transformer);
+  return Promise.all([
+    promise_rejects(t, new TypeError(), ts.writable.getWriter().write('a'), 'write() should throw'),
+    promise_rejects(t, new TypeError(), ts.readable.getReader().read(), 'read() should throw')

Someone might try to fix this broken optimisation by checking if the exception was TypeError. So the fact that it behaves exactly like transform() was undefined is WAI.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/689#discussion_r105073907

Received on Thursday, 9 March 2017 02:18:19 UTC