Skip to content

Commit

Permalink
[giow] (3) Try to clean up the incumbent script situation.
Browse files Browse the repository at this point in the history
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=18242
Affected topics: HTML

git-svn-id: http://svn.whatwg.org/webapps@8114 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Aug 1, 2013
1 parent 3df350e commit e7a1dae
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 60 deletions.
51 changes: 31 additions & 20 deletions complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@

<header class=head id=head><p><a href=http://www.whatwg.org/ class=logo><img width=101 src=/images/logo alt=WHATWG height=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 31 July 2013</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 1 August 2013</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -71460,6 +71460,11 @@ <h5 id=definitions-0><span class=secno>7.1.3.1 </span>Definitions</h5>

<h5 id=calling-scripts><span class=secno>7.1.3.2 </span>Calling scripts</h5>

<p>Each <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> has a <dfn id=stack-of-incumbent-scripts>stack of
incumbent scripts</dfn>, which must be initially empty. When a new script is <i>pushed</i> onto
this stack, the specified script is to be added to the stack; when the script on this stack that
was most recently pushed onto it is to be <i>popped</i> from the stack, it must be removed.</p>

<p>When a user agent is to <dfn id=jump-to-a-code-entry-point>jump to a code entry-point</dfn> for a <a href=#concept-script title=concept-script>script</a>, for example to invoke an event listener defined in that
<a href=#concept-script title=concept-script>script</a>, the user agent must run the following steps:</p>

Expand All @@ -71470,41 +71475,47 @@ <h5 id=calling-scripts><span class=secno>7.1.3.2 </span>Calling scripts</h5>
<li><p>If <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a> for <a href="#script's-browsing-context">script's
browsing context</a>, then abort these steps.</p>

<li><p>Set the <a href=#entry-script>entry script</a> to be the <a href=#concept-script title=concept-script>script</a>
being invoked.</li>
<li><p>Push the <a href=#concept-script title=concept-script>script</a> being invoked onto the <a href=#stack-of-incumbent-scripts>stack of
incumbent scripts</a>.</li>

<li><p>Make the <a href=#script-execution-environment title="script execution environment">script execution environment</a>
for the <a href=#concept-script title=concept-script>script</a> execute the code for the given code
entry-point.</li>

<li><p>Set the <a href=#entry-script>entry script</a> back to whatever it was when this algorithm
started (possibly nothing).</li>
<li><p>Pop the <a href=#concept-script title=concept-script>script</a> being invoked from the <a href=#stack-of-incumbent-scripts>stack of
incumbent scripts</a>.</li>

<li><p>If there is no longer an <a href=#entry-script>entry script</a>, <a href=#run-the-global-script-clean-up-jobs>run the global script clean-up
jobs</a>. (These cannot run scripts.)</li>
<li><p>If the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> is now empty, <a href=#run-the-global-script-clean-up-jobs>run the global script
clean-up jobs</a>. (These cannot run scripts.)</li>

<li><p>If there is no longer an <a href=#entry-script>entry script</a>, <a href=#perform-a-microtask-checkpoint>perform a microtask
<li><p>If the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> is now empty, <a href=#perform-a-microtask-checkpoint>perform a microtask
checkpoint</a>. (If this runs scripts, it will result in this algorithm being invoked
reentrantly.)</li>

</ol><p>This algorithm is not invoked by one script directly calling another, but it can be invoked
reentrantly in an indirect manner, e.g. if a script dispatches an event which has event listeners
registered.</p>

<hr><p>Each <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> can have an <dfn id=entry-script>entry
script</dfn> which is used to obtain, amongst other things, the <a href="#script's-base-url">script's base URL</a> to
<a href=#resolve-a-url title="resolve a url">resolve</a> relative <a href=#url title=URL>URLs</a> used in scripts
running in that <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a>. Initially, there is
no <a href=#entry-script>entry script</a>. It is changed by the <a href=#jump-to-a-code-entry-point>jump to a code entry-point</a>
algorithm above.</p>
<p>When a JavaScript <i>SourceElements</i> production is to be evaluated, the <a href=#concept-script title=concept-script>script</a> corresponding to that <i>SourceElements</i> must be pushed
onto the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> before the evaluation begins, and popped when the
evaluation ends (regardless of whether it's an abrupt completion or not).</p>

<p>The <dfn id=entry-script>entry script</dfn> is the <a href=#concept-script title=concept-script>script</a> in the
<a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> that was least-recently added (i.e. the first one in the
stack). If the stack is empty, then there is no <a href=#entry-script>entry script</a>. It is used to obtain,
amongst other things, the <a href="#script's-base-url">script's base URL</a> to <a href=#resolve-a-url title="resolve a
url">resolve</a> relative <a href=#url title=URL>URLs</a> used in scripts running in that
<a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a>.</p>

<p>The <dfn id=incumbent-script>incumbent script</dfn> is the <a href=#concept-script title=concept-script>script</a> in the
<a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> that was most-recently added (i.e. the last one on the
stack). If the stack is empty, then there is no <a href=#incumbent-script>incumbent script</a>. It is used in some
security checks.</p>

<p class=note>The WebIDL specification also manipulates the <a href=#stack-of-incumbent-scripts>stack of incumbent
scripts</a>. <a href=#refsWEBIDL>[WEBIDL]</a></p>

<!--CLEANUP:all occurrences of 'incumbent'-->
<p>The <dfn id=incumbent-script>incumbent script</dfn> is the <a href=#concept-script title=concept-script>script</a> corresponding
to the most-recently evaluated <i>SourceElements</i> JavaScript production whose evaluation
directly resulted in the invocation of the current API (method, attribute getter or setter,
constructor, etc).</p>
<!-- the <span title="concept-script">script</span> that invoked the current API -->
<!-- the <span title="concept-script">script</span> corresponding to the top execution context on the logical JavaScript execution context stack, also known as the running execution context -->

<hr><p>Each <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> has a <dfn id=running-mutation-observers>running mutation
observers</dfn> flag, which must initially be false. It is used to prevent reentrant invocation of
Expand Down
51 changes: 31 additions & 20 deletions index
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@

<header class=head id=head><p><a href=http://www.whatwg.org/ class=logo><img width=101 src=/images/logo alt=WHATWG height=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 31 July 2013</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 1 August 2013</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -71460,6 +71460,11 @@ interface <dfn id=navigatoronline>NavigatorOnLine</dfn> {

<h5 id=calling-scripts><span class=secno>7.1.3.2 </span>Calling scripts</h5>

<p>Each <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> has a <dfn id=stack-of-incumbent-scripts>stack of
incumbent scripts</dfn>, which must be initially empty. When a new script is <i>pushed</i> onto
this stack, the specified script is to be added to the stack; when the script on this stack that
was most recently pushed onto it is to be <i>popped</i> from the stack, it must be removed.</p>

<p>When a user agent is to <dfn id=jump-to-a-code-entry-point>jump to a code entry-point</dfn> for a <a href=#concept-script title=concept-script>script</a>, for example to invoke an event listener defined in that
<a href=#concept-script title=concept-script>script</a>, the user agent must run the following steps:</p>

Expand All @@ -71470,41 +71475,47 @@ interface <dfn id=navigatoronline>NavigatorOnLine</dfn> {
<li><p>If <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a> for <a href="#script's-browsing-context">script's
browsing context</a>, then abort these steps.</p>

<li><p>Set the <a href=#entry-script>entry script</a> to be the <a href=#concept-script title=concept-script>script</a>
being invoked.</li>
<li><p>Push the <a href=#concept-script title=concept-script>script</a> being invoked onto the <a href=#stack-of-incumbent-scripts>stack of
incumbent scripts</a>.</li>

<li><p>Make the <a href=#script-execution-environment title="script execution environment">script execution environment</a>
for the <a href=#concept-script title=concept-script>script</a> execute the code for the given code
entry-point.</li>

<li><p>Set the <a href=#entry-script>entry script</a> back to whatever it was when this algorithm
started (possibly nothing).</li>
<li><p>Pop the <a href=#concept-script title=concept-script>script</a> being invoked from the <a href=#stack-of-incumbent-scripts>stack of
incumbent scripts</a>.</li>

<li><p>If there is no longer an <a href=#entry-script>entry script</a>, <a href=#run-the-global-script-clean-up-jobs>run the global script clean-up
jobs</a>. (These cannot run scripts.)</li>
<li><p>If the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> is now empty, <a href=#run-the-global-script-clean-up-jobs>run the global script
clean-up jobs</a>. (These cannot run scripts.)</li>

<li><p>If there is no longer an <a href=#entry-script>entry script</a>, <a href=#perform-a-microtask-checkpoint>perform a microtask
<li><p>If the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> is now empty, <a href=#perform-a-microtask-checkpoint>perform a microtask
checkpoint</a>. (If this runs scripts, it will result in this algorithm being invoked
reentrantly.)</li>

</ol><p>This algorithm is not invoked by one script directly calling another, but it can be invoked
reentrantly in an indirect manner, e.g. if a script dispatches an event which has event listeners
registered.</p>

<hr><p>Each <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> can have an <dfn id=entry-script>entry
script</dfn> which is used to obtain, amongst other things, the <a href="#script's-base-url">script's base URL</a> to
<a href=#resolve-a-url title="resolve a url">resolve</a> relative <a href=#url title=URL>URLs</a> used in scripts
running in that <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a>. Initially, there is
no <a href=#entry-script>entry script</a>. It is changed by the <a href=#jump-to-a-code-entry-point>jump to a code entry-point</a>
algorithm above.</p>
<p>When a JavaScript <i>SourceElements</i> production is to be evaluated, the <a href=#concept-script title=concept-script>script</a> corresponding to that <i>SourceElements</i> must be pushed
onto the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> before the evaluation begins, and popped when the
evaluation ends (regardless of whether it's an abrupt completion or not).</p>

<p>The <dfn id=entry-script>entry script</dfn> is the <a href=#concept-script title=concept-script>script</a> in the
<a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> that was least-recently added (i.e. the first one in the
stack). If the stack is empty, then there is no <a href=#entry-script>entry script</a>. It is used to obtain,
amongst other things, the <a href="#script's-base-url">script's base URL</a> to <a href=#resolve-a-url title="resolve a
url">resolve</a> relative <a href=#url title=URL>URLs</a> used in scripts running in that
<a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a>.</p>

<p>The <dfn id=incumbent-script>incumbent script</dfn> is the <a href=#concept-script title=concept-script>script</a> in the
<a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a> that was most-recently added (i.e. the last one on the
stack). If the stack is empty, then there is no <a href=#incumbent-script>incumbent script</a>. It is used in some
security checks.</p>

<p class=note>The WebIDL specification also manipulates the <a href=#stack-of-incumbent-scripts>stack of incumbent
scripts</a>. <a href=#refsWEBIDL>[WEBIDL]</a></p>

<!--CLEANUP:all occurrences of 'incumbent'-->
<p>The <dfn id=incumbent-script>incumbent script</dfn> is the <a href=#concept-script title=concept-script>script</a> corresponding
to the most-recently evaluated <i>SourceElements</i> JavaScript production whose evaluation
directly resulted in the invocation of the current API (method, attribute getter or setter,
constructor, etc).</p>
<!-- the <span title="concept-script">script</span> that invoked the current API -->
<!-- the <span title="concept-script">script</span> corresponding to the top execution context on the logical JavaScript execution context stack, also known as the running execution context -->

<hr><p>Each <a href=#unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> has a <dfn id=running-mutation-observers>running mutation
observers</dfn> flag, which must initially be false. It is used to prevent reentrant invocation of
Expand Down
50 changes: 30 additions & 20 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -79892,6 +79892,11 @@ interface <dfn>NavigatorOnLine</dfn> {

<h5>Calling scripts</h5>

<p>Each <span>unit of related similar-origin browsing contexts</span> has a <dfn>stack of
incumbent scripts</dfn>, which must be initially empty. When a new script is <i>pushed</i> onto
this stack, the specified script is to be added to the stack; when the script on this stack that
was most recently pushed onto it is to be <i>popped</i> from the stack, it must be removed.</p>

<p>When a user agent is to <dfn>jump to a code entry-point</dfn> for a <span
title="concept-script">script</span>, for example to invoke an event listener defined in that
<span title="concept-script">script</span>, the user agent must run the following steps:</p>
Expand All @@ -79905,20 +79910,20 @@ interface <dfn>NavigatorOnLine</dfn> {
<li><p>If <span title="concept-bc-noscript">scripting is disabled</span> for <span>script's
browsing context</span>, then abort these steps.</p>

<li><p>Set the <span>entry script</span> to be the <span title="concept-script">script</span>
being invoked.</p></li>
<li><p>Push the <span title="concept-script">script</span> being invoked onto the <span>stack of
incumbent scripts</span>.</p></li>

<li><p>Make the <span title="script execution environment">script execution environment</span>
for the <span title="concept-script">script</span> execute the code for the given code
entry-point.</p></li>

<li><p>Set the <span>entry script</span> back to whatever it was when this algorithm
started (possibly nothing).</p></li>
<li><p>Pop the <span title="concept-script">script</span> being invoked from the <span>stack of
incumbent scripts</span>.</p></li>

<li><p>If there is no longer an <span>entry script</span>, <span>run the global script clean-up
jobs</span>. (These cannot run scripts.)</p></li>
<li><p>If the <span>stack of incumbent scripts</span> is now empty, <span>run the global script
clean-up jobs</span>. (These cannot run scripts.)</p></li>

<li><p>If there is no longer an <span>entry script</span>, <span>perform a microtask
<li><p>If the <span>stack of incumbent scripts</span> is now empty, <span>perform a microtask
checkpoint</span>. (If this runs scripts, it will result in this algorithm being invoked
reentrantly.)</p></li>

Expand All @@ -79928,22 +79933,27 @@ interface <dfn>NavigatorOnLine</dfn> {
reentrantly in an indirect manner, e.g. if a script dispatches an event which has event listeners
registered.</p>

<hr>
<p>When a JavaScript <i>SourceElements</i> production is to be evaluated, the <span
title="concept-script">script</span> corresponding to that <i>SourceElements</i> must be pushed
onto the <span>stack of incumbent scripts</span> before the evaluation begins, and popped when the
evaluation ends (regardless of whether it's an abrupt completion or not).</p>

<p>The <dfn>entry script</dfn> is the <span title="concept-script">script</span> in the
<span>stack of incumbent scripts</span> that was least-recently added (i.e. the first one in the
stack). If the stack is empty, then there is no <span>entry script</span>. It is used to obtain,
amongst other things, the <span>script's base URL</span> to <span title="resolve a
url">resolve</span> relative <span title="URL">URLs</span> used in scripts running in that
<span>unit of related similar-origin browsing contexts</span>.</p>

<p>The <dfn>incumbent script</dfn> is the <span title="concept-script">script</span> in the
<span>stack of incumbent scripts</span> that was most-recently added (i.e. the last one on the
stack). If the stack is empty, then there is no <span>incumbent script</span>. It is used in some
security checks.</p>

<p>Each <span>unit of related similar-origin browsing contexts</span> can have an <dfn>entry
script</dfn> which is used to obtain, amongst other things, the <span>script's base URL</span> to
<span title="resolve a url">resolve</span> relative <span title="URL">URLs</span> used in scripts
running in that <span>unit of related similar-origin browsing contexts</span>. Initially, there is
no <span>entry script</span>. It is changed by the <span>jump to a code entry-point</span>
algorithm above.</p>
<p class="note">The WebIDL specification also manipulates the <span>stack of incumbent
scripts</span>. <a href="#refsWEBIDL">[WEBIDL]</a></p>

<!--CLEANUP:all occurrences of 'incumbent'-->
<p>The <dfn>incumbent script</dfn> is the <span title="concept-script">script</span> corresponding
to the most-recently evaluated <i>SourceElements</i> JavaScript production whose evaluation
directly resulted in the invocation of the current API (method, attribute getter or setter,
constructor, etc).</p>
<!-- the <span title="concept-script">script</span> that invoked the current API -->
<!-- the <span title="concept-script">script</span> corresponding to the top execution context on the logical JavaScript execution context stack, also known as the running execution context -->

<hr>

Expand Down

0 comments on commit e7a1dae

Please sign in to comment.