Skip to content

Commit

Permalink
BroadcastChannel: Ignore msgs from detached iframes/closing workers
Browse files Browse the repository at this point in the history
For BroadcastChannel instances associated with detached iframes or closing workers, update the specification to require that calls to postMessage() should be ignored (without throwing an exception).

Closes whatwg#7219. Some potential followup in whatwg#7253 for the related bfcache case.
  • Loading branch information
recvfrom authored and Mason Freed committed Jun 3, 2022
1 parent ff155df commit ce044f4
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -101394,11 +101394,25 @@ interface <dfn interface>BroadcastChannel</dfn> : <span>EventTarget</span> {
data-x="dom-BroadcastChannel-name">name</code></dfn> getter steps are to return
<span>this</span>'s <span>channel name</span>.</p>

<p>A <code>BroadcastChannel</code> object is said to be <dfn>eligible for messaging</dfn> when
its <span>relevant global object</span> is either:</p>

<ul>
<li><p>a <code>Window</code> object whose <span data-x="concept-document-window">associated
<code>Document</code></span> is <span>fully active</span>, or</p></li>

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

<p>The <dfn method for="BroadcastChannel"><code
data-x="dom-BroadcastChannel-postMessage">postMessage(<var>message</var>)</code></dfn> method
steps are:</p>

<ol>
<li><p>If <span>this</span> is not <span>eligible for messaging</span>, then return.</p></li>

<li><p>If <span>this</span>'s <span data-x="concept-BroadcastChannel-closed">closed flag</span>
is true, then throw an <span>"<code>InvalidStateError</code>"</span>
<code>DOMException</code>.</p></li>
Expand All @@ -101414,18 +101428,7 @@ interface <dfn interface>BroadcastChannel</dfn> : <span>EventTarget</span> {
match the following criteria:</p>

<ul>
<li>
<p>Their <span>relevant global object</span> is either:</p>

<ul>
<li><p>a <code>Window</code> object whose <span data-x="concept-document-window">associated
<code>Document</code></span> is <span>fully active</span>, or</p></li>

<li><p>a <code>WorkerGlobalScope</code> object whose <span
data-x="dom-WorkerGlobalScope-closing">closing</span> flag is false and whose
<span>worker</span> is not a <span>suspendable worker</span>.</p></li>
</ul>
</li>
<li><p>They are <span>eligible for messaging</span>.</p></li>

<li><p>Their <span>relevant settings object</span>'s <span
data-x="concept-settings-object-origin">origin</span> is <span>same origin</span> with
Expand Down Expand Up @@ -126731,6 +126734,7 @@ INSERT INTERFACES HERE
Andrew Simons,
Andrew Smith,
Andrew W. Hagen,
Andrew Williams,
Andrey V. Lukyanov,
Andry Rendy,
Andy Davies,
Expand Down

0 comments on commit ce044f4

Please sign in to comment.