Skip to content
Permalink
Browse files

[e] (0) Work in progress for integration with WebIDL (script executio…

…n stuff)

Affected topics: HTML

git-svn-id: http://svn.whatwg.org/webapps@8129 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Aug 5, 2013
1 parent 92fe3a7 commit ed5b855e0c5e780aa1e009bb2648b3ac33e48675
Showing with 142 additions and 58 deletions.
  1. +42 −19 complete.html
  2. +42 −19 index
  3. +58 −20 source
was most recently pushed onto it is to be <i>popped</i> from the stack, it must be removed.
Entries on this stack can be labeled as <dfn id=candidate-entry-scripts>candidate entry scripts</dfn>.</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>
<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>, the user agent must run the following steps:</p>

<ol><li><p>If the <a href="#script's-global-object">script's global object</a> is a <code><a href=#window>Window</a></code> object whose
<code><a href=#document>Document</a></code> object is not <a href=#fully-active>fully active</a>, then abort these steps without
doing anything. The callback is not run.</p>
<ol><li><p>Let <var title="">s</var> be the given <a href=#concept-script title=concept-script>script</a>.</li>

<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>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>, and label it as a <a href=#candidate-entry-scripts title="candidate entry scripts">candidate entry
script</a>.</li>
<li><p><a href=#prepare-to-run-a-script-based-callback>Prepare to run a script-based callback</a> with <var title="">s</var> as both the
new incumbent <a href=#concept-script title=concept-script>script</a> and the owner <a href=#concept-script title=concept-script>script</a>. If this returns "do not run" then abort these
steps.</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 <a href=#concept-script title=concept-script>script</a>'s <a href=#code-entry-point>code entry-point</a>.</li>
for <var title="">s</var> execute the <a href=#concept-script title=concept-script>script</a>'s <a href=#code-entry-point>code
entry-point</a>.</li>

<li><p><a href=#clean-up-after-running-a-callback>Clean up after running a callback</a>.</li>

</ol><p>The <dfn id=prepare-to-run-a-script-based-callback>prepare to run a script-based callback</dfn> steps are as follows. They are invoked
with a new incumbent <a href=#concept-script title=concept-script>script</a> <var title="">s</var> and an owner
<a href=#concept-script title=concept-script>script</a> <var title="">o</var>, and return either "run" or "do
not run".</p>

<ol><li><p>If the <a href="#script's-global-object" title="script's global object">global object</a> of <var title="">o</var>
is a <code><a href=#window>Window</a></code> object whose <code><a href=#document>Document</a></code> object is not <a href=#fully-active>fully
active</a>, then return "do not run" and abort these steps.</p>

<li><p>If <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a> for <var title="">o</var>'s <a href="#script's-browsing-context" title="script's browsing context">browsing context</a>, then return
"do not run" and abort these steps.</p>

<li><p>Push <var title="">s</var> onto the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a>, and label it
as a <a href=#candidate-entry-scripts title="candidate entry scripts">candidate entry script</a>.</li>

<li><p>Return "run".</li>

</ol><p>The steps to <dfn id=prepare-to-run-a-non-script-based-callback>prepare to run a non-script-based callback</dfn> are as follows. They are
invoked with a new incumbent <a href=#concept-script title=concept-script>script</a> <var title="">s</var> and,
in principle, return either "run" or "do not run" (though in practice they always return
"run").</p>

<ol><li><p>Push <var title="">s</var> onto the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a>.</li>

<li><p>Return "run".</li>

</ol><p>The steps to <dfn id=clean-up-after-running-a-callback>clean up after running a callback</dfn> are as follows:</p>

<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>
<ol><li><p>Pop the current <a href=#incumbent-script>incumbent script</a> from the <a href=#stack-of-incumbent-scripts>stack of incumbent
scripts</a>.</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 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>
checkpoint</a>. (If this runs scripts, these algorithms will be invoked reentrantly.)</li>

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

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>
<p class=note>The WebIDL specification also uses these algorithms. <a href=#refsWEBIDL>[WEBIDL]</a></p>

<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
61 index
was most recently pushed onto it is to be <i>popped</i> from the stack, it must be removed.
Entries on this stack can be labeled as <dfn id=candidate-entry-scripts>candidate entry scripts</dfn>.</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>
<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>, the user agent must run the following steps:</p>

<ol><li><p>If the <a href="#script's-global-object">script's global object</a> is a <code><a href=#window>Window</a></code> object whose
<code><a href=#document>Document</a></code> object is not <a href=#fully-active>fully active</a>, then abort these steps without
doing anything. The callback is not run.</p>
<ol><li><p>Let <var title="">s</var> be the given <a href=#concept-script title=concept-script>script</a>.</li>

<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>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>, and label it as a <a href=#candidate-entry-scripts title="candidate entry scripts">candidate entry
script</a>.</li>
<li><p><a href=#prepare-to-run-a-script-based-callback>Prepare to run a script-based callback</a> with <var title="">s</var> as both the
new incumbent <a href=#concept-script title=concept-script>script</a> and the owner <a href=#concept-script title=concept-script>script</a>. If this returns "do not run" then abort these
steps.</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 <a href=#concept-script title=concept-script>script</a>'s <a href=#code-entry-point>code entry-point</a>.</li>
for <var title="">s</var> execute the <a href=#concept-script title=concept-script>script</a>'s <a href=#code-entry-point>code
entry-point</a>.</li>

<li><p><a href=#clean-up-after-running-a-callback>Clean up after running a callback</a>.</li>

</ol><p>The <dfn id=prepare-to-run-a-script-based-callback>prepare to run a script-based callback</dfn> steps are as follows. They are invoked
with a new incumbent <a href=#concept-script title=concept-script>script</a> <var title="">s</var> and an owner
<a href=#concept-script title=concept-script>script</a> <var title="">o</var>, and return either "run" or "do
not run".</p>

<ol><li><p>If the <a href="#script's-global-object" title="script's global object">global object</a> of <var title="">o</var>
is a <code><a href=#window>Window</a></code> object whose <code><a href=#document>Document</a></code> object is not <a href=#fully-active>fully
active</a>, then return "do not run" and abort these steps.</p>

<li><p>If <a href=#concept-bc-noscript title=concept-bc-noscript>scripting is disabled</a> for <var title="">o</var>'s <a href="#script's-browsing-context" title="script's browsing context">browsing context</a>, then return
"do not run" and abort these steps.</p>

<li><p>Push <var title="">s</var> onto the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a>, and label it
as a <a href=#candidate-entry-scripts title="candidate entry scripts">candidate entry script</a>.</li>

<li><p>Return "run".</li>

</ol><p>The steps to <dfn id=prepare-to-run-a-non-script-based-callback>prepare to run a non-script-based callback</dfn> are as follows. They are
invoked with a new incumbent <a href=#concept-script title=concept-script>script</a> <var title="">s</var> and,
in principle, return either "run" or "do not run" (though in practice they always return
"run").</p>

<ol><li><p>Push <var title="">s</var> onto the <a href=#stack-of-incumbent-scripts>stack of incumbent scripts</a>.</li>

<li><p>Return "run".</li>

</ol><p>The steps to <dfn id=clean-up-after-running-a-callback>clean up after running a callback</dfn> are as follows:</p>

<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>
<ol><li><p>Pop the current <a href=#incumbent-script>incumbent script</a> from the <a href=#stack-of-incumbent-scripts>stack of incumbent
scripts</a>.</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 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>
checkpoint</a>. (If this runs scripts, these algorithms will be invoked reentrantly.)</li>

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

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>
<p class=note>The WebIDL specification also uses these algorithms. <a href=#refsWEBIDL>[WEBIDL]</a></p>

<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
78 source
Entries on this stack can be labeled as <dfn>candidate entry scripts</dfn>.</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>
title="concept-script">script</span>, the user agent must run the following steps:</p>

<ol>

<li><p>If the <span>script's global object</span> is a <code>Window</code> object whose
<code>Document</code> object is not <span>fully active</span>, then abort these steps without
doing anything. The callback is not run.</p>
<li><p>Let <var title="">s</var> be the given <span
title="concept-script">script</span>.</p></li>

<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>Push the <span title="concept-script">script</span> being invoked onto the <span>stack of
incumbent scripts</span>, and label it as a <span title="candidate entry scripts">candidate entry
script</span>.</p></li>
<li><p><span>Prepare to run a script-based callback</span> with <var title="">s</var> as both the
new incumbent <span title="concept-script">script</span> and the owner <span
title="concept-script">script</span>. If this returns "do not run" then abort these
steps.</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 <span
title="concept-script">script</span>'s <span>code entry-point</span>.</p></li>
for <var title="">s</var> execute the <span title="concept-script">script</span>'s <span>code
entry-point</span>.</p></li>

<li><p><span>Clean up after running a callback</span>.</p></li>

</ol>

<p>The <dfn>prepare to run a script-based callback</dfn> steps are as follows. They are invoked
with a new incumbent <span title="concept-script">script</span> <var title="">s</var> and an owner
<span title="concept-script">script</span> <var title="">o</var>, and return either "run" or "do
not run".</p>

<ol>

<li><p>If the <span title="script's global object">global object</span> of <var title="">o</var>
is a <code>Window</code> object whose <code>Document</code> object is not <span>fully
active</span>, then return "do not run" and abort these steps.</p>

<li><p>If <span title="concept-bc-noscript">scripting is disabled</span> for <var
title="">o</var>'s <span title="script's browsing context">browsing context</span>, then return
"do not run" and abort these steps.</p>

<li><p>Push <var title="">s</var> onto the <span>stack of incumbent scripts</span>, and label it
as a <span title="candidate entry scripts">candidate entry script</span>.</p></li>

<li><p>Return "run".</p></li>

<li><p>Pop the <span title="concept-script">script</span> being invoked from the <span>stack of
incumbent scripts</span>.</p></li>
</ol>

<p>The steps to <dfn>prepare to run a non-script-based callback</dfn> are as follows. They are
invoked with a new incumbent <span title="concept-script">script</span> <var title="">s</var> and,
in principle, return either "run" or "do not run" (though in practice they always return
"run").</p>

<ol>

<li><p>Push <var title="">s</var> onto the <span>stack of incumbent scripts</span>.</p></li>

<li><p>Return "run".</p></li>

</ol>

<p>The steps to <dfn>clean up after running a callback</dfn> are as follows:</p>

<ol>

<li><p>Pop the current <span>incumbent script</span> from the <span>stack of incumbent
scripts</span>.</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 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>
checkpoint</span>. (If this runs scripts, these algorithms will be invoked reentrantly.)</p></li>

</ol>

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

stack). If the stack is empty, then there is no <span>incumbent script</span>. It is used in some
security checks.</p>

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

<hr>

0 comments on commit ed5b855

Please sign in to comment.
You can’t perform that action at this time.