A Zone is an object that represents a logical asynchronous context.
The Zone constructor is the %Zone% intrinsic object and the initial value of the Zone
property of the Zone
is not intended to be called as a function and will throw an exception when called in that manner.
The Zone
constructor is designed to be subclassable. It may be used as the value in an extends
clause of a class definition. Subclass constructors that intend to inherit the specified Zone
behaviour must include a super
call to the Zone
constructor to create and initialize the subclass instance with the internal state necessary to support the Zone
and Zone.prototype
built-in methods.
When the Zone
function is called with argument options, the following steps are taken:
"(unnamed zone)"
."name"
)."parent"
)."%ZonePrototype"
, « [[ParentZone]], [[Realm]], [[HostDefined]] »)."name"
, PropertyDescriptor {[[Value]]: name, [[Writable]]: The Zone
constructor is not typically used directly. Instead, anotherZone.fork({ name })
is used to create a new zone that is the child of an existing one. A particular common pattern is Zone.current.fork({ name })
.
(Spec review note) This is intended to mimic the signature constructor({ name = "(unnamed zone)", parent = null } = {}) { ... }
.
HostSetupZone is an implementation-defined abstract operation that allows host environments to set up Zone
objects based on the developer-supplied options value. Host environments may wish to, for example, store values passed as properties of options in the [[HostDefined]] internal slot of the zone object.
An implementation of HostSetupZone may complete normally or abruptly. Any abrupt completions will be propagated to its callers. The default implementation of HostSetupZone is to unconditionally return an empty normal completion.
zone will be guaranteed to be a Zone
object, and options will be guaranteed to have passed Zone
constructor in using
The value of the [[Prototype]] internal slot of the Zone
constructor is the intrinsic object
The Zone constructor has the following properties:
The initial value of Zone.prototype
is the intrinsic object
This property has the attributes { [[Writable]]:
Zone.current
is an accessor property whose set accessor function is
The Zone prototype object is the intrinsic object %ZonePrototype%. The value of the [[Prototype]] internal slot of the Zone prototype object is the intrinsic object
Zone.prototype.parent
is an accessor property whose set accessor function is
When the fork
method is called with argument options, the following steps are taken:
"name"
)."parent"
, Z)."name"
, name)."constructor"
).(Spec review note) This is intended to mimic the function signature fork({ name = ToString(this.name) + " child" } = {}) { ... }
.
When the run
method is called with argument callback, the following steps are taken:
When the wrap
method is called with argument callback, the following steps are taken:
A Zone.prototype.wrap wrapper function is an anonymous built-in function that is created by the Zone.prototype.wrap method. Each Zone.prototype.wrap wrapper function has [[Zone]] and [[Callback]] internal slots.
When a Zone.prototype.wrap wrapper function F is called with
Zone instances are ordinary objects that inherit properties from the Zone prototype object (the intrinsic,
Internal Slot | Description |
---|---|
[[ParentZone]] | The zone in which this zone was created. |
[[Realm]] | The Zone constructor that created this instance. |
[[HostDefined]] | Field reserved for use by host environments that need to associate additional information with a zone. |
Each Zone instance has the following own property:
The value of the name
property is a string that indicates the name of the zone, supplied at construction time. It is used for debugging and tooling purposes and does not affect the zone's behavior.
This property has the attributes { [[Writable]]:
The table for
Field Name | Value | Meaning |
---|---|---|
[[CurrentZone]] | A Zone object |
The current zone for this |
The abstract operation
"name"
, "(root zone)"
).The table for PromiseReaction
Field Name | Value | Meaning |
---|---|---|
[[Zone]] | A Zone object |
The zone associated with this promise reaction |
The abstract operation PerformPromiseThen performs the “then” operation on promise using onFulfilled and onRejected as its settlement actions. The result is resultCapability's promise.
"Identity"
."Thrower"
."pending"
, then"fulfilled"
, then"PromiseJobs"
, "rejected"
."handle"
)."PromiseJobs"
, The job
"Identity"
, let handlerResult be "Thrower"
, let handlerResult be