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

There is an incorrect possible optimisation to the call to
transformer.transform() in the TransformStreamTransform operation:

```javascript
let transformPromise;
try {
  transformPromise = Promise.resolve(transformer.transform(chunk, controller));
} catch (e) {
  if (transformer.transform === undefined) {
    transformPromise = TransformStreamDefaultTransform(chunk, controller);
  } else {
    transformPromise = Promise.reject(e);
  }
}
```

This optimisation is attractive because it moves the `undefined` check out of the
expected fast path. The flaw is the change in order of checking whether
transformer.transform is undefined is visible to user code.

Add a test to verify that the undefined check is performed before the method call.

Also test that transformer.transform is only looked up once, to protect against
flawed variations on this optimisation.
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/689

-- Commit Summary --

  * Check precisely the way that transformer.transform() is called

-- File Changes --

    M reference-implementation/to-upstream-wpts/transform-streams/general.js (32)

-- Patch Links --

https://github.com/whatwg/streams/pull/689.patch
https://github.com/whatwg/streams/pull/689.diff

-- 
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

Received on Wednesday, 8 March 2017 09:21:37 UTC