Skip to content

Commit

Permalink
[giow] (1) Make BroadcastChannel objects work in workers
Browse files Browse the repository at this point in the history
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=24414
Affected topics: DOM APIs

git-svn-id: http://svn.whatwg.org/webapps@8660 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jun 6, 2014
1 parent ad061c5 commit 300e7de
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
23 changes: 14 additions & 9 deletions complete.html
Expand Up @@ -83490,7 +83490,7 @@ <h3 id=broadcasting-to-other-browsing-contexts><span class=secno>9.6 </span><dfn
<p>For simple cases, though, where a shared worker would be an unreasonable overhead, authors can
use the simple channel-based broadcast mechanism described in this section.</p>

<pre class=idl>[<a href=#dom-broadcastchannel title=dom-BroadcastChannel>Constructor</a>(DOMString channel)]
<pre class=idl>[<a href=#dom-broadcastchannel title=dom-BroadcastChannel>Constructor</a>(DOMString channel), Exposed=Window,Worker]
interface <dfn id=broadcastchannel>BroadcastChannel</dfn> : <a href=#eventtarget>EventTarget</a> {
readonly attribute DOMString <a href=#dom-broadcastchannel-name title=dom-BroadcastChannel-name>name</a>;
void <a href=#dom-broadcastchannel-postmessage title=dom-BroadcastChannel-postMessage>postMessage</a>(any message);
Expand Down Expand Up @@ -83552,8 +83552,18 @@ <h3 id=broadcasting-to-other-browsing-contexts><span class=secno>9.6 </span><dfn
<p>Let <var title="">destinations</var> be a list of <code><a href=#broadcastchannel>BroadcastChannel</a></code> objects that
match the following criteria:</p>

<ul><li><p>Their <a href=#broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</a> specifies a
<a href=#responsible-document>responsible document</a> that is <a href=#fully-active>fully active</a>.</li>
<ul><li>

<p>Their <a href=#broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</a> specifies either:</p>

<ul><li><p>a <a href=#global-object>global object</a> that is a <code><a href=#window>Window</a></code> object and a
<a href=#responsible-document>responsible document</a> that is <a href=#fully-active>fully active</a>, or</li>

<li><p>a <a href=#global-object>global object</a> that is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object whose
<code title=dom-WorkerGlobalScope-closing><a href=#dom-workerglobalscope-closing>closing</a></code> flag is false and whose
<a href=#worker>worker</a> is a <a href=#suspendable-worker>suspendable worker</a>.</li>

</ul></li>

<li><p>Their <a href=#broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</a> specifies an
<a href=#origin>origin</a> that is the <a href=#same-origin>same origin</a> as the <a href=#origin>origin</a> specified
Expand Down Expand Up @@ -83593,7 +83603,7 @@ <h3 id=broadcasting-to-other-browsing-contexts><span class=secno>9.6 </span><dfn
<code><a href=#broadcastchannel>BroadcastChannel</a></code> object.</li>

</ol><p>The <a href=#concept-task title=concept-task>tasks</a> must be associated with the <a href=#responsible-document>responsible
document</a> specified by the <code><a href=#broadcastchannel>BroadcastChannel</a></code> object's
document</a> specified by the target <code><a href=#broadcastchannel>BroadcastChannel</a></code> object's
<a href=#broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</a>, and must use the <a href=#dom-manipulation-task-source>DOM
manipulation task source</a>.</p>

Expand All @@ -83613,11 +83623,6 @@ <h3 id=broadcasting-to-other-browsing-contexts><span class=secno>9.6 </span><dfn
<tbody><tr><td><dfn id=handler-broadcastchannel-onmessage title=handler-BroadcastChannel-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code>
</table></div>

<p class=note>Authors are strongly encouraged to explicitly close <code><a href=#messageport>MessagePort</a></code>
objects to disentangle them, so that their resources can be recollected. Creating many
<code><a href=#messageport>MessagePort</a></code> objects and discarding them without closing them can lead to high
transient memory usage since garbage collection is not necessarily performed promptly.</p>

<div class=example>

<p>Suppose a page wants to know when the user logs out, even when the user does so from another
Expand Down
23 changes: 14 additions & 9 deletions index
Expand Up @@ -83490,7 +83490,7 @@ callback <dfn id=portcollectioncallback>PortCollectionCallback</dfn> = void (<a
<p>For simple cases, though, where a shared worker would be an unreasonable overhead, authors can
use the simple channel-based broadcast mechanism described in this section.</p>

<pre class=idl>[<a href=#dom-broadcastchannel title=dom-BroadcastChannel>Constructor</a>(DOMString channel)]
<pre class=idl>[<a href=#dom-broadcastchannel title=dom-BroadcastChannel>Constructor</a>(DOMString channel), Exposed=Window,Worker]
interface <dfn id=broadcastchannel>BroadcastChannel</dfn> : <a href=#eventtarget>EventTarget</a> {
readonly attribute DOMString <a href=#dom-broadcastchannel-name title=dom-BroadcastChannel-name>name</a>;
void <a href=#dom-broadcastchannel-postmessage title=dom-BroadcastChannel-postMessage>postMessage</a>(any message);
Expand Down Expand Up @@ -83552,8 +83552,18 @@ interface <dfn id=broadcastchannel>BroadcastChannel</dfn> : <a href=#eventtarget
<p>Let <var title="">destinations</var> be a list of <code><a href=#broadcastchannel>BroadcastChannel</a></code> objects that
match the following criteria:</p>

<ul><li><p>Their <a href=#broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</a> specifies a
<a href=#responsible-document>responsible document</a> that is <a href=#fully-active>fully active</a>.</li>
<ul><li>

<p>Their <a href=#broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</a> specifies either:</p>

<ul><li><p>a <a href=#global-object>global object</a> that is a <code><a href=#window>Window</a></code> object and a
<a href=#responsible-document>responsible document</a> that is <a href=#fully-active>fully active</a>, or</li>

<li><p>a <a href=#global-object>global object</a> that is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object whose
<code title=dom-WorkerGlobalScope-closing><a href=#dom-workerglobalscope-closing>closing</a></code> flag is false and whose
<a href=#worker>worker</a> is a <a href=#suspendable-worker>suspendable worker</a>.</li>

</ul></li>

<li><p>Their <a href=#broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</a> specifies an
<a href=#origin>origin</a> that is the <a href=#same-origin>same origin</a> as the <a href=#origin>origin</a> specified
Expand Down Expand Up @@ -83593,7 +83603,7 @@ interface <dfn id=broadcastchannel>BroadcastChannel</dfn> : <a href=#eventtarget
<code><a href=#broadcastchannel>BroadcastChannel</a></code> object.</li>

</ol><p>The <a href=#concept-task title=concept-task>tasks</a> must be associated with the <a href=#responsible-document>responsible
document</a> specified by the <code><a href=#broadcastchannel>BroadcastChannel</a></code> object's
document</a> specified by the target <code><a href=#broadcastchannel>BroadcastChannel</a></code> object's
<a href=#broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</a>, and must use the <a href=#dom-manipulation-task-source>DOM
manipulation task source</a>.</p>

Expand All @@ -83613,11 +83623,6 @@ interface <dfn id=broadcastchannel>BroadcastChannel</dfn> : <a href=#eventtarget
<tbody><tr><td><dfn id=handler-broadcastchannel-onmessage title=handler-BroadcastChannel-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code>
</table></div>

<p class=note>Authors are strongly encouraged to explicitly close <code><a href=#messageport>MessagePort</a></code>
objects to disentangle them, so that their resources can be recollected. Creating many
<code><a href=#messageport>MessagePort</a></code> objects and discarding them without closing them can lead to high
transient memory usage since garbage collection is not necessarily performed promptly.</p>

<div class=example>

<p>Suppose a page wants to know when the user logs out, even when the user does so from another
Expand Down
27 changes: 18 additions & 9 deletions source
Expand Up @@ -92548,7 +92548,7 @@ callback <dfn>PortCollectionCallback</dfn> = void (<span>MessagePort</span> port
<p>For simple cases, though, where a shared worker would be an unreasonable overhead, authors can
use the simple channel-based broadcast mechanism described in this section.</p>

<pre class="idl">[<span data-x="dom-BroadcastChannel">Constructor</span>(DOMString channel)]
<pre class="idl">[<span data-x="dom-BroadcastChannel">Constructor</span>(DOMString channel), Exposed=Window,Worker]
interface <dfn>BroadcastChannel</dfn> : <span>EventTarget</span> {
readonly attribute DOMString <span data-x="dom-BroadcastChannel-name">name</span>;
void <span data-x="dom-BroadcastChannel-postMessage">postMessage</span>(any message);
Expand Down Expand Up @@ -92619,8 +92619,22 @@ interface <dfn>BroadcastChannel</dfn> : <span>EventTarget</span> {

<ul>

<li><p>Their <span><code>BroadcastChannel</code> settings object</span> specifies a
<span>responsible document</span> that is <span>fully active</span>.</p></li>
<li>

<p>Their <span><code>BroadcastChannel</code> settings object</span> specifies either:</p>

<ul>

<li><p>a <span>global object</span> that is a <code>Window</code> object and a
<span>responsible document</span> that is <span>fully active</span>, or</p></li>

<li><p>a <span>global object</span> that is a <code>WorkerGlobalScope</code> object whose
<code data-x="dom-WorkerGlobalScope-closing">closing</code> flag is false and whose
<span>worker</span> is a <span>suspendable worker</span>.</p></li>

</ul>

</li>

<li><p>Their <span><code>BroadcastChannel</code> settings object</span> specifies an
<span>origin</span> that is the <span>same origin</span> as the <span>origin</span> specified
Expand Down Expand Up @@ -92668,7 +92682,7 @@ interface <dfn>BroadcastChannel</dfn> : <span>EventTarget</span> {
</ol>

<p>The <span data-x="concept-task">tasks</span> must be associated with the <span>responsible
document</span> specified by the <code>BroadcastChannel</code> object's
document</span> specified by the target <code>BroadcastChannel</code> object's
<span><code>BroadcastChannel</code> settings object</span>, and must use the <span>DOM
manipulation task source</span>.</p>

Expand Down Expand Up @@ -92698,11 +92712,6 @@ interface <dfn>BroadcastChannel</dfn> : <span>EventTarget</span> {

</div>

<p class="note">Authors are strongly encouraged to explicitly close <code>MessagePort</code>
objects to disentangle them, so that their resources can be recollected. Creating many
<code>MessagePort</code> objects and discarding them without closing them can lead to high
transient memory usage since garbage collection is not necessarily performed promptly.</p>

<div class="example">

<p>Suppose a page wants to know when the user logs out, even when the user does so from another
Expand Down

0 comments on commit 300e7de

Please sign in to comment.