From cbc8c46bdff4a0130cd049ca9f8ed2271371ecec Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 Jun 2020 23:12:03 -0700 Subject: [PATCH] Editorial: add PromiseCapability Record assertions (#2050) --- spec.html | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/spec.html b/spec.html index a67bcdd95f7..b42a53f3d47 100644 --- a/spec.html +++ b/spec.html @@ -24077,7 +24077,7 @@

Runtime Semantics: HostImportModuleDynamically ( _referencingScriptOrModule_

Runtime Semantics: FinishDynamicImport ( _referencingScriptOrModule_, _specifier_, _promiseCapability_, _completion_ )

-

The abstract operation FinishDynamicImport takes arguments _referencingScriptOrModule_, _specifier_, _promiseCapability_, and _completion_. FinishDynamicImport completes the process of a dynamic import originally started by an `import()` call, resolving or rejecting the promise returned by that call as appropriate according to _completion_. It is performed by host environments as part of HostImportModuleDynamically. It performs the following steps when called:

+

The abstract operation FinishDynamicImport takes arguments _referencingScriptOrModule_, _specifier_, _promiseCapability_ (a PromiseCapability Record), and _completion_. FinishDynamicImport completes the process of a dynamic import originally started by an `import()` call, resolving or rejecting the promise returned by that call as appropriate according to _completion_. It is performed by host environments as part of HostImportModuleDynamically. It performs the following steps when called:

1. If _completion_ is an abrupt completion, then perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _completion_.[[Value]] »). @@ -38932,7 +38932,7 @@

Properties of Async-from-Sync Iterator Instances

AsyncFromSyncIteratorContinuation ( _result_, _promiseCapability_ )

-

The abstract operation AsyncFromSyncIteratorContinuation takes arguments _result_ and _promiseCapability_. It performs the following steps when called:

+

The abstract operation AsyncFromSyncIteratorContinuation takes arguments _result_ and _promiseCapability_ (a PromiseCapability Record). It performs the following steps when called:

1. Let _done_ be IteratorComplete(_result_). @@ -39485,7 +39485,7 @@

AsyncGeneratorRequest Records

[[Capability]] - A PromiseCapability record + A PromiseCapability Record The promise capabilities associated with this request. @@ -39528,6 +39528,7 @@

AsyncGeneratorResolve ( _generator_, _value_, _done_ )

1. Assert: _queue_ is not an empty List. 1. Remove the first element from _queue_ and let _next_ be the value of that element. 1. Let _promiseCapability_ be _next_.[[Capability]]. + 1. Assert: _promiseCapability_ is a PromiseCapability Record. 1. Let _iteratorResult_ be ! CreateIterResultObject(_value_, _done_). 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _iteratorResult_ »). 1. Perform ! AsyncGeneratorResumeNext(_generator_). @@ -39544,6 +39545,7 @@

AsyncGeneratorReject ( _generator_, _exception_ )

1. Assert: _queue_ is not an empty List. 1. Remove the first element from _queue_ and let _next_ be the value of that element. 1. Let _promiseCapability_ be _next_.[[Capability]]. + 1. Assert: _promiseCapability_ is a PromiseCapability Record. 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _exception_ »). 1. Perform ! AsyncGeneratorResumeNext(_generator_). 1. Return *undefined*. @@ -39695,7 +39697,7 @@

Promise Abstract Operations

PromiseCapability Records

A PromiseCapability is a Record value used to encapsulate a promise object along with the functions that are capable of resolving or rejecting that promise object. PromiseCapability Records are produced by the NewPromiseCapability abstract operation.

PromiseCapability Records have the fields listed in .

- + @@ -39900,7 +39902,7 @@

NewPromiseCapability ( _C_ )

1. If IsConstructor(_C_) is *false*, throw a *TypeError* exception. 1. NOTE: _C_ is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see ). - 1. Let _promiseCapability_ be the PromiseCapability { [[Promise]]: *undefined*, [[Resolve]]: *undefined*, [[Reject]]: *undefined* }. + 1. Let _promiseCapability_ be the PromiseCapability Record { [[Promise]]: *undefined*, [[Resolve]]: *undefined*, [[Reject]]: *undefined* }. 1. Let _steps_ be the algorithm steps defined in . 1. Let _executor_ be ! CreateBuiltinFunction(_steps_, « [[Capability]] »). 1. Set _executor_.[[Capability]] to _promiseCapability_. @@ -40012,6 +40014,7 @@

NewPromiseReactionJob ( _reaction_, _argument_ )

1. If _promiseCapability_ is *undefined*, then 1. Assert: _handlerResult_ is not an abrupt completion. 1. Return NormalCompletion(~empty~). + 1. Assert: _promiseCapability_ is a PromiseCapability Record. 1. If _handlerResult_ is an abrupt completion, then 1. Let _status_ be Call(_promiseCapability_.[[Reject]], *undefined*, « _handlerResult_.[[Value]] »). 1. Else, @@ -40126,10 +40129,9 @@

Runtime Semantics: GetPromiseResolve ( _promiseConstructor_ )

Runtime Semantics: PerformPromiseAll ( _iteratorRecord_, _constructor_, _resultCapability_, _promiseResolve_ )

-

The abstract operation PerformPromiseAll takes arguments _iteratorRecord_, _constructor_, _resultCapability_, and _promiseResolve_. It performs the following steps when called:

+

The abstract operation PerformPromiseAll takes arguments _iteratorRecord_, _constructor_, _resultCapability_ (a PromiseCapability Record), and _promiseResolve_. It performs the following steps when called:

1. Assert: IsConstructor(_constructor_) is *true*. - 1. Assert: _resultCapability_ is a PromiseCapability Record. 1. Assert: IsCallable(_promiseResolve_) is *true*. 1. Let _values_ be a new empty List. 1. Let _remainingElementsCount_ be the Record { [[Value]]: 1 }. @@ -40175,6 +40177,7 @@

`Promise.all` Resolve Element Functions

1. Let _index_ be _F_.[[Index]]. 1. Let _values_ be _F_.[[Values]]. 1. Let _promiseCapability_ be _F_.[[Capability]]. + 1. Assert: _promiseCapability_ is a PromiseCapability Record. 1. Let _remainingElementsCount_ be _F_.[[RemainingElements]]. 1. Set _values_[_index_] to _x_. 1. Set _remainingElementsCount_.[[Value]] to _remainingElementsCount_.[[Value]] - 1. @@ -40209,10 +40212,9 @@

Promise.allSettled ( _iterable_ )

Runtime Semantics: PerformPromiseAllSettled ( _iteratorRecord_, _constructor_, _resultCapability_, _promiseResolve_ )

-

The abstract operation PerformPromiseAllSettled takes arguments _iteratorRecord_, _constructor_, _resultCapability_, and _promiseResolve_. It performs the following steps when called:

+

The abstract operation PerformPromiseAllSettled takes arguments _iteratorRecord_, _constructor_, _resultCapability_ (a PromiseCapability Record), and _promiseResolve_. It performs the following steps when called:

1. Assert: ! IsConstructor(_constructor_) is *true*. - 1. Assert: _resultCapability_ is a PromiseCapability Record. 1. Assert: IsCallable(_promiseResolve_) is *true*. 1. Let _values_ be a new empty List. 1. Let _remainingElementsCount_ be the Record { [[Value]]: 1 }. @@ -40266,6 +40268,7 @@

`Promise.allSettled` Resolve Element Functions

1. Let _index_ be _F_.[[Index]]. 1. Let _values_ be _F_.[[Values]]. 1. Let _promiseCapability_ be _F_.[[Capability]]. + 1. Assert: _promiseCapability_ is a PromiseCapability Record. 1. Let _remainingElementsCount_ be _F_.[[RemainingElements]]. 1. Let _obj_ be ! OrdinaryObjectCreate(%Object.prototype%). 1. Perform ! CreateDataPropertyOrThrow(_obj_, *"status"*, *"fulfilled"*). @@ -40292,6 +40295,7 @@

`Promise.allSettled` Reject Element Functions

1. Let _index_ be _F_.[[Index]]. 1. Let _values_ be _F_.[[Values]]. 1. Let _promiseCapability_ be _F_.[[Capability]]. + 1. Assert: _promiseCapability_ is a PromiseCapability Record. 1. Let _remainingElementsCount_ be _F_.[[RemainingElements]]. 1. Let _obj_ be ! OrdinaryObjectCreate(%Object.prototype%). 1. Perform ! CreateDataPropertyOrThrow(_obj_, *"status"*, *"rejected"*). @@ -40338,10 +40342,9 @@

Promise.race ( _iterable_ )

Runtime Semantics: PerformPromiseRace ( _iteratorRecord_, _constructor_, _resultCapability_, _promiseResolve_ )

-

The abstract operation PerformPromiseRace takes arguments _iteratorRecord_, _constructor_, _resultCapability_, and _promiseResolve_. It performs the following steps when called:

+

The abstract operation PerformPromiseRace takes arguments _iteratorRecord_, _constructor_, _resultCapability_ (a PromiseCapability Record), and _promiseResolve_. It performs the following steps when called:

1. Assert: IsConstructor(_constructor_) is *true*. - 1. Assert: _resultCapability_ is a PromiseCapability Record. 1. Assert: IsCallable(_promiseResolve_) is *true*. 1. Repeat, 1. Let _next_ be IteratorStep(_iteratorRecord_). @@ -40513,13 +40516,9 @@

Promise.prototype.then ( _onFulfilled_, _onRejected_ )

PerformPromiseThen ( _promise_, _onFulfilled_, _onRejected_ [ , _resultCapability_ ] )

-

The abstract operation PerformPromiseThen takes arguments _promise_, _onFulfilled_, and _onRejected_ and optional argument _resultCapability_. It performs the “then” operation on _promise_ using _onFulfilled_ and _onRejected_ as its settlement actions. If _resultCapability_ is passed, the result is stored by updating _resultCapability_'s promise. If it is not passed, then PerformPromiseThen is being called by a specification-internal operation where the result does not matter. It performs the following steps when called:

+

The abstract operation PerformPromiseThen takes arguments _promise_, _onFulfilled_, and _onRejected_ and optional argument _resultCapability_ (a PromiseCapability Record). It performs the “then” operation on _promise_ using _onFulfilled_ and _onRejected_ as its settlement actions. If _resultCapability_ is passed, the result is stored by updating _resultCapability_'s promise. If it is not passed, then PerformPromiseThen is being called by a specification-internal operation where the result does not matter. It performs the following steps when called:

1. Assert: IsPromise(_promise_) is *true*. - 1. If _resultCapability_ is present, then - 1. Assert: _resultCapability_ is a PromiseCapability Record. - 1. Else, - 1. Set _resultCapability_ to *undefined*. 1. If IsCallable(_onFulfilled_) is *false*, then 1. Set _onFulfilled_ to *undefined*. 1. If IsCallable(_onRejected_) is *false*, then @@ -40716,7 +40715,7 @@

Async Functions Abstract Operations

AsyncFunctionStart ( _promiseCapability_, _asyncFunctionBody_ )

-

The abstract operation AsyncFunctionStart takes arguments _promiseCapability_ and _asyncFunctionBody_. It performs the following steps when called:

+

The abstract operation AsyncFunctionStart takes arguments _promiseCapability_ (a PromiseCapability Record) and _asyncFunctionBody_. It performs the following steps when called:

1. Let _runningContext_ be the running execution context. 1. Let _asyncContext_ be a copy of _runningContext_.