Skip to content

Commit f5ea9b8

Browse files
committed
Propagate active script to callbacks
See discussion in tc39/ecma262#2086 (comment).
1 parent 318315c commit f5ea9b8

File tree

1 file changed

+38
-42
lines changed

1 file changed

+38
-42
lines changed

index.bs

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,7 @@ spec: ecma-262; type: dfn; for: /; text:realm
4040
</pre>
4141

4242
<pre class="anchors">
43-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_astc/; spec: WEBGL_compressed_texture_astc
44-
type: interface; text: WEBGL_compressed_texture_astc
45-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_s3tc_srgb/; spec: WEBGL_compressed_texture_s3tc_srgb
46-
type: interface; text: WEBGL_compressed_texture_s3tc_srgb
47-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/WEBGL_draw_buffers/; spec: WEBGL_draw_buffers
48-
type: interface; text: WEBGL_draw_buffers
49-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/WEBGL_lose_context/; spec: WEBGL_lose_context
50-
type: interface; text: WEBGL_lose_context
51-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/; spec: ANGLE_instanced_arrays
52-
type: interface; text: ANGLE_instanced_arrays
53-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/EXT_blend_minmax/; spec: EXT_blend_minmax
54-
type: interface; text: EXT_blend_minmax
55-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/EXT_color_buffer_float/; spec: EXT_color_buffer_float
56-
type: interface; text: EXT_color_buffer_float
57-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/EXT_disjoint_timer_query/; spec: EXT_disjoint_timer_query
58-
type: interface; text: EXT_disjoint_timer_query
59-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/OES_standard_derivatives/; spec: OES_standard_derivatives
60-
type: interface; text: OES_standard_derivatives
61-
urlPrefix: https://www.khronos.org/registry/webgl/extensions/OES_vertex_array_object/; spec: OES_vertex_array_object
62-
type: interface; text: OES_vertex_array_object
63-
urlPrefix: https://www.w3.org/TR/geolocation-API/; spec: GEOLOCATION-API
64-
type: interface
65-
text: Geolocation; url: geolocation;
66-
text: Coordinates; url: coordinates;
67-
text: Position; url: position;
68-
text: PositionError; url: position-error;
69-
urlPrefix: https://w3c.github.io/deviceorientation/spec-source-orientation.html; spec: ORIENTATION-EVENT
70-
type: interface
71-
text: DeviceRotationRate; url: device_rotation_rate;
72-
text: DeviceAcceleration; url: device_acceleration;
73-
urlPrefix: https://w3c.github.io/mediacapture-main/; spec: MEDIACAPTURE-STREAMS
74-
type: interface
75-
text: ConstrainablePattern; url: dom-constrainablepattern;
43+
url: https://html.spec.whatwg.org/multipage/webappapis.html#active-script; spec: HTML; type: dfn; text: active script
7644
urlPrefix: http://www.unicode.org/glossary/; spec: UNICODE
7745
type: dfn
7846
text: Unicode scalar value; url: unicode_scalar_value
@@ -6253,8 +6221,8 @@ about the execution context at the time the language binding specific object ref
62536221
converted to an IDL value.
62546222

62556223
Note: For ECMAScript objects, the [=callback context=] is used to hold a reference to the
6256-
[=incumbent settings object=] at the time the Object value is converted to an IDL callback
6257-
interface type value. See [[#es-callback-interface]].
6224+
[=incumbent settings object=] and [=active script=] at the time the Object value is converted to an
6225+
IDL callback interface type value. See [[#es-callback-interface]].
62586226

62596227
There is no way to represent a constant object reference value for a particular
62606228
[=callback interface type=] in IDL.
@@ -6314,7 +6282,7 @@ An IDL value of the callback function type is represented by a tuple of an objec
63146282
reference and a [=callback context=].
63156283

63166284
Note: As with [=callback interface types=], the [=callback context=] is used to hold a
6317-
reference to the [=incumbent settings object=] at
6285+
reference to the [=incumbent settings object=] and [=active script=] at
63186286
the time an ECMAScript Object value is converted to an IDL
63196287
callback function type value. See [[#es-callback-function]].
63206288

@@ -7922,7 +7890,8 @@ values are represented by ECMAScript Object values (including [=function objects
79227890

79237891
1. If <a abstract-op>Type</a>(|V|) is not Object, then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
79247892
1. Return the IDL [=callback interface type=] value that represents a reference to |V|, with
7925-
the [=incumbent settings object=] as the [=callback context=].
7893+
the [=tuple=] (the [=incumbent settings object=], the [=active script=]) as the
7894+
[=callback context=].
79267895
</div>
79277896

79287897
<p id="callback-interface-to-es">
@@ -8043,8 +8012,8 @@ IDL [=callback function types=] are represented by ECMAScript [=function objects
80438012
that is annotated with [{{LegacyTreatNonObjectAsNull}}],
80448013
then [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
80458014
1. Return the IDL [=callback function type=] value
8046-
that represents a reference to the same object that |V| represents, with the
8047-
[=incumbent settings object=] as the [=callback context=].
8015+
that represents a reference to the same object that |V| represents, with the tuple
8016+
(the [=incumbent settings object=], the [=active script=]) as the [=callback context=].
80488017
</div>
80498018

80508019
<p id="callback-function-to-es">
@@ -13888,9 +13857,16 @@ the special value “missing”, which represents a missing optional argument.
1388813857
1. Let |O| be the ECMAScript object corresponding to |value|.
1388913858
1. Let |realm| be |O|'s [=associated Realm=].
1389013859
1. Let |relevant settings| be |realm|'s [=Realm/settings object=].
13891-
1. Let |stored settings| be |value|'s [=callback context=].
13860+
1. Let (|stored settings|, |active script|) be |value|'s [=callback context=].
1389213861
1. [=Prepare to run script=] with |relevant settings|.
1389313862
1. [=Prepare to run a callback=] with |stored settings|.
13863+
1. Set |script execution context| to null.
13864+
1. If |active script| is not null:
13865+
1. Set |script execution context| to a new [=ECMAScript code execution context=], whose
13866+
[=Execution context/Function=] is <emu-val>null</emu-val>, [=Execution context/Realm=]
13867+
is |active script|'s [=script/settings object=]'s [=environment settings object/Realm=],
13868+
and [=Execution context/ScriptOrModule=] is |active script|'s [=script/record=].
13869+
1. Push |script execution context| onto the [=execution context stack=].
1389413870
1. Let |X| be |O|.
1389513871
1. If [=!=] <a abstract-op>IsCallable</a>(|O|) is false, then:
1389613872
1. Let |getResult| be <a abstract-op>Get</a>(|O|, |opName|).
@@ -13914,6 +13890,8 @@ the special value “missing”, which represents a missing optional argument.
1391413890
return type.
1391513891
1. <i id="call-user-object-operation-return">Return:</i> at this
1391613892
point |completion| will be set to an ECMAScript completion value.
13893+
1. If |script execution context| is not null, then pop |script execution context| from
13894+
the [=execution context stack=].
1391713895
1. [=Clean up after running a callback=] with |stored settings|.
1391813896
1. [=Clean up after running script=] with |relevant settings|.
1391913897
1. If |completion| is a normal completion, return |completion|.
@@ -13988,9 +13966,16 @@ described in the previous section).
1398813966
<emu-val>undefined</emu-val> to the callback function's return type.
1398913967
1. Let |realm| be |F|'s [=associated Realm=].
1399013968
1. Let |relevant settings| be |realm|'s [=Realm/settings object=].
13991-
1. Let |stored settings| be |callable|'s [=callback context=].
13969+
1. Let (|stored settings|, |active script|) be |callable|'s [=callback context=].
1399213970
1. [=Prepare to run script=] with |relevant settings|.
1399313971
1. [=Prepare to run a callback=] with |stored settings|.
13972+
1. Set |script execution context| to null.
13973+
1. If |active script| is not null:
13974+
1. Set |script execution context| to a new [=ECMAScript code execution context=], whose
13975+
[=Execution context/Function=] is <emu-val>null</emu-val>, [=Execution context/Realm=]
13976+
is |active script|'s [=script/settings object=]'s [=environment settings object/Realm=],
13977+
and [=Execution context/ScriptOrModule=] is |active script|'s [=script/record=].
13978+
1. Push |script execution context| onto the [=execution context stack=].
1399413979
1. Let |esArgs| be the result of [=Web IDL arguments list/converting=] |args| to an ECMAScript
1399513980
arguments list. If this throws an exception, set |completion| to the completion value
1399613981
representing the thrown exception and jump to the step labeled
@@ -14003,6 +13988,8 @@ described in the previous section).
1400313988
return type.
1400413989
1. <i id="invoke-return">Return:</i> at this
1400513990
point |completion| will be set to an ECMAScript completion value.
13991+
1. If |script execution context| is not null, then pop |script execution context| from
13992+
the [=execution context stack=].
1400613993
1. [=Clean up after running a callback=] with |stored settings|.
1400713994
1. [=Clean up after running script=] with |relevant settings|.
1400813995
1. If |completion| is a normal completion, return |completion|.
@@ -14030,9 +14017,16 @@ a return type that is a [=promise type=].
1403014017
{{ECMAScript/TypeError}} exception.
1403114018
1. Let |realm| be |F|'s [=associated Realm=].
1403214019
1. Let |relevant settings| be |realm|'s [=Realm/settings object=].
14033-
1. Let |stored settings| be |callable|'s [=callback context=].
14020+
1. Let (|stored settings|, |active script|) be |callable|'s [=callback context=].
1403414021
1. [=Prepare to run script=] with |relevant settings|.
1403514022
1. [=Prepare to run a callback=] with |stored settings|.
14023+
1. Set |script execution context| to null.
14024+
1. If |active script| is not null:
14025+
1. Set |script execution context| to a new [=ECMAScript code execution context=], whose
14026+
[=Execution context/Function=] is <emu-val>null</emu-val>, [=Execution context/Realm=]
14027+
is |active script|'s [=script/settings object=]'s [=environment settings object/Realm=],
14028+
and [=Execution context/ScriptOrModule=] is |active script|'s [=script/record=].
14029+
1. Push |script execution context| onto the [=execution context stack=].
1403614030
1. Let |esArgs| be the result of [=Web IDL arguments list/converting=] |args| to an ECMAScript
1403714031
arguments list. If this throws an exception, set |completion| to the completion value
1403814032
representing the thrown exception and jump to the step labeled
@@ -14045,6 +14039,8 @@ a return type that is a [=promise type=].
1404514039
return type.
1404614040
1. <i id="construct-return">Return:</i> at this
1404714041
point |completion| will be set to an ECMAScript completion value.
14042+
1. If |script execution context| is not null, then pop |script execution context| from
14043+
the [=execution context stack=].
1404814044
1. [=Clean up after running a callback=] with |stored settings|.
1404914045
1. [=Clean up after running script=] with |relevant settings|.
1405014046
1. Return |completion|.

0 commit comments

Comments
 (0)