Skip to content

Commit

Permalink
[] (0) Fire 'unload' on a message port if it is .close()d or if its o…
Browse files Browse the repository at this point in the history
…ther end is garbage collected.

git-svn-id: http://svn.whatwg.org/webapps@1883 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jul 16, 2008
1 parent ac5387a commit 86c922b
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 88 deletions.
96 changes: 50 additions & 46 deletions index
Original file line number Diff line number Diff line change
Expand Up @@ -1645,10 +1645,13 @@
<li><a href="#message0"><span class=secno>7.5.3 </span>Message
ports</a>
<ul class=toc>
<li><a href="#ports"><span class=secno>7.5.3.1. </span>Ports and
<li><a href="#unentangling"><span class=secno>7.5.3.1.
</span>Unentangling</a>

<li><a href="#ports"><span class=secno>7.5.3.2. </span>Ports and
browsing contexts</a>

<li><a href="#ports0"><span class=secno>7.5.3.2. </span>Ports and
<li><a href="#ports0"><span class=secno>7.5.3.3. </span>Ports and
garbage collection</a>
</ul>
</ul>
Expand Down Expand Up @@ -35216,8 +35219,8 @@ user reload must be equivalent to .reload()
message ports</a>, if the document is the <a href="#active">active
document</a>, or otherwise any ports in that document's <a
href="#list-of3">list of message ports</a>, if the document is not the <a
href="#active">active document</a>, must be <span>deactivated</span> and
unentangled.
href="#active">active document</a>, must be <span>unentangled with
prejudice</span>.

<p class=big-issue>Also, <code title=event-unload>unload</code> events
should fire.
Expand Down Expand Up @@ -42317,7 +42320,7 @@ function receiver(e) {

<li>
<p>Wait for all scripts in the <a href="#unit-of">unit of related
browsing contexts</a> to which the the <code><a
browsing contexts</a> to which the <code><a
href="#window">Window</a></code> object on which the method was invoked
belongs to have finished executing any pending scripts.</p>
<!-- XXX define this in terms of the
Expand Down Expand Up @@ -42404,7 +42407,7 @@ function receiver(e) {

<li>
<p>Wait for all scripts in the <a href="#unit-of">unit of related
browsing contexts</a> to which the the <code><a
browsing contexts</a> to which the <code><a
href="#window">Window</a></code> object on which the method was invoked
belongs to have finished executing any pending scripts.</p>
<!-- XXX define this in terms of the
Expand Down Expand Up @@ -42746,7 +42749,7 @@ function receiver(e) {

<li>
<p>Wait for all scripts in the <a href="#unit-of">unit of related
browsing contexts</a> to which the the <a href="#ownerwindow"
browsing contexts</a> to which the <a href="#ownerwindow"
title=dom-MessagePort-ownerWindow>owner</a> of the <var title="">target
port</var> belongs to have executed to completion, and then dispatch the
event at the <var title="">target port</var> object. If this never
Expand All @@ -42761,34 +42764,10 @@ function receiver(e) {

<p>The <dfn id=close2
title=dom-MessagePort-close><code>close()</code></dfn> method, when called
on a port <var title="">local port</var>, must cause the user agent to run
the following steps:

<ol>
<li>
<p>If <var title="">local port</var> is entangled with another port, then
let <var title="">remote port</var> be that port and run these substeps:</p>

<ol>
<li>
<p>Unentangle <var title="">remote port</var>, so that it is no longer
entangled with any ports.

<li>
<p>Set the <code title=dom-MessagePort-active><a
href="#active0">active</a></code> attribute of <var title="">remote
port</var> to false.

<li>
<p>Unentangle <var title="">local port</var>, so that it is no longer
entangled with any ports.
</ol>

<li>
<p>Set the <code title=dom-MessagePort-active><a
href="#active0">active</a></code> attribute of <var title="">local
port</var> to false.
</ol>
on a port <var title="">local port</var> that is entangled with another
port, must cause the <var title="">local port</var> to be
<span>unentangled with prejudice</span>. If the method is called on a port
that is not entangled, then the method must do nothing.

<hr>

Expand Down Expand Up @@ -42832,13 +42811,38 @@ function receiver(e) {
</dl>

<p class=note>Nothing in this specification causes any <code
title=event-load><a href="#load0">load</a></code>, <code
title=event-error><a href="#error1">error</a></code>, or <code
title=event-unload>unload</code> events to be targetted at a <code><a
href="#messageport0">MessagePort</a></code> object. This feature is
intended for use with Workers. <a href="#refsWORKERS">[WORKERS]</a>
title=event-load><a href="#load0">load</a></code> or <code
title=event-error><a href="#error1">error</a></code> events to be
targetted at a <code><a href="#messageport0">MessagePort</a></code>
object. Those features are intended for use with Workers. <a
href="#refsWORKERS">[WORKERS]</a>

<h5 id=ports><span class=secno>7.5.3.1. </span>Ports and browsing contexts</h5>
<h5 id=unentangling><span class=secno>7.5.3.1. </span>Unentangling</h5>

<p>A message port is entangled and unentangled as part of the normal
processing of message channels. When a channel is closed permanently but
in a controlled fashion, however, the user agent will be required to <dfn
id=unentangle title="unentangle with prejudice">unentangle a port with
prejudice</dfn>, which means it must run the following steps:

<ol>
<li>
<p>Unentangle the two ports.

<li>
<p>Set both ports' <code title=dom-messageport-active><a
href="#active0">active</a></code> attribute to false.

<li>
<p>At the next available opportunity, after any scripts have finished
executing<!-- XXX queue -->, <a href="#firing2">fire a simple event</a>
called <code title=event-unload>unload</code> at each of the message
ports. If the two message ports are in the same <a href="#unit-of">unit
of related browsing contexts</a>, then the port being unentangled with
prejudice must receive the event first.
</ol>

<h5 id=ports><span class=secno>7.5.3.2. </span>Ports and browsing contexts</h5>

<p>During <a href="#traverse" title="traverse the history">session history
traversal</a> (e.g. when a user <a href="#navigate"
Expand Down Expand Up @@ -42871,7 +42875,7 @@ function receiver(e) {
href="#active0">active</a></code> attribute of the port's entangled port,
not its own attribute.

<h5 id=ports0><span class=secno>7.5.3.2. </span>Ports and garbage
<h5 id=ports0><span class=secno>7.5.3.3. </span>Ports and garbage
collection</h5>

<p>User agents must act as if <code><a
Expand All @@ -42893,10 +42897,10 @@ function receiver(e) {
</div>

<p>When an entangled message port is about to be garbage collected, it must
be <a href="#deactivate" title="deactivate a port">deactivated</a> and
then unentangled, so that the two ports are no longer related and so that
the other port's <code title=dom-MessagePort-active><a
href="#active0">active</a></code> attribute is set to false.
be <span>unentangled with prejudice</span>, so that the two ports are no
longer related and so that the other port's <code
title=dom-MessagePort-active><a href="#active0">active</a></code>
attribute is set to false.

<h2 id=syntax><span class=secno>8. </span>The HTML syntax</h2>

Expand Down
85 changes: 43 additions & 42 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -32861,8 +32861,8 @@ user reload must be equivalent to .reload()
message ports</span>, if the document is the <span>active
document</span>, or otherwise any ports in that document's
<span>list of message ports</span>, if the document is not the
<span>active document</span>, must be <span>deactivated</span> and
unentangled.</p>
<span>active document</span>, must be <span>unentangled with
prejudice</span>.</p>

<p class="big-issue">Also, <code title="event-unload">unload</code>
events should fire.</p>
Expand Down Expand Up @@ -39970,7 +39970,7 @@ function receiver(e) {
<li>

<p>Wait for all scripts in the <span>unit of related browsing
contexts</span> to which the the <code>Window</code> object on
contexts</span> to which the <code>Window</code> object on
which the method was invoked belongs to have finished executing
any pending scripts.</p> <!-- XXX define this in terms of the
event queue -->
Expand Down Expand Up @@ -40080,7 +40080,7 @@ function receiver(e) {
<li>

<p>Wait for all scripts in the <span>unit of related browsing
contexts</span> to which the the <code>Window</code> object on
contexts</span> to which the <code>Window</code> object on
which the method was invoked belongs to have finished executing
any pending scripts.</p> <!-- XXX define this in terms of the
event queue -->
Expand Down Expand Up @@ -40414,7 +40414,7 @@ function receiver(e) {
steps.</p></li>

<li><p>Wait for all scripts in the <span>unit of related browsing
contexts</span> to which the the <span
contexts</span> to which the <span
title="dom-MessagePort-ownerWindow">owner</span> of the <var
title="">target port</var> belongs to have executed to completion,
and then dispatch the event at the <var title="">target port</var>
Expand All @@ -40427,36 +40427,11 @@ function receiver(e) {
<hr>

<p>The <dfn title="dom-MessagePort-close"><code>close()</code></dfn>
method, when called on a port <var title="">local port</var>, must
cause the user agent to run the following steps:</p>

<ol>

<li>

<p>If <var title="">local port</var> is entangled with another
port, then let <var title="">remote port</var> be that port and
run these substeps:</p>

<ol>

<li><p>Unentangle <var title="">remote port</var>, so that it is
no longer entangled with any ports.</p></li>

<li><p>Set the <code title="dom-MessagePort-active">active</code>
attribute of <var title="">remote port</var> to false.</p></li>

<li><p>Unentangle <var title="">local port</var>, so that it is
no longer entangled with any ports.</p></li>

</ol>

</li>

<li><p>Set the <code title="dom-MessagePort-active">active</code>
attribute of <var title="">local port</var> to false.</p></li>

</ol>
method, when called on a port <var title="">local port</var> that is
entangled with another port, must cause the <var title="">local
port</var> to be <span>unentangled with prejudice</span>. If the
method is called on a port that is not entangled, then the method
must do nothing.</p>

<hr>

Expand Down Expand Up @@ -40493,14 +40468,41 @@ function receiver(e) {
</dl>

<p class="note">Nothing in this specification causes any <code
title="event-load">load</code>, <code
title="event-error">error</code>, or <code
title="event-unload">unload</code> events to be targetted at a
<code>MessagePort</code> object. This feature is intended for use
title="event-load">load</code> or <code
title="event-error">error</code> events to be targetted at a
<code>MessagePort</code> object. Those features are intended for use
with Workers. <a href="#refsWORKERS">[WORKERS]</a></p>



<h5>Unentangling</h5>

<p>A message port is entangled and unentangled as part of the normal
processing of message channels. When a channel is closed permanently
but in a controlled fashion, however, the user agent will be
required to <dfn title="unentangle with prejudice">unentangle a port
with prejudice</dfn>, which means it must run the following
steps:</p>

<ol>

<li><p>Unentangle the two ports.</p></li>

<li><p>Set both ports' <code
title="dom-messageport-active">active</code> attribute to
false.</p></li>

<li><p>At the next available opportunity, after any scripts have
finished executing<!-- XXX queue -->, <span>fire a simple
event</span> called <code title="event-unload">unload</code> at
each of the message ports. If the two message ports are in the same
<span>unit of related browsing contexts</span>, then the port being
unentangled with prejudice must receive the event first.</p></li>

</ol>



<h5>Ports and browsing contexts</h5>

<p>During <span title="traverse the history">session history
Expand Down Expand Up @@ -40559,9 +40561,8 @@ function receiver(e) {
</div>

<p>When an entangled message port is about to be garbage collected,
it must be <span title="deactivate a port">deactivated</span> and
then unentangled, so that the two ports are no longer related and so
that the other port's <code
it must be <span>unentangled with prejudice</span>, so that the two
ports are no longer related and so that the other port's <code
title="dom-MessagePort-active">active</code> attribute is set to
false.</p>

Expand Down

0 comments on commit 86c922b

Please sign in to comment.