@@ -72,6 +72,12 @@ urlPrefix: https://tc39.es/ecma262/; spec: ecmascript
7272urlPrefix: https://tc39.es/proposal-resizablearraybuffer/; spec: RESIZABLE-BUFFERS-PROPOSAL
7373 type: abstract-op
7474 text: IsResizableArrayBuffer; url: sec-isresizablearraybuffer
75+ urlPrefix: https://tc39.es/proposal-async-context/; spec: RESIZABLE-BUFFERS-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
7581</pre>
7682
7783<style>
@@ -6013,8 +6019,9 @@ about the execution context at the time the language binding specific object ref
60136019converted to an IDL value.
60146020
60156021Note: 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]].
60186025
60196026There is no way to represent a constant object reference value for a particular
60206027[=callback interface type=] in IDL.
@@ -6061,10 +6068,10 @@ the [=callback function=], the values can be references to objects that are not
60616068An IDL value of the callback function type is represented by a tuple of an object
60626069reference and a [=callback context=].
60636070
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]].
60686075
60696076There is no way to represent a constant [=callback function=]
60706077value in IDL.
@@ -7671,8 +7678,10 @@ values are represented by ECMAScript Object values (including [=function objects
76717678 to an IDL [=callback interface type=] value by running the following algorithm:
76727679
76737680 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$]().
76747683 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=].
76767685</div>
76777686
76787687<p id="callback-interface-to-es">
@@ -7792,9 +7801,11 @@ IDL [=callback function types=] are represented by ECMAScript [=function objects
77927801 [=callback function=]
77937802 that is annotated with [{{LegacyTreatNonObjectAsNull}}],
77947803 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$]().
77957806 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=].
77987809</div>
77997810
78007811<p id="callback-function-to-es">
@@ -14149,8 +14160,9 @@ the special value “missing”, which represents a missing optional argument.
1414914160
1415014161 To <dfn id="call-a-user-objects-operation" export>call a user object's operation</dfn>,
1415114162 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|,
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+ optional [=list=] of [=Async Context Mapping Records=] |caller async context mapping|,
1415414166 perform the following steps.
1415514167 These steps will either return an IDL value or throw an exception.
1415614168
@@ -14159,7 +14171,10 @@ the special value “missing”, which represents a missing optional argument.
1415914171 1. Let |O| be the ECMAScript object corresponding to |value|.
1416014172 1. Let |realm| be |O|'s [=associated realm=].
1416114173 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 |caller async context mapping| is present, then:
14176+ 1. Set |async context mapping| to |caller async context mapping|.
14177+ 1. Let |previous async context mapping| be [$AsyncContextSwap$](|async context mapping|).
1416314178 1. [=Prepare to run script=] with |relevant settings|.
1416414179 1. [=Prepare to run a callback=] with |stored settings|.
1416514180 1. Let |X| be |O|.
@@ -14188,6 +14203,7 @@ the special value “missing”, which represents a missing optional argument.
1418814203 point |completion| will be set to an IDL value or an [=abrupt completion=].
1418914204 1. [=Clean up after running a callback=] with |stored settings|.
1419014205 1. [=Clean up after running script=] with |relevant settings|.
14206+ 1. [$AsyncContextSwap$](|previous async context mapping|).
1419114207 1. If |completion| is an IDL value, return |completion|.
1419214208 1. If |completion| is an [=abrupt completion=] and the operation has a [=return type=]
1419314209 that is <em>not</em> a [=promise type=], throw |completion|.\[[Value]].
@@ -14245,7 +14261,8 @@ described in the previous section).
1424514261
1424614262 To <dfn id="invoke-a-callback-function" export>invoke</dfn> a
1424714263 [=callback function type=] value |callable| with a [=Web IDL arguments list=] |args|
14248- and an optional [=callback this value|callback this value=] |thisArg|,
14264+ and an optional [=callback this value|callback this value=] |thisArg|, and
14265+ optional [=list=] of [=Async Context Mapping Records=] |caller async context mapping|,
1424914266 perform the following steps.
1425014267 These steps will either return an IDL value or throw an exception.
1425114268
@@ -14259,7 +14276,10 @@ described in the previous section).
1425914276 <emu-val>undefined</emu-val> to the callback function's return type.
1426014277 1. Let |realm| be |F|'s [=associated realm=].
1426114278 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 |caller async context mapping| is present, then:
14281+ 1. Set |async context mapping| to |caller async context mapping|.
14282+ 1. Let |previous async context mapping| be [$AsyncContextSwap$](|async context mapping|).
1426314283 1. [=Prepare to run script=] with |relevant settings|.
1426414284 1. [=Prepare to run a callback=] with |stored settings|.
1426514285 1. Let |esArgs| be the result of [=Web IDL arguments list/converting=] |args| to an ECMAScript
@@ -14277,6 +14297,7 @@ described in the previous section).
1427714297 point |completion| will be set to an IDL value or an [=abrupt completion=].
1427814298 1. [=Clean up after running a callback=] with |stored settings|.
1427914299 1. [=Clean up after running script=] with |relevant settings|.
14300+ 1. [$AsyncContextSwap$](|previous async context mapping|).
1428014301 1. If |completion| is an IDL value, return |completion|.
1428114302 1. If |completion| is an [=abrupt completion=] and the callback function has a
1428214303 [=return type=] that is <em>not</em> a [=promise type=], throw |completion|.\[[Value]].
@@ -14292,7 +14313,8 @@ a return type that is a [=promise type=].
1429214313<div algorithm>
1429314314
1429414315 To <dfn id="construct-a-callback-function" export>construct</dfn> a
14295- [=callback function type=] value |callable| with a [=Web IDL arguments list=] |args|,
14316+ [=callback function type=] value |callable| with a [=Web IDL arguments list=] |args|, and
14317+ optional [=list=] of [=Async Context Mapping Records=] |caller async context mapping|,
1429614318 perform the following steps.
1429714319 These steps will either return an IDL value or throw an exception.
1429814320
@@ -14302,7 +14324,10 @@ a return type that is a [=promise type=].
1430214324 <l spec=ecmascript>{{TypeError}}</l> exception.
1430314325 1. Let |realm| be |F|'s [=associated realm=].
1430414326 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 |caller async context mapping| is present, then:
14329+ 1. Set |async context mapping| to |caller async context mapping|.
14330+ 1. Let |previous async context mapping| be [$AsyncContextSwap$](|async context mapping|).
1430614331 1. [=Prepare to run script=] with |relevant settings|.
1430714332 1. [=Prepare to run a callback=] with |stored settings|.
1430814333 1. Let |esArgs| be the result of [=Web IDL arguments list/converting=] |args| to an ECMAScript
@@ -14320,6 +14345,7 @@ a return type that is a [=promise type=].
1432014345 point |completion| will be set to an IDL value or an [=abrupt completion=].
1432114346 1. [=Clean up after running a callback=] with |stored settings|.
1432214347 1. [=Clean up after running script=] with |relevant settings|.
14348+ 1. [$AsyncContextSwap$](|previous async context mapping|).
1432314349 1. If |completion| is an [=abrupt completion=], throw |completion|.\[[Value]].
1432414350 1. Return |completion|.
1432514351</div>
0 commit comments