[whatwg/streams] Add helpers to use initial values of Promise methods (#1010)

Currently, the reference implementation does not use the initial value of the `Promise` constructor and its methods to implement phrases such as ["upon fulfillment of _p_ with value _v_"](https://www.w3.org/2001/tag/doc/promises-guide/#upon-fulfillment), although this is required by the promise guide. This causes the reference implementation to fail on the new tests introduced in web-platform-tests/wpt#18452.

This PR adds helper functions to call the original versions of the promise constructor and its methods. Assuming they haven't been monkey-patched before the reference implementation was loaded, these should be the initial values expected by the spec.

It also replaces all direct calls to the promise constructos and its methods with calls to the respective helper functions. This is a purely mechanical change, but it does make for quite a big diff! 😅

With this change, the reference implementation once again passes all tests. 🎉

See also:
* [Original report](https://github.com/web-platform-tests/wpt/pull/18452#issuecomment-522364285)
You can view, comment on, or merge this pull request online at:

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


-- Commit Summary --

  * Add promise helpers
  * Replace `new Promise` with CreatePromise
  * Replace `Promise.resolve` with PromiseResolve
  * Replace `Promise.reject` with PromiseReject
  * Replace `Promise.prototype.then` with PerformPromiseThen
  * Add PerformPromiseCatch helper
  * Replace `Promise.prototype.catch` with PerformPromiseCatch
  * Update WPT

-- File Changes --

    M reference-implementation/lib/helpers.js (41)
    M reference-implementation/lib/readable-stream.js (286)
    M reference-implementation/lib/transform-stream.js (28)
    M reference-implementation/lib/writable-stream.js (178)
    M reference-implementation/web-platform-tests (2)

-- Patch Links --

https://github.com/whatwg/streams/pull/1010.patch

https://github.com/whatwg/streams/pull/1010.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/1010

Received on Monday, 19 August 2019 21:38:52 UTC