@@ -72,6 +72,12 @@ urlPrefix: https://tc39.es/ecma262/; spec: ecmascript
72
72
urlPrefix: https://tc39.es/proposal-resizablearraybuffer/; spec: RESIZABLE-BUFFERS-PROPOSAL
73
73
type: abstract-op
74
74
text: IsResizableArrayBuffer; url: sec-isresizablearraybuffer
75
+ urlPrefix: https://tc39.es/proposal-async-context/; spec: ASYNC-CONTEXT-PROPOSAL
76
+ type: abstract-op
77
+ text: AsyncContextSnapshot; url: sec-asynccontextsnapshot
78
+ text: AsyncContextSwap; url: sec-asynccontextswap
79
+ type: dfn
80
+ text: async context mapping records; url: sec-asynccontext-mapping-record-specification-type
75
81
</pre>
76
82
77
83
<style>
@@ -6013,8 +6019,9 @@ about the execution context at the time the language binding specific object ref
6013
6019
converted to an IDL value.
6014
6020
6015
6021
Note: For ECMAScript objects, the [=callback context=] is used to hold a reference to the
6016
- <a spec="HTML">incumbent settings object</a> at the time the Object value is converted to an IDL
6017
- callback interface type value. See [[#es-callback-interface]].
6022
+ <a spec="HTML">incumbent settings object</a> and the [=list=] of [=Async Context Mapping Records=]
6023
+ at the time the Object value is converted to an IDL callback interface type value.
6024
+ See [[#es-callback-interface]].
6018
6025
6019
6026
There is no way to represent a constant object reference value for a particular
6020
6027
[=callback interface type=] in IDL.
@@ -6061,10 +6068,10 @@ the [=callback function=], the values can be references to objects that are not
6061
6068
An IDL value of the callback function type is represented by a tuple of an object
6062
6069
reference and a [=callback context=].
6063
6070
6064
- Note: As with [=callback interface types=], the [=callback context=] is used to hold a
6065
- reference to the <a spec="HTML">incumbent settings object</a> at
6066
- the time an ECMAScript Object value is converted to an IDL
6067
- callback function type value. See [[#es-callback-function]].
6071
+ Note: As with [=callback interface types=], the [=callback context=] is used to hold a reference to
6072
+ the <a spec="HTML">incumbent settings object</a> and the [=list=] of [=Async Context Mapping
6073
+ Records=] at the time the Object value is converted to an IDL callback function type value.
6074
+ See [[#es-callback-function]].
6068
6075
6069
6076
There is no way to represent a constant [=callback function=]
6070
6077
value in IDL.
@@ -7671,8 +7678,10 @@ values are represented by ECMAScript Object values (including [=function objects
7671
7678
to an IDL [=callback interface type=] value by running the following algorithm:
7672
7679
7673
7680
1. If <a abstract-op>Type</a>(|V|) is not Object, then [=ECMAScript/throw=] a <l spec=ecmascript>{{TypeError}}</l>.
7681
+ 1. Let |incumbent| be the <a spec="HTML">incumbent settings object</a>.
7682
+ 1. Let |context| be [$AsyncContextSnapshot$]().
7674
7683
1. Return the IDL [=callback interface type=] value that represents a reference to |V|, with
7675
- the <a spec="HTML"> incumbent settings object</a> as the [=callback context=].
7684
+ (| incumbent|, |context|) as the [=callback context=].
7676
7685
</div>
7677
7686
7678
7687
<p id="callback-interface-to-es">
@@ -7792,9 +7801,11 @@ IDL [=callback function types=] are represented by ECMAScript [=function objects
7792
7801
[=callback function=]
7793
7802
that is annotated with [{{LegacyTreatNonObjectAsNull}}],
7794
7803
then [=ECMAScript/throw=] a <l spec=ecmascript>{{TypeError}}</l>.
7804
+ 1. Let |incumbent| be the <a spec="HTML">incumbent settings object</a>.
7805
+ 1. Let |context| be [$AsyncContextSnapshot$]().
7795
7806
1. Return the IDL [=callback function type=] value
7796
- that represents a reference to the same object that |V| represents, with the
7797
- <a spec="HTML"> incumbent settings object</a> as the [=callback context=].
7807
+ that represents a reference to the same object that |V| represents, with
7808
+ (| incumbent|, |context|) as the [=callback context=].
7798
7809
</div>
7799
7810
7800
7811
<p id="callback-function-to-es">
@@ -14149,17 +14160,20 @@ the special value “missing”, which represents a missing optional argument.
14149
14160
14150
14161
To <dfn id="call-a-user-objects-operation" export>call a user object's operation</dfn>,
14151
14162
given a [=callback interface type=] value |value|,
14152
- operation name |opName|, [=Web IDL arguments list=] |args|, and optional
14153
- <dfn id="dfn-callback-this-value" export>callback this value</dfn> |thisArg|,
14154
- perform the following steps.
14163
+ operation name |opName|, [=Web IDL arguments list=] |args|, optional
14164
+ <dfn id="dfn-callback-this-value" export>callback this value</dfn> |thisArg|, and
14165
+ an optional [=boolean=] |useCreationTimeAsyncContext|, perform the following steps.
14155
14166
These steps will either return an IDL value or throw an exception.
14156
14167
14168
+ 1. If |useCreationTimeAsyncContext| was not given, let |useCreationTimeAsyncContext| be false.
14157
14169
1. Let |completion| be an uninitialized variable.
14158
14170
1. If |thisArg| was not given, let |thisArg| be <emu-val>undefined</emu-val>.
14159
14171
1. Let |O| be the ECMAScript object corresponding to |value|.
14160
14172
1. Let |realm| be |O|'s [=associated realm=].
14161
14173
1. Let |relevant settings| be |realm|'s [=realm/settings object=].
14162
- 1. Let |stored settings| be |value|'s [=callback context=].
14174
+ 1. Let (|stored settings|, |async context mapping|) be |value|'s [=callback context=].
14175
+ 1. If |useCreationTimeAsyncContext| is true, then:
14176
+ 1. Let |previous async context mapping| be [$AsyncContextSwap$](|async context mapping|).
14163
14177
1. [=Prepare to run script=] with |relevant settings|.
14164
14178
1. [=Prepare to run a callback=] with |stored settings|.
14165
14179
1. Let |X| be |O|.
@@ -14188,6 +14202,8 @@ the special value “missing”, which represents a missing optional argument.
14188
14202
point |completion| will be set to an IDL value or an [=abrupt completion=].
14189
14203
1. [=Clean up after running a callback=] with |stored settings|.
14190
14204
1. [=Clean up after running script=] with |relevant settings|.
14205
+ 1. If |useCreationTimeAsyncContext| is true, then:
14206
+ 1. [$AsyncContextSwap$](|previous async context mapping|).
14191
14207
1. If |completion| is an IDL value, return |completion|.
14192
14208
1. If |completion| is an [=abrupt completion=] and the operation has a [=return type=]
14193
14209
that is <em>not</em> a [=promise type=], throw |completion|.\[[Value]].
@@ -14245,12 +14261,13 @@ described in the previous section).
14245
14261
14246
14262
To <dfn id="invoke-a-callback-function" export>invoke</dfn> a
14247
14263
[=callback function type=] value |callable| with a [=Web IDL arguments list=] |args|
14248
- and an optional [=callback this value|callback this value=] |thisArg|,
14249
- perform the following steps.
14264
+ and an optional [=callback this value|callback this value=] |thisArg|, and
14265
+ an optional [=boolean=] |useCreationTimeAsyncContext|, perform the following steps.
14250
14266
These steps will either return an IDL value or throw an exception.
14251
14267
14252
14268
1. Let |completion| be an uninitialized variable.
14253
14269
1. If |thisArg| was not given, let |thisArg| be <emu-val>undefined</emu-val>.
14270
+ 1. If |useCreationTimeAsyncContext| was not given, let |useCreationTimeAsyncContext| be false.
14254
14271
1. Let |F| be the ECMAScript object corresponding to |callable|.
14255
14272
1. If <a abstract-op>IsCallable</a>(|F|) is <emu-val>false</emu-val>:
14256
14273
1. Note: This is only possible when the [=callback function=] came from an attribute
@@ -14259,7 +14276,9 @@ described in the previous section).
14259
14276
<emu-val>undefined</emu-val> to the callback function's return type.
14260
14277
1. Let |realm| be |F|'s [=associated realm=].
14261
14278
1. Let |relevant settings| be |realm|'s [=realm/settings object=].
14262
- 1. Let |stored settings| be |callable|'s [=callback context=].
14279
+ 1. Let (|stored settings|, |async context mapping|) be |callable|'s [=callback context=].
14280
+ 1. If |useCreationTimeAsyncContext| is true, then:
14281
+ 1. Let |previous async context mapping| be [$AsyncContextSwap$](|async context mapping|).
14263
14282
1. [=Prepare to run script=] with |relevant settings|.
14264
14283
1. [=Prepare to run a callback=] with |stored settings|.
14265
14284
1. Let |esArgs| be the result of [=Web IDL arguments list/converting=] |args| to an ECMAScript
@@ -14277,6 +14296,8 @@ described in the previous section).
14277
14296
point |completion| will be set to an IDL value or an [=abrupt completion=].
14278
14297
1. [=Clean up after running a callback=] with |stored settings|.
14279
14298
1. [=Clean up after running script=] with |relevant settings|.
14299
+ 1. If |useCreationTimeAsyncContext| is true, then:
14300
+ 1. [$AsyncContextSwap$](|previous async context mapping|).
14280
14301
1. If |completion| is an IDL value, return |completion|.
14281
14302
1. If |completion| is an [=abrupt completion=] and the callback function has a
14282
14303
[=return type=] that is <em>not</em> a [=promise type=], throw |completion|.\[[Value]].
@@ -14292,17 +14313,20 @@ a return type that is a [=promise type=].
14292
14313
<div algorithm>
14293
14314
14294
14315
To <dfn id="construct-a-callback-function" export>construct</dfn> a
14295
- [=callback function type=] value |callable| with a [=Web IDL arguments list=] |args|,
14296
- perform the following steps.
14316
+ [=callback function type=] value |callable| with a [=Web IDL arguments list=] |args|, and
14317
+ an optional [=boolean=] |useCreationTimeAsyncContext|, perform the following steps.
14297
14318
These steps will either return an IDL value or throw an exception.
14298
14319
14320
+ 1. If |useCreationTimeAsyncContext| was not given, let |useCreationTimeAsyncContext| be false.
14299
14321
1. Let |completion| be an uninitialized variable.
14300
14322
1. Let |F| be the ECMAScript object corresponding to |callable|.
14301
14323
1. If <a abstract-op>IsConstructor</a>(|F|) is <emu-val>false</emu-val>, throw a
14302
14324
<l spec=ecmascript>{{TypeError}}</l> exception.
14303
14325
1. Let |realm| be |F|'s [=associated realm=].
14304
14326
1. Let |relevant settings| be |realm|'s [=realm/settings object=].
14305
- 1. Let |stored settings| be |callable|'s [=callback context=].
14327
+ 1. Let (|stored settings|, |async context mapping|) be |callable|'s [=callback context=].
14328
+ 1. If |useCreationTimeAsyncContext| is true, then:
14329
+ 1. Let |previous async context mapping| be [$AsyncContextSwap$](|async context mapping|).
14306
14330
1. [=Prepare to run script=] with |relevant settings|.
14307
14331
1. [=Prepare to run a callback=] with |stored settings|.
14308
14332
1. Let |esArgs| be the result of [=Web IDL arguments list/converting=] |args| to an ECMAScript
@@ -14320,6 +14344,8 @@ a return type that is a [=promise type=].
14320
14344
point |completion| will be set to an IDL value or an [=abrupt completion=].
14321
14345
1. [=Clean up after running a callback=] with |stored settings|.
14322
14346
1. [=Clean up after running script=] with |relevant settings|.
14347
+ 1. If |useCreationTimeAsyncContext| is true, then:
14348
+ 1. [$AsyncContextSwap$](|previous async context mapping|).
14323
14349
1. If |completion| is an [=abrupt completion=], throw |completion|.\[[Value]].
14324
14350
1. Return |completion|.
14325
14351
</div>
0 commit comments