Skip to content

Commit

Permalink
Add other postMessage methods on Worker, GlobalWorkerDedicatedScope.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtapuska committed Jul 30, 2018
1 parent 6cf8e04 commit 4df7974
Showing 1 changed file with 82 additions and 17 deletions.
99 changes: 82 additions & 17 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -78051,9 +78051,8 @@ interface <dfn data-export="" data-dfn-type="interface">Window</dfn> : <span>Eve

callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span> time);

dictionary <dfn>WindowPostMessageOptions</dfn> {
dictionary <dfn>WindowPostMessageOptions</dfn> : <span>PostMessageOptions</span> {
USVString targetOrigin = "/";
sequence&lt;<span data-x="idl-object">object</span>&gt; transfer = [];
};</code></pre>

<!-- for more features to add here, look here:
Expand Down Expand Up @@ -95362,16 +95361,16 @@ function receiver(e) {

<dl class="domintro">

<dt><var>window</var> . <code subdfn data-x="dom-window-postMessage">postMessage</code>(<var>message</var>[, <var>transfer</var> ] [, options ])</dt>
<dt><var>window</var> . <code subdfn data-x="dom-window-postMessage">postMessage</code>(<var>message</var>[, <var>options</var> ])</dt>

<dd>
<p>Posts a message to the given window. Messages can be structured objects, e.g. nested objects
and arrays, can contain JavaScript values (strings, numbers, <code>Date</code>
objects, etc), and can contain certain data objects such as <code>File</code> <code>Blob</code>,
<code>FileList</code>, and <code data-x="idl-ArrayBuffer">ArrayBuffer</code> objects.</p>

<p>Objects listed in <var>transfer</var> are transferred, not just cloned, meaning that
they are no longer usable on the sending side.</p>
<p>Objects listed specific using the <code data-x="">transfer</code> member of <var>options</var>
are transferred, not just cloned, meaning that they are no longer usable on the sending side.</p>

<p>A target origin can be specified using the <code data-x="">targetOrigin</code> member of
<var>options</var>. If not provided, it defaults to "<code data-x="">/</code>". This restricts
Expand Down Expand Up @@ -95809,12 +95808,17 @@ interface <dfn>MessageChannel</dfn> {
<pre><code class="idl" data-x="">[Exposed=(Window,Worker,AudioWorklet), <span>Transferable</span>]
interface <dfn>MessagePort</dfn> : <span>EventTarget</span> {
void <span data-x="dom-MessagePort-postMessage">postMessage</span>(any message, optional sequence&lt;<span data-x="idl-object">object</span>&gt; transfer = []);
void <span data-x="dom-MessagePort-postMessage-options">postMessage</span>(any message, optional <span>PostMessageOptions</span> options);
void <span data-x="dom-MessagePort-start">start</span>();
void <span data-x="dom-MessagePort-close">close</span>();

// event handlers
attribute <span>EventHandler</span> <span data-x="handler-MessagePort-onmessage">onmessage</span>;
attribute <span>EventHandler</span> <span data-x="handler-MessagePort-onmessageerror">onmessageerror</span>;
};

dictionary <dfn>PostMessageOptions</dfn> {
sequence&lt;<span data-x="idl-object">object</span>&gt; transfer = [];
};</code></pre>

<dl class="domintro">
Expand All @@ -95828,6 +95832,16 @@ interface <dfn>MessagePort</dfn> : <span>EventTarget</span> {
could not be cloned.</p>
</dd>

<dt><var>port</var> . <code subdfn data-x="dom-MessagePort-postMessage-options">postMessage</code>(<var>message</var> [, <var>options</var>] )</dt>
<dd>
<p>Posts a message through the channel. Objects listed in <var>transfer</var> are
transferred, not just cloned, meaning that they are no longer usable on the sending side.</p>

<p>Throws a <span>"<code>DataCloneError</code>"</span> <code>DOMException</code> if
<var>transfer</var> contains duplicate objects or <var>port</var>, or if <var>message</var>
could not be cloned.</p>
</dd>

<dt><var>port</var> . <code subdfn data-x="dom-MessagePort-start">start</code>()</dt>
<dd><p>Begins dispatching messages received on the port.</p></dd>

Expand Down Expand Up @@ -95970,13 +95984,12 @@ interface <dfn>MessagePort</dfn> : <span>EventTarget</span> {

<hr>

<p>The <dfn><code data-x="dom-MessagePort-postMessage">postMessage(<var>message</var>,
<var>transfer</var>)</code></dfn> method, when invoked on a <code>MessagePort</code> object, must
run the following steps:</p>
<p>The <dfn>message port post message steps</dfn>, given a <var>targetPort</var>, <var>message</var>
and <var>options</var> are as follows:</p>

<ol> <!-- a lot of this is similar or identical to window.postMessage -->
<li><p>Let <var>targetPort</var> be the port with which this <code>MessagePort</code> is
entangled, if any; otherwise let it be null.</p></li>
<li><p>Let <var>transfer</var> be the value of <var>options</var>'s <code
data-x="">transfer</code> member.</p></li>

<li><p>If <var>transfer</var> <span data-x="list contains">contains</span> this
<code>MessagePort</code>, then throw a <span>"<code>DataCloneError</code>"</span>
Expand Down Expand Up @@ -96045,6 +96058,39 @@ interface <dfn>MessagePort</dfn> : <span>EventTarget</span> {

<hr>

<p>The <dfn><code data-x="dom-MessagePort-postMessage-options">postMessage(<var>message</var>,
<var>options</var>)</code></dfn> method, when invoked on a
<code>MessagePort</code> object must run the following steps:</p>
<ol>
<li><p>Let <var>targetPort</var> be the port with which this <code>MessagePort</code> is
entangled, if any; otherwise let it be null.</p></li>

<li><p>Run the <span>message port post message steps</span> providing <var>targetPort</var>,
<var>message</var> and <var>options</var>.</p></li>
</ol>

<hr>

<p>The <dfn><code data-x="dom-MessagePort-postMessage">postMessage(<var>message</var>,
<var>transfer</var>)</code></dfn> method, when invoked on a <code>MessagePort</code> object
must run the following steps:</p>

<ol>
<li><p>Let <var>targetPort</var> be the port with which this <code>MessagePort</code> is
entangled, if any; otherwise let it be null.</p></li>

<li><p>Let <var>options</var> be a new instance of <code>PostMessageOptions</code>
object.</p></li>

<li><p>Set <var>options</var>'s <code data-x="">transfer</code> member to be
<var>transfer</var>.</p></li>

<li><p>Run the <span>message port post message steps</span> providing
<var>targetPort</var>, <var>message</var> and <var>options</var>.</p></li>
</ol>

<hr>

<p>The <dfn><code data-x="dom-MessagePort-start">start()</code></dfn> method, when invoked, must
enable this <code>MessagePort</code> object's <span>port message queue</span>, if it is not
already enabled.</p>
Expand Down Expand Up @@ -96937,6 +96983,7 @@ interface <dfn>DedicatedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span>
[Replaceable] readonly attribute DOMString <span data-x="dom-DedicatedWorkerGlobalScope-name">name</span>;

void <span data-x="dom-DedicatedWorkerGlobalScope-postMessage">postMessage</span>(any message, optional sequence&lt;<span data-x="idl-object">object</span>&gt; transfer = []);
void <span data-x="dom-DedicatedWorkerGlobalScope-postMessage-options">postMessage</span>(any message, optional <span>PostMessageOptions</span> options);

void <span data-x="dom-DedicatedWorkerGlobalScope-close">close</span>();

Expand Down Expand Up @@ -96965,6 +97012,13 @@ interface <dfn>DedicatedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span>
<var>dedicatedWorkerGlobal</var>. <var>transfer</var> can be passed as a list of objects that are
to be transferred rather than cloned.</dd>

<dt><var>dedicatedWorkerGlobal</var> . <code subdfn
data-x="dom-DedicatedWorkerGlobalScope-postMessage-options">postMessage</code>(<var>message</var> [,
<var>options</var> ])</dt>
<dd>Clones <var>message</var> and transmits it to the <code>Worker</code> object associated with
<var>dedicatedWorkerGlobal</var>. <var>options</var> can initialized with a <var>transfer</var>
property with a list of objects that are to be transferred rather than cloned.</dd>

<dt><var>dedicatedWorkerGlobal</var> . <code subdfn
data-x="dom-DedicatedWorkerGlobalScope-close">close</code>()</dt>
<dd>Aborts <var>dedicatedWorkerGlobal</var>.</dd>
Expand All @@ -96978,9 +97032,11 @@ interface <dfn>DedicatedWorkerGlobalScope</dfn> : <span>WorkerGlobalScope</span>
worker using the <code>Worker</code> constructor, used primarily for debugging purposes.</p>

<p>The <dfn><code data-x="dom-DedicatedWorkerGlobalScope-postMessage">postMessage()</code></dfn>
method on <code>DedicatedWorkerGlobalScope</code> objects must act as if, when invoked, it
immediately invoked <span data-x="dom-MessagePort-postMessage">the method of the same name</span>
on the port, with the same arguments, and returned the same return value.</p>
and <dfn><code data-x="dom-DedicatedWorkerGlobalScope-postMessage-options">postMessage()</code></dfn>
methods on <code>DedicatedWorkerGlobalScope</code> objects act as if, when invoked, it
immediately invoked the respective <span data-x="dom-MessagePort-postMessage">postMessage</span>
and <span data-x="dom-MessagePort-postMessage-options">postMessage (with options)</span> on the port,
with the same arguments, and returned the same return value.</p>

<p>To <dfn data-export="">close a worker</dfn>, given a <var>workerGlobal</var>, run these
steps:</p>
Expand Down Expand Up @@ -97672,6 +97728,7 @@ interface <dfn>Worker</dfn> : <span>EventTarget</span> {
void <span data-x="dom-Worker-terminate">terminate</span>();

void <span data-x="dom-Worker-postMessage">postMessage</span>(any message, optional sequence&lt;<span data-x="idl-object">object</span>&gt; transfer = []);
void <span data-x="dom-Worker-postMessage-options">postMessage</span>(any message, optional <span>PostMessageOptions</span> options);
attribute <span>EventHandler</span> <span data-x="handler-Worker-onmessage">onmessage</span>;
attribute <span>EventHandler</span> <span data-x="handler-Worker-onmessageerror">onmessageerror</span>;
};
Expand Down Expand Up @@ -97704,6 +97761,12 @@ enum <dfn>WorkerType</dfn> { "classic", "module" };
<dd>Clones <var>message</var> and transmits it to <var>worker</var>'s global environment.
<var>transfer</var> can be passed as a list of objects that are to be transferred rather than
cloned.</dd>

<dt><var>worker</var> . <code subdfn data-x="dom-Worker-postMessage-options">postMessage</code>(<var>message</var> [, <var>options</var> ])
<dd>Clones <var>message</var> and transmits it to <var>worker</var>'s global environment.
<var>options</var> can be initialized with a list of objects specified in the
<code data-x="">transfer</code> attribute can be passed as a list of objects that are to be transferred rather than
cloned.</dd>
</dl>

<div w-nodev>
Expand All @@ -97719,10 +97782,12 @@ enum <dfn>WorkerType</dfn> { "classic", "module" };
<p>All messages received by that port must immediately be retargeted at the <code>Worker</code>
object.</p>

<p>The <dfn><code data-x="dom-Worker-postMessage">postMessage()</code></dfn> method on
<code>Worker</code> objects must act as if, when invoked, it immediately invoked <span
data-x="dom-MessagePort-postMessage">the method of the same name</span> on the port, with the same
arguments, and returned the same return value.</p>
<p>The <dfn><code data-x="dom-Worker-postMessage">postMessage()</code></dfn> and
<dfn><code data-x="dom-Worker-postMessage-options">postMessage()</code></dfn> methods on
<code>Worker</code> objects act as if, when invoked, it immediately invoked the respective
<span data-x="dom-MessagePort-postMessage">postMessage</span> and
<span data-x="dom-MessagePort-postMessage-options">postMessage (with options)</span> on the port,
with the same arguments, and returned the same return value.</p>

</div>

Expand Down

0 comments on commit 4df7974

Please sign in to comment.