Skip to content

Commit

Permalink
[giow] (0) Make onbeforeunload and onunload fire on descendant browsi…
Browse files Browse the repository at this point in the history
…ng contexts.

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=8415

git-svn-id: http://svn.whatwg.org/webapps@4493 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jan 6, 2010
1 parent e5bc7f4 commit df6c6c8
Show file tree
Hide file tree
Showing 3 changed files with 303 additions and 41 deletions.
109 changes: 95 additions & 14 deletions complete.html
Expand Up @@ -48929,7 +48929,24 @@ <h4 id=nested-browsing-contexts><span class=secno>6.1.1 </span>Nested browsing c
context</a> gives the list of <dfn id=ancestor-browsing-context title="ancestor browsing
context">ancestor browsing contexts</dfn>.</p>

<p>A <code>Document</code> is said to be <dfn id=fully-active>fully active</dfn>
<p>The <dfn id=list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</dfn> of a
<code>Document</code> <var title="">d</var> is the list returned by
the following algorithm:</p>

<ol><li><p>Let <var title="">list</var> be an empty list.</li>

<li><p>For each <a href=#child-browsing-context>child browsing context</a> of <var title="">d</var> that is <a href=#browsing-context-nested-through title="browsing context nested
through">nested through</a> an element that is <a href=#in-a-document title="in a
document">in the <code>Document</code></a> <var title="">d</var>, in the <a href=#tree-order>tree order</a> of the elements of
the elements nesting those <a href=#browsing-context title="browsing context">browsing
contexts</a>, append to the list <var title="">list</var> the
<a href=#list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</a> of the
<a href=#active-document>active document</a> of that <a href=#child-browsing-context>child browsing
context</a>.</li>

<li><p>Return the constructed <var title="">list</var>.</li>

</ol><hr><p>A <code>Document</code> is said to be <dfn id=fully-active>fully active</dfn>
when it is the <a href=#active-document>active document</a> of its <a href=#browsing-context>browsing
context</a>, and either its browsing context is a <a href=#top-level-browsing-context>top-level
browsing context</a>, or the <code>Document</code> <a href=#browsing-context-nested-through title="browsing context nested through">through which</a> that
Expand Down Expand Up @@ -49650,12 +49667,14 @@ <h4 id=accessing-other-browsing-contexts><span class=secno>6.3.3 </span>Accessin
<p>The <dfn id=dom-length title=dom-length><code>length</code></dfn> IDL
attribute on the <code><a href=#window>Window</a></code> interface must return the
number of <a href=#child-browsing-context title="child browsing context">child browsing
contexts</a> of the <a href=#active-document>active document</a> of that
<code><a href=#window>Window</a></code> object, if that <code><a href=#window>Window</a></code>'s
<a href=#browsing-context>browsing context</a> shares the same <a href=#event-loop>event
loop</a> as the <a href="#script's-browsing-context">script's browsing context</a> of the
<a href=#first-script>first script</a> accessing the IDL attribute; otherwise, it
must return zero.</p>
contexts</a> that are <a href=#browsing-context-nested-through title="browsing context nested
through">nested through</a> elements that are <a href=#in-a-document title="in a
document">in the <code>Document</code></a> that is the
<a href=#active-document>active document</a> of that <code><a href=#window>Window</a></code> object, if
that <code><a href=#window>Window</a></code>'s <a href=#browsing-context>browsing context</a> shares the
same <a href=#event-loop>event loop</a> as the <a href="#script's-browsing-context">script's browsing
context</a> of the <a href=#first-script>first script</a> accessing the IDL
attribute; otherwise, it must return zero.</p>

<!-- in other words, frames are only accessible to same-thread processes -->

Expand All @@ -49667,9 +49686,10 @@ <h4 id=accessing-other-browsing-contexts><span class=secno>6.3.3 </span>Accessin
<p>When a <code><a href=#window>Window</a></code> object is <dfn id=dom-window-item title=dom-window-item>indexed to retrieve an indexed
property</dfn> <var title="">index</var>, the value returned must be
the <var title="">index</var>th <a href=#child-browsing-context>child browsing context</a>
of the <code>Document</code>, sorted in the <a href=#tree-order>tree order</a>
of the elements nesting those <a href=#browsing-context title="browsing
context">browsing contexts</a>.</p>
of the <code>Document</code> that is nested through an element that
is <a href=#in-a-document title="in a document">in the <code>Document</code></a>,
sorted in the <a href=#tree-order>tree order</a> of the elements nesting those
<a href=#browsing-context title="browsing context">browsing contexts</a>.</p>

<p>These properties are the <dfn id=dynamic-nested-browsing-context-properties>dynamic nested browsing context
properties</dfn>.</p>
Expand Down Expand Up @@ -49776,9 +49796,12 @@ <h4 id=garbage-collection-and-browsing-contexts><span class=secno>6.3.5 </span>G
<p>When a <a href=#browsing-context>browsing context</a> is to <dfn id=discard-a-document>discard a
<code>Document</code></dfn>, that means that it is to lose the
strong reference from the <code>Document</code>'s <a href=#browsing-context>browsing
context</a> to the <code>Document</code>, and that any <a href=#concept-task title=concept-task>tasks</a> associated with the
context</a> to the <code>Document</code>, that any <a href=#concept-task title=concept-task>tasks</a> associated with the
<code>Document</code> in any <a href=#task-source>task source</a> must be
removed without being run.</p>
removed without being run, and that all the <a href=#child-browsing-context title="child
browsing context">child browsing contexts</a> of the
<code>Document</code> must also be <a href=#a-browsing-context-is-discarded title="a browsing context
is discarded">discarded</a>.</p>

<p class=note>The <a href=#browsing-context>browsing context</a>'s <a href=#default-view>default
view</a>'s <code><a href=#window>Window</a></code> object <a href=#implied-strong-reference title="implied strong
Expand Down Expand Up @@ -56399,6 +56422,36 @@ <h4 id=unloading-documents><span class=secno>6.11.10 </span>Unloading documents<

</li>

<li><p>If this algorithm was invoked by another instance of the
"prompt to unload a document" algorithm (i.e. through the steps
below that invoke this algorithm for all descendant browsing
contexts), then abort these steps here.</li>

<li><p>Let <var title="">descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts>list of the
descendant browsing contexts</a> of the
<code>Document</code>.</li>

<li>

<p>If <var title="">descendants</var> is not an empty list, then
for each <a href=#browsing-context>browsing context</a> <var title="">b</var> in
<var title="">descendants</var> run the following substeps:</p>

<ol><li><p><a href=#prompt-to-unload-a-document title="prompt to unload a document">Prompt to
unload</a> the <a href=#active-document>active document</a> of the
<a href=#browsing-context>browsing context</a> <var title="">b</var>. If the user
<a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then
the user implicitly also <a href=#refused-to-allow-the-document-to-be-unloaded title="refused to allow the
document to be unloaded">refused to allow <em>this</em> document
to be unloaded</a>; abort these steps.</p>

<li><p>If <var title="">salvageable</var> state of the
<a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>
<var title="">b</var> is false, then set the <var title="">salvageable</var> state of <em>this</em> document to
false also.</li>

</ol></li>

</ol><hr><p>When a user agent is to <dfn id=unload-a-document>unload a document</dfn>, it must run
the following steps. These steps are passed an argument, <var title="">recycle</var>, which is either true or false, indicating
whether the <code>Document</code> object is going to be
Expand Down Expand Up @@ -56427,8 +56480,36 @@ <h4 id=unloading-documents><span class=secno>6.11.10 </span>Unloading documents<
<a href=#list-of-active-timeouts>list of active timeouts</a> and its <a href=#list-of-active-intervals>list of active
intervals</a>.</li>

<li><p>If <var title="">salvageable</var> and <var title="">recycle</var> are both false, <a href=#discard-a-document title="discard a
document">discard the <code>Document</code></a>.</li>
<li><p>If this algorithm was invoked by another instance of the
"unload a document" algorithm (i.e. through the steps below that
invoke this algorithm for all descendant browsing contexts), then
abort these steps here.</li>

<li><p>Let <var title="">descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts>list of the
descendant browsing contexts</a> of the
<code>Document</code>.</li>

<li>

<p>If <var title="">descendants</var> is not an empty list, then
for each <a href=#browsing-context>browsing context</a> <var title="">b</var> in
<var title="">descendants</var> run the following substeps:</p>

<ol><li><p><a href=#unload-a-document title="unload a document">Unload</a> the
<a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>
<var title="">b</var> with the <var title="">recycle</var>
parameter set to false.</li>

<li><p>If <var title="">salvageable</var> state of the
<a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>
<var title="">b</var> is false, then set the <var title="">salvageable</var> state of <em>this</em> document to
false also.</li>

</ol></li>

<li><p>If <var title="">salvageable</var> and <var title="">recycle</var> are both false, then the
<code>Document</code>'s <a href=#browsing-context>browsing context</a> must <a href=#discard-a-document title="discard a document">discard the
<code>Document</code></a>.</li>

</ol><h5 id=event-definition><span class=secno>6.11.10.1 </span>Event definition</h5>

Expand Down
109 changes: 95 additions & 14 deletions index
Expand Up @@ -46089,7 +46089,24 @@ document.body.appendChild(outer);</pre>
context</a> gives the list of <dfn id=ancestor-browsing-context title="ancestor browsing
context">ancestor browsing contexts</dfn>.</p>

<p>A <code>Document</code> is said to be <dfn id=fully-active>fully active</dfn>
<p>The <dfn id=list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</dfn> of a
<code>Document</code> <var title="">d</var> is the list returned by
the following algorithm:</p>

<ol><li><p>Let <var title="">list</var> be an empty list.</li>

<li><p>For each <a href=#child-browsing-context>child browsing context</a> of <var title="">d</var> that is <a href=#browsing-context-nested-through title="browsing context nested
through">nested through</a> an element that is <a href=#in-a-document title="in a
document">in the <code>Document</code></a> <var title="">d</var>, in the <a href=#tree-order>tree order</a> of the elements of
the elements nesting those <a href=#browsing-context title="browsing context">browsing
contexts</a>, append to the list <var title="">list</var> the
<a href=#list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</a> of the
<a href=#active-document>active document</a> of that <a href=#child-browsing-context>child browsing
context</a>.</li>

<li><p>Return the constructed <var title="">list</var>.</li>

</ol><hr><p>A <code>Document</code> is said to be <dfn id=fully-active>fully active</dfn>
when it is the <a href=#active-document>active document</a> of its <a href=#browsing-context>browsing
context</a>, and either its browsing context is a <a href=#top-level-browsing-context>top-level
browsing context</a>, or the <code>Document</code> <a href=#browsing-context-nested-through title="browsing context nested through">through which</a> that
Expand Down Expand Up @@ -46810,12 +46827,14 @@ interface <dfn id=window>Window</dfn> {
<p>The <dfn id=dom-length title=dom-length><code>length</code></dfn> IDL
attribute on the <code><a href=#window>Window</a></code> interface must return the
number of <a href=#child-browsing-context title="child browsing context">child browsing
contexts</a> of the <a href=#active-document>active document</a> of that
<code><a href=#window>Window</a></code> object, if that <code><a href=#window>Window</a></code>'s
<a href=#browsing-context>browsing context</a> shares the same <a href=#event-loop>event
loop</a> as the <a href="#script's-browsing-context">script's browsing context</a> of the
<a href=#first-script>first script</a> accessing the IDL attribute; otherwise, it
must return zero.</p>
contexts</a> that are <a href=#browsing-context-nested-through title="browsing context nested
through">nested through</a> elements that are <a href=#in-a-document title="in a
document">in the <code>Document</code></a> that is the
<a href=#active-document>active document</a> of that <code><a href=#window>Window</a></code> object, if
that <code><a href=#window>Window</a></code>'s <a href=#browsing-context>browsing context</a> shares the
same <a href=#event-loop>event loop</a> as the <a href="#script's-browsing-context">script's browsing
context</a> of the <a href=#first-script>first script</a> accessing the IDL
attribute; otherwise, it must return zero.</p>

<!-- in other words, frames are only accessible to same-thread processes -->

Expand All @@ -46827,9 +46846,10 @@ interface <dfn id=window>Window</dfn> {
<p>When a <code><a href=#window>Window</a></code> object is <dfn id=dom-window-item title=dom-window-item>indexed to retrieve an indexed
property</dfn> <var title="">index</var>, the value returned must be
the <var title="">index</var>th <a href=#child-browsing-context>child browsing context</a>
of the <code>Document</code>, sorted in the <a href=#tree-order>tree order</a>
of the elements nesting those <a href=#browsing-context title="browsing
context">browsing contexts</a>.</p>
of the <code>Document</code> that is nested through an element that
is <a href=#in-a-document title="in a document">in the <code>Document</code></a>,
sorted in the <a href=#tree-order>tree order</a> of the elements nesting those
<a href=#browsing-context title="browsing context">browsing contexts</a>.</p>

<p>These properties are the <dfn id=dynamic-nested-browsing-context-properties>dynamic nested browsing context
properties</dfn>.</p>
Expand Down Expand Up @@ -46936,9 +46956,12 @@ interface <dfn id=window>Window</dfn> {
<p>When a <a href=#browsing-context>browsing context</a> is to <dfn id=discard-a-document>discard a
<code>Document</code></dfn>, that means that it is to lose the
strong reference from the <code>Document</code>'s <a href=#browsing-context>browsing
context</a> to the <code>Document</code>, and that any <a href=#concept-task title=concept-task>tasks</a> associated with the
context</a> to the <code>Document</code>, that any <a href=#concept-task title=concept-task>tasks</a> associated with the
<code>Document</code> in any <a href=#task-source>task source</a> must be
removed without being run.</p>
removed without being run, and that all the <a href=#child-browsing-context title="child
browsing context">child browsing contexts</a> of the
<code>Document</code> must also be <a href=#a-browsing-context-is-discarded title="a browsing context
is discarded">discarded</a>.</p>

<p class=note>The <a href=#browsing-context>browsing context</a>'s <a href=#default-view>default
view</a>'s <code><a href=#window>Window</a></code> object <a href=#implied-strong-reference title="implied strong
Expand Down Expand Up @@ -53573,6 +53596,36 @@ State: &lt;OUTPUT NAME=I&gt;1&lt;/OUTPUT&gt; &lt;INPUT VALUE="Increment" TYPE=BU

</li>

<li><p>If this algorithm was invoked by another instance of the
"prompt to unload a document" algorithm (i.e. through the steps
below that invoke this algorithm for all descendant browsing
contexts), then abort these steps here.</li>

<li><p>Let <var title="">descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts>list of the
descendant browsing contexts</a> of the
<code>Document</code>.</li>

<li>

<p>If <var title="">descendants</var> is not an empty list, then
for each <a href=#browsing-context>browsing context</a> <var title="">b</var> in
<var title="">descendants</var> run the following substeps:</p>

<ol><li><p><a href=#prompt-to-unload-a-document title="prompt to unload a document">Prompt to
unload</a> the <a href=#active-document>active document</a> of the
<a href=#browsing-context>browsing context</a> <var title="">b</var>. If the user
<a href=#refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then
the user implicitly also <a href=#refused-to-allow-the-document-to-be-unloaded title="refused to allow the
document to be unloaded">refused to allow <em>this</em> document
to be unloaded</a>; abort these steps.</p>

<li><p>If <var title="">salvageable</var> state of the
<a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>
<var title="">b</var> is false, then set the <var title="">salvageable</var> state of <em>this</em> document to
false also.</li>

</ol></li>

</ol><hr><p>When a user agent is to <dfn id=unload-a-document>unload a document</dfn>, it must run
the following steps. These steps are passed an argument, <var title="">recycle</var>, which is either true or false, indicating
whether the <code>Document</code> object is going to be
Expand Down Expand Up @@ -53601,8 +53654,36 @@ State: &lt;OUTPUT NAME=I&gt;1&lt;/OUTPUT&gt; &lt;INPUT VALUE="Increment" TYPE=BU
<a href=#list-of-active-timeouts>list of active timeouts</a> and its <a href=#list-of-active-intervals>list of active
intervals</a>.</li>

<li><p>If <var title="">salvageable</var> and <var title="">recycle</var> are both false, <a href=#discard-a-document title="discard a
document">discard the <code>Document</code></a>.</li>
<li><p>If this algorithm was invoked by another instance of the
"unload a document" algorithm (i.e. through the steps below that
invoke this algorithm for all descendant browsing contexts), then
abort these steps here.</li>

<li><p>Let <var title="">descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts>list of the
descendant browsing contexts</a> of the
<code>Document</code>.</li>

<li>

<p>If <var title="">descendants</var> is not an empty list, then
for each <a href=#browsing-context>browsing context</a> <var title="">b</var> in
<var title="">descendants</var> run the following substeps:</p>

<ol><li><p><a href=#unload-a-document title="unload a document">Unload</a> the
<a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>
<var title="">b</var> with the <var title="">recycle</var>
parameter set to false.</li>

<li><p>If <var title="">salvageable</var> state of the
<a href=#active-document>active document</a> of the <a href=#browsing-context>browsing context</a>
<var title="">b</var> is false, then set the <var title="">salvageable</var> state of <em>this</em> document to
false also.</li>

</ol></li>

<li><p>If <var title="">salvageable</var> and <var title="">recycle</var> are both false, then the
<code>Document</code>'s <a href=#browsing-context>browsing context</a> must <a href=#discard-a-document title="discard a document">discard the
<code>Document</code></a>.</li>

</ol><h5 id=event-definition><span class=secno>6.11.10.1 </span>Event definition</h5>

Expand Down

0 comments on commit df6c6c8

Please sign in to comment.