Skip to content

Commit 52c3ca8

Browse files
authored
Clarify that "this" is not available while in parallel
Fixes #11110, by clarifying that Web IDL's this value is not available from steps running in parallel, even if those steps were kicked off my a non-parallel algorithm that _can_ access "this". Clarify this in the parallelism example, and in prose about how to operate from while parallel, and fix all cases of "this's relevant _foo_" being used improperly from parallel steps, which is a good start to setting the right precedent.
1 parent 0cff288 commit 52c3ca8

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

source

+44-32
Original file line numberDiff line numberDiff line change
@@ -1637,23 +1637,25 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
16371637
<li><p>Let <var>p</var> be a new promise created in <span>this</span>'s <span
16381638
data-x="concept-relevant-realm">relevant realm</span>.</p></li>
16391639

1640+
<li><p>Let <var>global</var> be <span>this</span>'s <span>relevant global
1641+
object</span>.</p></li>
1642+
16401643
<li>
16411644
<p>Run the following steps <span>in parallel</span>:</p>
16421645

16431646
<ol>
16441647
<li><p>If <var>nameList</var> <span data-x="list contains">contains</span> <var>name</var>,
16451648
then <span>queue a global task</span> on the <span>DOM manipulation task source</span> given
1646-
<span>this</span>'s <span>relevant global object</span> to reject <var>p</var> with a
1647-
<code>TypeError</code>, and abort these steps.</p></li>
1649+
<var>global</var> to reject <var>p</var> with a <code>TypeError</code>, and abort these
1650+
steps.</p></li>
16481651

16491652
<li><p>Do some potentially lengthy work.</p></li>
16501653

16511654
<li><p><span data-x="list append">Append</span> <var>name</var> to
16521655
<var>nameList</var>.</p></li>
16531656

1654-
<li><p><span>Queue a global task</span> on the <span>DOM manipulation task source</span>
1655-
given <span>this</span>'s <span>relevant global object</span> to resolve <var>p</var> with
1656-
undefined.</p></li>
1657+
<li><p><span>Queue a global task</span> on the <span>DOM manipulation task source</span> given
1658+
<var>global</var> to resolve <var>p</var> with undefined.</p></li>
16571659
</ol>
16581660
</li>
16591661

@@ -1671,23 +1673,25 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
16711673
<li><p>Let <var>p</var> be a new promise created in <span>this</span>'s <span
16721674
data-x="concept-relevant-realm">relevant realm</span>.</p></li>
16731675

1676+
<li><p>Let <var>global</var> be <span>this</span>'s <span>relevant global
1677+
object</span>.</p></li>
1678+
16741679
<li>
16751680
<p><mark><span>Enqueue the following steps</span> to <var>nameListQueue</var>:</mark></p>
16761681

16771682
<ol>
16781683
<li><p>If <var>nameList</var> <span data-x="list contains">contains</span> <var>name</var>,
16791684
then <span>queue a global task</span> on the <span>DOM manipulation task source</span> given
1680-
<span>this</span>'s <span>relevant global object</span> to reject <var>p</var> with a
1681-
<code>TypeError</code>, and abort these steps.</p></li>
1685+
<var>global</var> to reject <var>p</var> with a <code>TypeError</code>, and abort these
1686+
steps.</p></li>
16821687

16831688
<li><p>Do some potentially lengthy work.</p></li>
16841689

16851690
<li><p><span data-x="list append">Append</span> <var>name</var> to
16861691
<var>nameList</var>.</p></li>
16871692

1688-
<li><p><span>Queue a global task</span> on the <span>DOM manipulation task source</span>
1689-
given <span>this</span>'s <span>relevant global object</span> to resolve <var>p</var> with
1690-
undefined.</p></li>
1693+
<li><p><span>Queue a global task</span> on the <span>DOM manipulation task source</span> given
1694+
<var>global</var> to resolve <var>p</var> with undefined.</p></li>
16911695
</ol>
16921696
</li>
16931697

@@ -72160,6 +72164,8 @@ interface <dfn interface>OffscreenCanvas</dfn> : <span>EventTarget</span> {
7216072164

7216172165
<li><p>Let <var>result</var> be a new promise object.</p></li>
7216272166

72167+
<li><p>Let <var>global</var> be <span>this</span>'s <span>relevant global object</span>.</p></li>
72168+
7216372169
<li>
7216472170
<p>Run these steps <span>in parallel</span>:</p>
7216572171

@@ -72171,14 +72177,14 @@ interface <dfn interface>OffscreenCanvas</dfn> : <span>EventTarget</span> {
7217172177

7217272178
<li>
7217372179
<p><span>Queue a global task</span> on the <span>canvas blob serialization task source</span>
72174-
given <span>this</span>'s <span>relevant global object</span> to run these steps:</p>
72180+
given <var>global</var> to run these steps:</p>
7217572181

7217672182
<ol>
7217772183
<li><p>If <var>file</var> is null, then reject <var>result</var> with an
7217872184
<span>"<code>EncodingError</code>"</span> <code>DOMException</code>.</p></li>
7217972185

7218072186
<li><p>Otherwise, resolve <var>result</var> with a new <code>Blob</code> object, created in
72181-
<span>this</span>'s <span data-x="concept-relevant-realm">relevant realm</span>, representing
72187+
<var>global</var>'s <span data-x="concept-relevant-realm">relevant realm</span>, representing
7218272188
<var>file</var>. <ref>FILEAPI</ref></p></li>
7218372189
</ol>
7218472190
</li>
@@ -114024,6 +114030,10 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
114024114030
Doing so would create data races observable to JavaScript code, since after all, your algorithm
114025114031
steps are running <em><span>in parallel</span></em> to the JavaScript code.</p>
114026114032

114033+
<p>By extension, you cannot access Web IDL's <span>this</span> value from steps running <span>in
114034+
parallel</span>, even if those steps were activated by an algorithm that <em>does</em> have access
114035+
to the <span>this</span> value.</p>
114036+
114027114037
<p>You can, however, manipulate specification-level data structures and values from
114028114038
<cite>Infra</cite>, as those are realm-agnostic. They are never directly exposed to JavaScript without
114029114039
a specific conversion taking place (often <span data-x="concept-idl-convert">via Web IDL</span>).
@@ -123951,48 +123961,50 @@ dictionary <dfn dictionary>WorkletOptions</dfn> {
123951123961

123952123962
<li><p>Let <var>promise</var> be a new promise.</p></li>
123953123963

123964+
<li><p>Let <var>workletInstance</var> be <span>this</span>.</p></li>
123965+
123954123966
<li>
123955123967
<p>Run the following steps <span>in parallel</span>:</p>
123956123968

123957123969
<ol>
123958123970
<li>
123959-
<p>If <span>this</span>'s <span data-x="concept-Worklet-global-scopes">global scopes</span>
123960-
<span data-x="list is empty">is empty</span>, then:</p>
123971+
<p>If <var>workletInstance</var>'s <span data-x="concept-Worklet-global-scopes">global
123972+
scopes</span> <span data-x="list is empty">is empty</span>, then:</p>
123961123973

123962123974
<ol>
123963-
<li><p><span>Create a worklet global scope</span> given <span>this</span>.</p></li>
123975+
<li><p><span>Create a worklet global scope</span> given <var>workletInstance</var>.</p></li>
123964123976

123965123977
<li><p>Optionally, <span data-x="create a worklet global scope">create</span> additional
123966-
global scope instances given <span>this</span>, depending on the specific worklet in question
123967-
and its specification.</p></li>
123978+
global scope instances given <var>workletInstance</var>, depending on the specific worklet in
123979+
question and its specification.</p></li>
123968123980

123969123981
<li><p>Wait for all steps of the <span data-x="create a worklet global scope">creation</span>
123970123982
process(es) — including those taking place within the <span data-x="worklet agent">worklet
123971123983
agents</span> — to complete, before moving on.</p></li>
123972123984
</ol>
123973123985
</li>
123974123986

123975-
<li><p>Let <var>pendingTasks</var> be <span>this</span>'s <span
123987+
<li><p>Let <var>pendingTasks</var> be <var>workletInstance</var>'s <span
123976123988
data-x="concept-Worklet-global-scopes">global scopes</span>'s <span data-x="list
123977123989
size">size</span>.</p></li>
123978123990

123979123991
<li><p>Let <var>addedSuccessfully</var> be false.</p></li>
123980123992

123981123993
<li>
123982123994
<p><span data-x="list iterate">For each</span> <var>workletGlobalScope</var> of
123983-
<span>this</span>'s <span data-x="concept-Worklet-global-scopes">global scopes</span>,
123984-
<span>queue a global task</span> on the <span>networking task source</span> given
123985-
<var>workletGlobalScope</var> to <span>fetch a worklet script graph</span> given
123986-
<var>moduleURLRecord</var>, <var>outsideSettings</var>, <span>this</span>'s <span>worklet
123987-
destination type</span>, <var>options</var>["<code
123995+
<var>workletInstance</var>'s <span data-x="concept-Worklet-global-scopes">global
123996+
scopes</span>, <span>queue a global task</span> on the <span>networking task source</span>
123997+
given <var>workletGlobalScope</var> to <span>fetch a worklet script graph</span> given
123998+
<var>moduleURLRecord</var>, <var>outsideSettings</var>, <var>workletInstance</var>'s
123999+
<span>worklet destination type</span>, <var>options</var>["<code
123988124000
data-x="dom-WorkletOptions-credentials">credentials</code>"], <var>workletGlobalScope</var>'s
123989-
<span>relevant settings object</span>, <span>this</span>'s <span
124001+
<span>relevant settings object</span>, <var>workletInstance</var>'s <span
123990124002
data-x="concept-Worklet-module-responses-map">module responses map</span>, and the following
123991124003
steps given <var>script</var>:</p>
123992124004

123993124005
<p class="note">Only the first of these fetches will actually perform a network request; the
123994124006
ones for other <code>WorkletGlobalScope</code>s will reuse <span
123995-
data-x="concept-response">responses</span> from <span>this</span>'s <span
124007+
data-x="concept-response">responses</span> from <var>workletInstance</var>'s <span
123996124008
data-x="concept-Worklet-module-responses-map">module responses map</span>.</p>
123997124009

123998124010
<ol>
@@ -124002,7 +124014,7 @@ dictionary <dfn dictionary>WorkletOptions</dfn> {
124002124014
<ol>
124003124015
<li>
124004124016
<p><span>Queue a global task</span> on the <span>networking task source</span> given
124005-
<span>this</span>'s <span>relevant global object</span> to perform the following
124017+
<var>workletInstance</var>'s <span>relevant global object</span> to perform the following
124006124018
steps:</p>
124007124019

124008124020
<ol>
@@ -124030,7 +124042,7 @@ dictionary <dfn dictionary>WorkletOptions</dfn> {
124030124042
<ol>
124031124043
<li>
124032124044
<p><span>Queue a global task</span> on the <span>networking task source</span> given
124033-
<span>this</span>'s <span>relevant global object</span> to perform the following
124045+
<var>workletInstance</var>'s <span>relevant global object</span> to perform the following
124034124046
steps:</p>
124035124047

124036124048
<ol>
@@ -124056,8 +124068,8 @@ dictionary <dfn dictionary>WorkletOptions</dfn> {
124056124068

124057124069
<ol>
124058124070
<li><p><span data-x="list append">Append</span> <var>moduleURLRecord</var> to
124059-
<span>this</span>'s <span data-x="concept-Worklet-added-modules-list">added modules
124060-
list</span>.</p></li>
124071+
<var>workletInstance</var>'s <span data-x="concept-Worklet-added-modules-list">added
124072+
modules list</span>.</p></li>
124061124073

124062124074
<li><p>Set <var>addedSuccessfully</var> to true.</p></li>
124063124075
</ol>
@@ -124066,9 +124078,9 @@ dictionary <dfn dictionary>WorkletOptions</dfn> {
124066124078
<li><p><span>Run a module script</span> given <var>script</var>.</p></li>
124067124079

124068124080
<li>
124069-
<p><span>Queue a global task</span> on the
124070-
<span>networking task source</span> given <span>this</span>'s <span>relevant global
124071-
object</span> to perform the following steps:</p>
124081+
<p><span>Queue a global task</span> on the <span>networking task source</span> given
124082+
<var>workletInstance</var>'s <span>relevant global object</span> to perform the following
124083+
steps:</p>
124072124084

124073124085
<ol>
124074124086
<li>

0 commit comments

Comments
 (0)