Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[editorial] dfn worker's outside/inside port, and clarify event retargeting #10738

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -120449,17 +120449,15 @@ enum <dfn enum>WorkerType</dfn> { "classic", "module" };

<div w-nodev>

<p>Each <code>Worker</code> object has an associated <dfn for="Worker">outside port</dfn> (a
<code>MessagePort</code>). This port is part of a channel that is set up when the worker is
created, but it is not exposed. This object must never be garbage collected before the
<code>Worker</code> object.</p>

<p>The <dfn method for="Worker"><code data-x="dom-Worker-terminate">terminate()</code></dfn>
method, when invoked, must cause the <span>terminate a worker</span> algorithm to be run on the
worker with which the object is associated.</p>

<p><code>Worker</code> objects act as if they had an implicit <code>MessagePort</code> associated
with them. This port is part of a channel that is set up when the worker is created, but it is not
exposed. This object must never be garbage collected before the <code>Worker</code> object.</p>

<p>All messages received by that port must immediately be retargeted at the <code>Worker</code>
object.</p>

<p>The <dfn method for="Worker"><code
data-x="dom-Worker-postMessage">postMessage(<var>message</var>, <var>transfer</var>)</code></dfn>
and <dfn method for="Worker"><code
Expand All @@ -120468,8 +120466,8 @@ enum <dfn enum>WorkerType</dfn> { "classic", "module" };
they immediately invoked the respective <code
data-x="dom-MessagePort-postMessage">postMessage(<var>message</var>, <var>transfer</var>)</code>
and <code data-x="dom-MessagePort-postMessage-options">postMessage(<var>message</var>,
<var>options</var>)</code> on the port, with the same arguments, and returned the same return
value.</p>
<var>options</var>)</code> on <span>this</span>'s <span>outside port</span>, with the same
arguments, and returned the same return value.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point this should really be defined to invoke some internal algorithm instead of the public method.


</div>

Expand Down Expand Up @@ -120530,7 +120528,28 @@ enum <dfn enum>WorkerType</dfn> { "classic", "module" };
<li><p>Let <var>outside port</var> be a <span>new</span> <code>MessagePort</code> in <var>outside
settings</var>'s <span data-x="environment settings object's realm">realm</span>.</p></li>

<li><p>Associate the <var>outside port</var> with <var>worker</var>.</p></li>
<li><p>Set <var>worker</var>'s <span>outside port</span> to <var>outside port</var>.</p></li>

<li><p>Let <var>messageCallback</var> be the result of creating a Web IDL <code
data-x="dom-EventListener">EventListener</code> instance representing a reference to a function
of one argument <var>event</var> (a <span>MessageEvent</span>) that, when called, <span
data-x="concept-event-dispatch">dispatches</span> <var>event</var> at
<var>worker</var>.</p></li>

<li>
<p><span>Add an event listener</span> with <var>outside port</var> and a new <span>event
listener</span> whose <span data-x="event listener type">type</span> is "<code
data-x="event-message">message</code>" and <span data-x="event listener
callback">callback</span> is <var>messageCallback</var>.</p>

<p class="note">An <span>event listener</span> is different from an <code
data-x="dom-EventListener">EventListener</code>.</p>
</li>

<li><p><span>Add an event listener</span> with <var>outside port</var> and a new <span>event
listener</span> whose <span data-x="event listener type">type</span> is "<code
data-x="event-messageerror">messageerror</code>" and <span data-x="event listener
callback">callback</span> is <var>messageCallback</var>.</p></li>

<li>
<p>Run this step <span>in parallel</span>:</p>
Expand Down