diff --git a/dom.bs b/dom.bs index 5266d1bbe..5c14048f6 100644 --- a/dom.bs +++ b/dom.bs @@ -30,10 +30,28 @@ urlPrefix: https://tc39.es/ecma262/#; spec: ECMASCRIPT text: current realm; url: current-realm text: realm; url: realm text: surrounding agent; url: surrounding-agent + text: execution context stack; url: execution-context-stack urlPrefix: https://w3c.github.io/hr-time/#; spec: HR-TIME type:typedef; urlPrefix: dom-; text: DOMHighResTimeStamp type:dfn; text: current high resolution time; url: dfn-current-high-resolution-time type:dfn; text: relative high resolution coarse time; url: dfn-relative-high-resolution-coarse-time +urlPrefix: https://tc39.es/proposal-async-context/; spec: PROPOSAL-ASYNCCONTEXT + type: dfn; text: Async Context Mapping; url: async-context-mapping + type: abstract-op; text: AsyncContextSnapshot; url: sec-asynccontextsnapshot + +# Link to HTML AsyncContext PR so the spec preview works +urlPrefix: https://whatpr.org/html/12152/infrastructure.html; spec: HTML + type: dfn; text: run; for: Async Context Mapping + + +
+{
+ "PROPOSAL-ASYNCCONTEXT": {
+ "publisher": "Ecma",
+ "href": "https://tc39.es/proposal-async-context/",
+ "title": "AsyncContext"
+ }
+}
@@ -1073,6 +1091,15 @@ and a legacy-canceled-activation behavior algoThese algorithms only exist for checkbox and radio <{input}> elements and are not to be used for anything else. [[!HTML]] +
Each {{EventTarget}} object has a preserved AsyncContext map, which is +a map from strings representing event types to Async Context Mappings. This map is +initially empty. [[!PROPOSAL-ASYNCCONTEXT]] + +
This map is used to implement the [{{PropagatesAsyncContextToEvents}}] WebIDL extended +attribute. For simplicity, the map is defined on {{EventTarget}}, but it will always be empty unless +this implements an interface which either is annotated with this extended attribute or has a +regular operation annotated with it. +
target = new EventTarget();
Creates a new {{EventTarget}} object, which can be used by developers to dispatch and @@ -1763,8 +1790,21 @@ initialized, and a legacy target override flag, run these steps:
This also allows for the {{Event/isTrusted}} attribute to be set to false. -
Return the result of dispatching event at target, with - legacy target override flag set if set. +
If the JavaScript execution context stack is empty, and + if (target's preserved AsyncContext map)[e] + exists, then let async context mapping be (target's + preserved AsyncContext map)[e]. Otherwise, let async context + mapping be AsyncContextSnapshot(). + +
Return the result of running the following steps with + async context mapping: + +
Return the result of dispatching event at target, with + legacy target override flag set if set. +
To enable integration with the TC39 AsyncContext proposal for events fired asynchronously as a +result of either a method call or the construction of an interface instance, we introduce the +[{{PropagatesAsyncContextToEvents}}] WebIDL [=extended attribute=]. [[!PROPOSAL-ASYNCCONTEXT]] + +
The [{{PropagatesAsyncContextToEvents}}] extended attribute must take either a string or a list +of strings. It must only used on either an [=interface=] that inherits from {{EventTarget}}, or on a +[=regular operation=] declared on such an interface. + +
Regular operations annotated with [{{PropagatesAsyncContextToEvents}}], as well as [=constructor +steps=] of an interface annotated with that extended attribute, must run the following steps in +place of the ones specified in their description: + +
If the [{{PropagatesAsyncContextToEvents}}] extended attribute takes a list of strings, let + event types be that list. Otherwise, the argument is a string; let event + types be a list containing that string. + +
For each event type in event types, set (this's + preserved AsyncContext map)[event type] to + AsyncContextSnapshot(). + +
The return value of AsyncContextSnapshot() will not change across + these invocations. +
Run the originally-specified steps for this regular operation. If the steps return a value + or throw an exception, return or throw it in turn. +
Specifications should set this extended attribute on methods which start an async operation which +will eventually cause events to be fired on the instance on which the method was called. +An example of this is the {{XMLHttpRequest}} and its +{{XMLHttpRequest/send}} method: [[XHR]] + +
+[Exposed=(Window,DedicatedWorker,SharedWorker)]
+interface XMLHttpRequest : XMLHttpRequestEventTarget {
+ // ...
+ [PropagatesAsyncContextToEvents=("loadstart", "progress", "error", "load", "timeout", "loadend")] undefined send(optional (Document or XMLHttpRequestBodyInit)? body = null);
+ // ...
+};
+
+
+Specifications should also set this extended attribute on interfaces which are only constructed +as a result of an operation which will eventually fire events on that instance. +An example of this is {{IDBOpenDBRequest}}, instances of which can only +be created by the methods {{IDBFactory/open}} or {{IDBFactory/deleteDatabase}} of {{IDBFactory}}, +both of which will result in events being fired on the returned {{IDBOpenDBRequest}} instance. Note +that here {{IDBFactory/open}} and {{IDBFactory/deleteDatabase}} are not annotated with any +AsyncContext-related extended attribute; only {{IDBOpenDBRequest}} is: [[INDEXEDDB]] + +
+[Exposed=(Window,Worker)]
+interface IDBFactory {
+ [NewObject] IDBOpenDBRequest open(DOMString name,
+ optional [EnforceRange] unsigned long long version);
+ [NewObject] IDBOpenDBRequest deleteDatabase(DOMString name);
+ // ...
+};
+
+[Exposed=(Window,Worker),
+PropagatesAsyncContextToEvents=("success", "error", "blocked", "upgradeneeded")]
+interface IDBOpenDBRequest : IDBRequest {
+ // ...
+};
+
+
+