Short URL: http://html5.org/r/2529
Index: source
===================================================================
--- source (revision 2528)
+++ source (revision 2529)
@@ -428,7 +428,7 @@
that no scripts execute (e.g. no event handlers, no timers,
etc). User agents should remain responsive to user input while
paused, however, albeit without letting the user interact with Web
- pages where that would involve invoking any script.</p>
+ pages where that would involve invoking any <span title="concept-script">script</span>.</p>
<h4>XML</h4>
@@ -3334,13 +3334,7 @@
<h4>Terminology</h4>
- <p>A <dfn>URL</dfn> is a string used to identify a resource. <span
- id="urldoc">A <span>URL</span> is always associated with a
- <code>Document</code>, either explicitly when the URL is created or
- defined; or through a DOM node, in which case the associated
- <code>Document</code> is the node's <code>Document</code>; or
- through a script, in which case the associated <code>Document</code>
- is the script's <span>script document context</span>.</span></p>
+ <p>A <dfn>URL</dfn> is a string used to identify a resource.</p>
<p>A <span>URL</span> is a <dfn>valid URL</dfn> if at least one of
the following conditions holds:</p>
@@ -3364,6 +3358,29 @@
</ul>
+ <p>A <span>URL</span> has an associated <dfn>URL character
+ encoding</dfn>, determined as follows:</p>
+
+ <dl class="switch">
+
+ <dt>If the URL came from a script (e.g. as an argument to a
+ method)</dt>
+
+ <dd>The URL character encoding is the <span>script's character
+ encoding</span>.</dd>
+
+ <dt>If the URL came from a DOM node (e.g. from an element)</dt>
+
+ <dd>The node has a <code>Document</code>, and the URL character
+ encoding is the <span>document's character encoding</span>.</dd>
+
+ <dt>If the URL had a character encoding defined when the URL was
+ created or defined</dt>
+
+ <dd>The URL character encoding is as defined.</dd>
+
+ </dl>
+
<p class="note">The term "URL" in this specification is used in a
manner distinct from the precise technical meaning it is given in
RFC 3986. Readers familiar with that RFC will find it easier to read
@@ -3522,8 +3539,7 @@
<dt>If the URL to be resolved was passed to an API</dt>
- <dd><p>The base URL is the <span>document base URL</span> of the
- script's <span>script document context</span>.</p></dd>
+ <dd><p>The base URL is the <span>script's base URL</span>.</p></dd>
<dt>If the URL to be resolved is from the value of a content
attribute</dt>
@@ -3594,14 +3610,9 @@
<li><p>Let <var title="">url</var> be the <span>URL</span> being
resolved.</p></li>
- <li><p>Let <var title="">document</var> be the
- <code>Document</code> <a href="#urldoc">associated with</a> <var
- title="">url</var>.</p></li>
+ <li><p>Let <var title="">encoding</var> be the <span>URL character
+ encoding</span>.</p></li>
- <li><p>Let <var title="">encoding</var> be the <span
- title="document's character encoding">character encoding</span> of
- <var title="">document</var>.</p></li>
-
<li><p>If <var title="">encoding</var> is UTF-16, then change it to
UTF-8.</p></li>
@@ -5609,13 +5620,31 @@
<li value="20"><dfn><code>ABORT_ERR</code></dfn></li> <!-- actually in XHR for now -->
<li value="21"><dfn><code>URL_MISMATCH_ERR</code></dfn></li> <!-- actually in workers for now -->
<li value="22"><dfn><code>QUOTA_EXCEEDED_ERR</code></dfn></li> <!-- actually defined right here for now -->
+ <li value="23"><dfn><code>UNAVAILABLE_SCRIPT_ERR</code></dfn></li> <!-- actually defined right here for now -->
<li value="81"><dfn><code>PARSE_ERR</code></dfn></li> <!-- actually defined in dom3ls -->
<li value="82"><dfn><code>SERIALISE_ERR</code></dfn></li> <!-- actually defined in dom3ls -->
</ol>
+ <h4>Garbage collection</h4>
+ <p>There is an <dfn>implied strong reference</dfn> from any DOM
+ attribute that returns a pre-existing object to that object.</p>
+ <div class="example">
+
+ <p>For example, the <code>document.defaultView</code> attribute
+ means that there is a strong reference from a <code>Document</code>
+ object to its <code>Window</code> object. Similarly, there is
+ always a strong reference from a <code>Document</code> to any
+ descendant nodes, and from any node to its owner
+ <code>Document</code>.</p>
+
+ </div>
+
+
+
+
<h2 id="dom">Semantics and structure of HTML documents</h2>
<h3 id="semantics-intro">Introduction</h3>
@@ -5634,10 +5663,12 @@
<p><dfn>The document's address</dfn> is an <span>absolute URL</span>
that is set when the <code>Document</code> is created.</p>
- <p>When a <code>Document</code> is created by a script using the
- <code title="">createDocument()</code> API, <span>the document's
+ <p>When a <code>Document</code> is created by a <span
+ title="concept-script">script</span> using the <code
+ title="">createDocument()</code> API, <span>the document's
address</span> is the same as <span>the document's address</span> of
- the <span>script document context</span> of that script.</p>
+ the <span>active document</span> of the <span>script's browsing
+ context</span>.</p>
<p><code>Document</code> objects are assumed to be <dfn>XML
documents</dfn> unless they are flagged as being <dfn>HTML
@@ -5654,8 +5685,15 @@
<span title="HTML documents">HTML document</span> by calling <code
title="dom-document-open">document.open()</code> on it.</p>
+ <p>When a <code>Document</code> is first created, a new <span>script
+ group</span> must be created. This is the <code>Document</code>'s
+ <dfn>current script group</dfn> until the script group is changed
+ (which can happen if <code
+ title="dom-document-open">document.open()</code> is invoked on the
+ <code>Document</code>).</p>
+
<h4>Documents in the DOM</h4>
<p>All <code>Document</code> objects (in user agents implementing
@@ -7450,8 +7488,8 @@
with the parser, and thus their behavior varies depending on whether
they are used with <span>HTML documents</span> (and the <span>HTML
parser</span>) or XHTML in <span>XML documents</span> (and the
- <span>XML parser</span>). The following table cross-references the
- various versions of these APIs.</p>
+ <span>XML parser</span><!-- XXX xref -->). The following table
+ cross-references the various versions of these APIs.</p>
<table>
<thead>
@@ -7550,8 +7588,11 @@
</li>
- <li><p class="XXX">onbeforeunload, onunload, reset timers, empty event queue, kill any pending transactions, XMLHttpRequests, etc</p></li>
- <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%20src%3D%22document%22%3E%3C%2Fiframe%3E%0A%3Cscript%3Eonload%20%3D%20function%20()%20{%20f%20%3D%20document.getElementsByTagName(%27iframe%27)[0]%3B%20d%20%3D%20f.contentDocument%3B%20}%3C%2Fscript%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22w(d.documentElement.innerHTML)%22%20value%3D%22dump%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.body.bgColor%3D%27red%27%22%20value%3D%22color%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22f.style.border%3D%27lime%20solid%27%22%20value%3D%22color%20frame%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.open()%3B%20d.write(%27%3Cp%3Etest%3C%2Fp%3E%27)%3B%20d.close()%22%20value%3D%22replace%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.open()%3B%20d.write(%27%3Cp%3E%3Cscript%3Ei%20%3D%200%3B%20setInterval(%26quot%3Bparent.w(i%2B%2B)%26quot%3B%2C%20500)%3C%2Fscript%3E%3C%2Fp%3E%27)%3B%20d.close()%22%20value%3D%22replace%20with%20timer%22%3E%0A -->
+ <li><p><span title="unload a document">Unload</span> the
+ <code>Document</code> object, with the <var title="">recycle</var>
+ parameter set to true. If the user <span>refused to allow the
+ document to be unloaded</span>, then these steps must be
+ aborted.</p></li>
<li><p>If the document has an <span>active parser</span><!--XXX
xref-->, then stop that parser, and throw away any pending content
@@ -7560,15 +7601,28 @@
XHTML, or image document, or something?</span></p></li><!-- XXX see
also innerHTML in HTML -->
+ <li><p>Freeze the document's <span>current script
+ group</span>.</p></li>
+
+ <li><p>Unregister all event listeners registered on the
+ <code>Document</code> node and its descendants.</p>
+
<li><p>Remove all child nodes of the document, without firing any
mutation events.</p></li>
+ <li><p>Create a new <span>script group</span> and let the
+ document's <span>current script group</span> be that new
+ group. (The old script group is now permanently frozen.)</p></li>
+
+ <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%20src%3D%22document%22%3E%3C%2Fiframe%3E%0A%3Cscript%3Eonload%20%3D%20function%20()%20%7B%20f%20%3D%20document.getElementsByTagName('iframe')%5B0%5D%3B%20d%20%3D%20f.contentWindow.document%3B%20%7D%3C%2Fscript%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22w(d.documentElement.innerHTML)%22%20value%3D%22dump%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.open()%3B%20d.write('%3Cscript%3Evar%20x%20%3D%20new%20XMLHttpRequest()%3Bx.open(%26quot%3BGET%26quot%3B%2C%20%26quot%3BGET%26quot%3B)%3Bx.onreadystatechange%3Dfunction()%20%7B%20alert(x.readyState)%3B%20%7D%3Bx.send(null)%3B%3C%2Fscript%3E')%3Bd.close()%3B%20setTimeout(function()%20%7B%20d.open()%3B%20d.write('%3Cp%3Etest%3C%2Fp%3E')%3B%20d.close()%20%7D%2C%200)%3B%22%20value%3D%22xhr%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.onclick%20%3D%20function()%20%7B%20w('click')%20%7D%22%20value%3D%22add%20click%20handler%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.open()%3B%20d.write('%3Cp%3Etest%3C%2Fp%3E')%3B%20d.close()%22%20value%3D%22replace%22%3E%0A%3Cinput%20type%3Dbutton%20onclick%3D%22d.open()%3B%20d.write('%3Cp%3E%3Cscript%3Ei%20%3D%200%3B%20setTimeout(%26quot%3Bparent.w(i%2B%2B)%26quot%3B%2C%202000)%3C%2Fscript%3E%3C%2Fp%3E')%3B%20d.close()%22%20value%3D%22replace%20with%20timer%22%3E -->
+
<li><p>Change the <span>document's character encoding</span> to
UTF-16.</p></li>
- <li><p>Change <span>the document's address</span> to the <span
- title="the document's address">address</span> of the <span>script
- document context</span> of the script that invoked the <code
+ <li><p>Change <span>the document's address</span> to the <span>the
+ document's address</span> of the <span>active document</span> of
+ the <span title="script's browsing context">browsing context</span>
+ of the <span title="concept-script">script</span> that invoked the <code
title="dom-document-open">document.open()</code> method.</p></li>
<li><p>Create a new <span>HTML parser</span> and associate it with
@@ -7685,8 +7739,10 @@
<p>If the <span>insertion point</span> is undefined, the <code
title="dom-document-open">open()</code> method must be called
(with no arguments) on the <code title="Document">document</code>
- object. The <span>insertion point</span> will point at just before
- the end of the (empty) <span>input stream</span>.</p>
+ object. If the user <span>refused to allow the document to be
+ unloaded</span>, then these steps must be aborted. Otherwise, the
+ <span>insertion point</span> will point at just before the end of
+ the (empty) <span>input stream</span>.</p>
</li>
@@ -8193,7 +8249,7 @@
<li>
- <p>The user agent must create a new <span>XML parser</span>.</p>
+ <p>The user agent must create a new <span>XML parser</span><!-- XXX xref -->.</p>
</li>
@@ -9793,13 +9849,13 @@
<dfn>"parser-inserted"</dfn>. This flag is set by the <span>HTML
parser</span> and is used to handle <code
title="dom-document-write-HTML">document.write()</code> calls. The
- third and fourth pieces of metadata are <dfn><var>the script's
- type</var></dfn> and <dfn><var>the script's character
+ third and fourth pieces of metadata are <dfn><var>the script block's
+ type</var></dfn> and <dfn><var>the script block's character
encoding</var></dfn>. They are determined when the script is run,
based on the attributes on the element at that time.</p>
- <p>When an <span>XML parser</span> creates a <code>script</code>
- element, it must be marked as being
+ <p>When an <span>XML parser</span><!-- XXX xref --> creates a
+ <code>script</code> element, it must be marked as being
<span>"parser-inserted"</span>. When the element's end tag is
parsed, the user agent must <span title="running a
script">run</span> the <code>script</code> element.</p>
@@ -9841,23 +9897,23 @@
</ul>
- <p>...let <var>the script's type</var> for this
+ <p>...let <var>the script block's type</var> for this
<code>script</code> element be "<code
title="">text/javascript</code>".</p>
<p>Otherwise, if the <code>script</code> element has a <code
title="attr-script-type">type</code> attribute, let <var>the
- script's type</var> for this <code>script</code> element be the
- value of that attribute.</p>
+ script block's type</var> for this <code>script</code> element be
+ the value of that attribute.</p>
<p>Otherwise, the element has a <code
title="attr-script-language">language</code> attribute; let
- <var>the script's type</var> for this <code>script</code> element
- be the concatenation of the string "<code title="">text/</code>"
- followed by the value of the <code
- title="attr-script-language">language</code> attribute.</p>
- <!-- user agents already support, e.g., type="text/javascript1.3",
- so we don't have to support that separately. -->
+ <var>the script block's type</var> for this <code>script</code>
+ element be the concatenation of the string "<code
+ title="">text/</code>" followed by the value of the <code
+ title="attr-script-language">language</code> attribute.</p> <!--
+ user agents already support, e.g., type="text/javascript1.3", so
+ we don't have to support that separately. -->
</li>
@@ -9865,12 +9921,12 @@
<p>If the <code>script</code> element has a <code
title="attr-script-charset">charset</code> attribute, then let
- <var>the script's character encoding</var> for this
+ <var>the script block's character encoding</var> for this
<code>script</code> element be the encoding given by the <code
title="attr-script-charset">charset</code> attribute.</p>
- <p>Otherwise, let <var>the script's character encoding</var> for
- this <code>script</code> element be the same as <span
+ <p>Otherwise, let <var>the script block's character encoding</var>
+ for this <code>script</code> element be the same as <span
title="document's character encoding">the encoding of the document
itself</span>.</p>
@@ -9878,16 +9934,18 @@
<li>
- <p>If the <code>script</code> element is <span>without
- script</span>, or if the <code>script</code> element was created
- by an <span>XML parser</span> that itself was created as part of
+ <p>If <span title="concept-n-noscript">scripting is
+ disabled</span> for the <code>script</code> element, or if the
+ <code>script</code> element was created by an <span>XML
+ parser</span><!-- XXX xref --> that itself was created as part of
the processing of the <code
title="dom-innerHTML-XML">innerHTML</code> attribute's setter<!--
no need to worry about the HTML case, as the HTML parser handles
that for us -->, or if the user agent does not <span>support the
- scripting language</span> given by <var>the script's type</var>
- for this <code>script</code> element, then the user agent must
- abort these steps at this point. The script is not executed.</p>
+ scripting language</span> given by <var>the script block's
+ type</var> for this <code>script</code> element, then the user
+ agent must abort these steps at this point. The script is not
+ executed.</p>
</li>
@@ -9997,8 +10055,8 @@
<dt>Otherwise</dt>
<dd>The user agent must immediately <span title="executing a
- script block">execute the script</span>, even if other scripts
- are already executing.</dd>
+ script block">execute the script block</span>, even if other
+ scripts are already executing.</dd>
</dl>
@@ -10006,17 +10064,18 @@
</ol>
- <p><dfn>When a script completes loading</dfn>: If the script's
- element was added to one of the lists mentioned above and the
- document is still being parsed, then the parser handles
- it. Otherwise, the UA must run the following steps as the <span
- title="concept-task">task</span> that the <span>networking task
- source</span> places on the <span>task queue</span>:</p>
+ <p><dfn>When a script completes loading</dfn>: If the
+ <code>script</code> element was added to one of the lists mentioned
+ above and the document is still being parsed, then the parser
+ handles it. Otherwise, the UA must run the following steps as the
+ <span title="concept-task">task</span> that the <span>networking
+ task source</span> places on the <span>task queue</span>:</p>
<dl class="switch">
- <dt>If the script's element was added to the <dfn>list of scripts
- that will execute when the document has finished parsing</dfn>:</dt>
+ <dt>If the <code>script</code> element was added to the <dfn>list
+ of scripts that will execute when the document has finished
+ parsing</dfn>:</dt>
<dd>
@@ -10024,23 +10083,23 @@
<li>
- <p>If the script's element is not the first element in the list,
- then do nothing yet. Stop going through these steps.</p>
+ <p>If the <code>script</code> element is not the first element
+ in the list, then do nothing yet. Stop going through these
+ steps.</p>
</li>
<li>
<p>Otherwise, <span title="executing a script block">execute the
- script</span> (that is, the script associated with the first
- element in the list).</p>
+ script block</span> (the first element in the list).</p>
</li>
<li>
- <p>Remove the script's element from the list (i.e. shift out the
- first entry in the list).</p>
+ <p>Remove the <code>script</code> element from the list
+ (i.e. shift out the first entry in the list).</p>
</li>
@@ -10056,8 +10115,8 @@
</dd>
- <dt>If the script's element was added to the <dfn>list of scripts
- that will execute asynchronously</dfn>:</dt>
+ <dt>If the <code>script</code> element was added to the <dfn>list
+ of scripts that will execute asynchronously</dfn>:</dt>
<dd>
@@ -10072,16 +10131,15 @@
<li>
- <p><span title="executing a script block">Execute the
- script</span> (the script associated with the first element in
- the list).</p>
+ <p><span title="executing a script block">Execute the script
+ block</span> (the first element in the list).</p>
</li>
<li>
- <p>Remove the script's element from the list (i.e. shift out the
- first entry in the list).</p>
+ <p>Remove the <code>script</code> element from the list
+ (i.e. shift out the first entry in the list).</p>
</li>
@@ -10100,8 +10158,8 @@
</dd>
- <dt>If the script's element was added to the <dfn>list of scripts
- that will execute as soon as possible</dfn>:</dt>
+ <dt>If the <code>script</code> element was added to the <dfn>list
+ of scripts that will execute as soon as possible</dfn>:</dt>
<dd>
@@ -10110,13 +10168,13 @@
<li>
<p><span title="executing a script block">Execute the
- script</span>.</p>
+ script block</span>.</p>
</li>
<li>
- <p>Remove the script's element from the list.</p>
+ <p>Remove the <code>script</code> element from the list.</p>
</li>
@@ -10130,7 +10188,7 @@
title="event-load">load</code> event</span>.</p>
<p><dfn title="executing a script block">Executing a script
- block</dfn>: When the steps above require that the script be
+ block</dfn>: When the steps above require that the script block be
executed, the user agent must act as follows:</p>
<dl class="switch">
@@ -10138,21 +10196,22 @@
<dt>If the load resulted in an error (for example a DNS error, or
an HTTP 404 error)</dt>
- <dd><p>Executing the script must just consist of <span title="fire
- an error event">firing an <code title="event-error">error</code>
- event</span> at the element.</p></dd>
+ <dd><p>Executing the script block must just consist of <span
+ title="fire an error event">firing an <code
+ title="event-error">error</code> event</span> at the
+ element.</p></dd>
<dt>If the load was successful</dt>
+ <!-- SCRIPT EXEC -->
<dd>
<ol>
<li>
- <p>If the <code>script</code> element's <code>Document</code> is
- the <span>active document</span> in its <span>browsing
- context</span>, the user agent must execute the script:</p>
+ <p>Initialise <dfn><var>the script block's source</var></dfn> as
+ follows:</p>
<dl class="switch">
@@ -10160,12 +10219,13 @@
<dd>
- <p>That file must be used as the file to execute.</p>
+ <p>The contents of that file, interpreted as as string of
+ Unicode characters, are the script source.</p>
- <p>The file must be interpreted using the character encoding
- given by <var>the script's character encoding</var>, regardless
- of any metadata given by the file's <span
- title="Content-Type">Content-Type metadata</span>.</p>
+ <p>The file must be converted to Unicode using the character
+ encoding given by <var>the script block's character
+ encoding</var>, regardless of any metadata given by the file's
+ <span title="Content-Type">Content-Type metadata</span>.</p>
<p class="XXX">This means that a UTF-16 document will
always assume external scripts are UTF-16...? This applies,
@@ -10176,51 +10236,47 @@
</dd>
- <dt>If the script is inline</dt>
+ <dt>If the script is inline and <var>the script block's type</var> is a text-based language</dt>
<dd>
- <p>For scripting languages that consist of pure text, user
- agents must use the value of the DOM <code
- title="dom-script-text">text</code> attribute (defined below) as
- the script to execute, and for XML-based scripting languages,
- user agents must use all the child nodes of the
- <code>script</code> element as the script to execute.</p>
+ <p>The value of the DOM <code
+ title="dom-script-text">text</code> attribute at the time the
+ "<span>running a script</span>" algorithm was first invoked is
+ the script source.</p>
</dd>
+ <dt>If the script is inline and <var>the script block's type</var> is an XML-based language</dt>
+
+ <dd>
+
+ <p>The child nodes of the <code>script</code> element at the
+ time the "<span>running a script</span>" algorithm was first
+ invoked are the script source.</p>
+
+ </dd>
+
</dl>
- <!-- SCRIPT EXEC -->
- <p>In any case, the user agent must execute the script according to
- the semantics defined by the language associated with <var>the
- script's type</var> (see the <a href="#scriptingLanguages">scripting
- languages</a> section below).</p>
+ </li>
- <p>The <span>script execution context</span> of the script must
- be the <code>Window</code> object of that <span>browsing
- context</span>.</p>
+ <li>
- <p>The <span>script document context</span> of the script must
- be the <code>Document</code> object that owns the
- <code>script</code> element.</p>
+ <p><span title="create a script from a node">Create a
+ script</span> from the <code>script</code> element node, using
+ the <var>the script block's source</var> and the <var>the script
+ block's type</var>.</p>
- <p class="note">The element's attributes' values might have changed
- between when the element was inserted into the document and when the
- script has finished loading, as may its other attributes; similarly,
- the element itself might have been taken back out of the DOM, or had
- other changes made. These changes do not in any way affect the above
- steps; only the values of the attributes at the time the
- <code>script</code> element is first inserted into the document
- matter.</p>
+ <p class="note">This is where the script is compiled and
+ actually executed.</p>
</li>
<li>
- <p>Then, the user agent must <span>fire a <code
- title="event-load">load</code> event</span> at the
- <code>script</code> element.</p>
+ <p><span>Fire a <code title="event-load">load</code>
+ event</span> at the <code>script</code> element.</p>
</li>
@@ -10275,8 +10331,8 @@
<h5 id="scriptingLanguages">Scripting languages</h5>
<p>A user agent is said to <dfn>support the scripting language</dfn>
- if <var>the script's type</var> matches the MIME type of a scripting
- language that the user agent implements.</p>
+ if <var>the script block's type</var> matches the MIME type of a
+ scripting language that the user agent implements.</p>
<p>The following lists some MIME types and the languages to which
they refer:</p>
@@ -10316,9 +10372,9 @@
<dd>In a <code>head</code> element of an <span title="HTML documents">HTML document</span>, if there are no ancestor <code>noscript</code> elements.</dd>
<dd>Where <span>phrasing content</span> is expected in <span>HTML documents</span>, if there are no ancestor <code>noscript</code> elements.</dd>
<dt>Content model:</dt>
- <dd><span>Without script</span>, in a <code>head</code> element: in any order, zero or more <code>link</code> elements, zero or more <code>style</code> elements, and zero or more <code>meta</code> elements.</dd>
- <dd><span>Without script</span>, not in a <code>head</code> element: <span>transparent</span>, but there must be no <code>noscript</code> element descendants.</dd>
- <dd><span>With script</span>: text that conforms to the requirements given in the prose.</dd>
+ <dd>When <span title="concept-n-noscript">scripting is disabled</span>, in a <code>head</code> element: in any order, zero or more <code>link</code> elements, zero or more <code>style</code> elements, and zero or more <code>meta</code> elements.</dd>
+ <dd>When <span title="concept-n-noscript">scripting is disabled</span>, not in a <code>head</code> element: <span>transparent</span>, but there must be no <code>noscript</code> element descendants.</dd>
+ <dd>Otherwise: text that conforms to the requirements given in the prose.</dd>
<dt>Element-specific attributes:</dt>
<dd>None.</dd>
<dt>DOM interface:</dt>
@@ -10330,97 +10386,104 @@
scripting and those that don't support scripting, by affecting how
the document is parsed.</p>
- <p>The <code>noscript</code> element must not be used in <span>XML
- documents</span>.</p>
-
- <p class="note"><strong>The <code>noscript</code> element is only
- effective in the <span title="">HTML serialization</span><!-- XXX
- xref -->, it has no effect in the <span title="">XML
- serialization</span><!-- XXX xref -->.</strong></p>
-
<p>When used in <span>HTML documents</span>, the allowed content
model is as follows:</p>
- <p>In a <code>head</code> element, if the <code>noscript</code>
- element is <span>without script</span>, then the content model of a
- <code>noscript</code> element must contain only <code>link</code>,
- <code>style</code>, and <code>meta</code> elements. If the
- <code>noscript</code> element is <span>with script</span>, then the
- content model of a <code>noscript</code> element is text, except
- that invoking the <span>HTML fragment parsing algorithm</span> with
- the <code>noscript</code> element as the <var title="">context</var>
- element and the text contents as the <var title="">input</var> must
- result in a list of nodes that consists only of <code>link</code>,
- <code>style</code>, and <code>meta</code> elements.</p>
+ <dl>
- <p>Outside of <code>head</code> elements, if the
- <code>noscript</code> element is <span>without script</span>, then
- the content model of a <code>noscript</code> element is
- <span>transparent</span>, with the additional restriction that a
- <code>noscript</code> element must not have a <code>noscript</code>
- element as an ancestor (that is, <code>noscript</code> can't be
- nested).</p>
+ <dt>In a <code>head</code> element, if <span
+ title="concept-n-noscript">scripting is disabled</span> for the
+ <code>noscript</code> element</dt>
- <p>Outside of <code>head</code> elements, if the
- <code>noscript</code> element is <span>with script</span>, then the
- content model of a <code>noscript</code> element is text, except
- that the text must be such that running the following algorithm
- results in a conforming document with no <code>noscript</code>
- elements and no <code>script</code> elements, and such that no step
- in the algorithm causes an <span>HTML parser</span> to flag a
- <span>parse error</span>:</p>
+ <dd><p>The <code>noscript</code> element must contain only
+ <code>link</code>, <code>style</code>, and <code>meta</code>
+ elements.</p></dd>
- <ol>
+ <dt>In a <code>head</code> element, if <span
+ title="concept-n-noscript">scripting is enabled</span> for the
+ <code>noscript</code> element</dt>
- <li>Remove every <code>script</code> element from the
- document.</li>
+ <dd><p>The <code>noscript</code> element must contain only text,
+ except that invoking the <span>HTML fragment parsing
+ algorithm</span> with the <code>noscript</code> element as the <var
+ title="">context</var> element and the text contents as the <var
+ title="">input</var> must result in a list of nodes that consists
+ only of <code>link</code>, <code>style</code>, and
+ <code>meta</code> elements.</p></dd>
- <li>Make a list of every <code>noscript</code> element in the
- document. For every <code>noscript</code> element in that list,
- perform the following steps:
+ <dt>Outside of <code>head</code> elements, if <span
+ title="concept-n-noscript">scripting is disabled</span> for the
+ <code>noscript</code> element</dt>
+ <dd><p>The <code>noscript</code> element's content model is
+ <span>transparent</span>, with the additional restriction that a
+ <code>noscript</code> element must not have a <code>noscript</code>
+ element as an ancestor (that is, <code>noscript</code> can't be
+ nested).</p></dd>
+
+ <dt>Outside of <code>head</code> elements, if <span
+ title="concept-n-noscript">scripting is enabled</span> for the
+ <code>noscript</code> element</dt>
+
+ <dd>
+
+ <p>The <code>noscript</code> element must contain only text,
+ except that the text must be such that running the following
+ algorithm results in a conforming document with no
+ <code>noscript</code> elements and no <code>script</code>
+ elements, and such that no step in the algorithm causes an
+ <span>HTML parser</span> to flag a <span>parse error</span>:</p>
+
<ol>
- <li>Let the <var title="">parent element</var> be the parent
- element of the <code>noscript</code> element.</li>
+ <li>Remove every <code>script</code> element from the
+ document.</li>
- <li>Take all the children of the <var title="">parent element</var>
- that come before the <code>noscript</code> element, and call these
- elements <var title="">the before children</var>.</li>
+ <li>Make a list of every <code>noscript</code> element in the
+ document. For every <code>noscript</code> element in that list,
+ perform the following steps:
- <li>Take all the children of the <var title="">parent element</var>
- that come <em>after</em> the <code>noscript</code> element, and
- call these elements <var title="">the after children</var>.</li>
+ <ol>
- <li>Let <var title="">s</var> be the concatenation of all the
- <span>text node</span> children of the <code>noscript</code>
- element.</li>
+ <li>Let the <var title="">parent element</var> be the parent
+ element of the <code>noscript</code> element.</li>
- <li>Set the <code title="dom-innerHTML-HTML">innerHTML</code>
- attribute of the <var title="">parent element</var> to the value
- of <var title="">s</var>. (This, as a side-effect, causes the
- <code>noscript</code> element to be removed from the
- document.)</li>
+ <li>Take all the children of the <var title="">parent element</var>
+ that come before the <code>noscript</code> element, and call these
+ elements <var title="">the before children</var>.</li>
- <li>Insert <var title="">the before children</var> at the start of
- the <var title="">parent element</var>, preserving their original
- relative order.</li>
+ <li>Take all the children of the <var title="">parent element</var>
+ that come <em>after</em> the <code>noscript</code> element, and
+ call these elements <var title="">the after children</var>.</li>
- <li>Insert <var title="">the after children</var> at the end of the
- <var title="">parent element</var>, preserving their original
- relative order.</li>
+ <li>Let <var title="">s</var> be the concatenation of all the
+ <span>text node</span> children of the <code>noscript</code>
+ element.</li>
+ <li>Set the <code title="dom-innerHTML-HTML">innerHTML</code>
+ attribute of the <var title="">parent element</var> to the value
+ of <var title="">s</var>. (This, as a side-effect, causes the
+ <code>noscript</code> element to be removed from the
+ document.)</li>
+
+ <li>Insert <var title="">the before children</var> at the start of
+ the <var title="">parent element</var>, preserving their original
+ relative order.</li>
+
+ <li>Insert <var title="">the after children</var> at the end of the
+ <var title="">parent element</var>, preserving their original
+ relative order.</li>
+
+ </ol>
+
+ </li>
+
</ol>
- </li>
+ </dd>
- </ol>
+ </dl>
- <p>The <code>noscript</code> element has no other requirements. In
- particular, children of the <code>noscript</code> element are not
- exempt from form submission, scripting, and so forth, even when the
- element is <span>with script</span>.</p>
-
<p class="note">All these contortions are required because, for
historical reasons, the <code>noscript</code> element is handled
differently by the <span>HTML parser</span> based on whether <span
@@ -10429,13 +10492,22 @@
XML the parser is not affected by such state, and thus the element
would not have the desired effect.</p>
- <p class="note">The <code>noscript</code> element interacts poorly
- with the <code title="dom-document-designMode">designMode</code>
- feature. Authors are encouraged to not use <code>noscript</code>
- elements on pages that will have <code
- title="dom-document-designMode">designMode</code> enabled.</p>
+ <p>The <code>noscript</code> element must not be used in <span>XML
+ documents</span>.</p>
+ <p class="note"><strong>The <code>noscript</code> element is only
+ effective in the <span>HTML serialization</span><!-- XXX xref -->,
+ it has no effect in the <span>XML serialization</span><!-- XXX xref
+ -->.</strong></p>
+ <p>The <code>noscript</code> element has no other requirements. In
+ particular, children of the <code>noscript</code> element are not
+ exempt from form submission, scripting, and so forth, even when
+ <span title="concept-n-script">scripting is enabled</span> for the
+ element.</p>
+
+
+
<h4>The <dfn><code>eventsource</code></dfn> element</h4>
<dl class="element">
@@ -15596,7 +15668,7 @@
<p class="note">The value of <code
title="dom-img-complete">complete</code> can thus change while a
- script is executing.</p>
+ <span title="concept-script">script</span> is executing.</p>
<p>Three constructors are provided for creating
<code>HTMLImageElement</code> objects (in addition to the factory
@@ -16695,6 +16767,12 @@
<dl>
+ <!-- XXX disallow cross-origin loads of any kind (networking
+ override that only allows same-origin URLs or about:,
+ javascript:, data:) -->
+ <!-- XXX block access to 'contentWindow.frames' from iframe owner -->
+ <!-- XXX block access to 'parent.frames' from sandbox -->
+
<dt>The <dfn>sandboxed navigation browsing context flag</dfn></dt>
<dd>
@@ -20049,14 +20127,15 @@
<p>The <dfn title="attr-media-controls"><code>controls</code></dfn>
attribute is a <span>boolean attribute</span>. If the attribute is
- present, or if the <span>media element</span> is <span>without
- script</span>, then the user agent should <dfn>expose a user
- interface to the user</dfn>. This user interface should include
- features to begin playback, pause playback, seek to an arbitrary
- position in the content (if the content supports arbitrary seeking),
- change the volume, and show the media content in manners more
- suitable to the user (e.g. full-screen video or in an independent
- resizable window). Other controls may also be made available.</p>
+ present, or if <span title="concept-n-noscript">scripting is
+ disabled</span> for the <span>media element</span>, then the user
+ agent should <dfn>expose a user interface to the user</dfn>. This
+ user interface should include features to begin playback, pause
+ playback, seek to an arbitrary position in the content (if the
+ content supports arbitrary seeking), change the volume, and show the
+ media content in manners more suitable to the user (e.g. full-screen
+ video or in an independent resizable window). Other controls may
+ also be made available.</p>
<p>If the attribute is absent, then the user agent should avoid
making a user interface available that could conflict with an
@@ -20370,8 +20449,9 @@
element. The contents of the <code>canvas</code> element, if any,
are the element's <span>fallback content</span>.</p>
- <p>In interactive visual media, if the <code>canvas</code> element
- is <span>with script</span>, the <code>canvas</code> element
+ <p>In interactive visual media, if <span
+ title="concept-n-script">scripting is enabled</span> for the
+ <code>canvas</code> element, the <code>canvas</code> element
represents an embedded element with a dynamically created image.</p>
<p>In non-interactive, static, visual media, if the
@@ -20383,10 +20463,10 @@
size. Otherwise, the element represents its <span>fallback
content</span> instead.</p>
- <p>In non-visual media, and in visual media if the
- <code>canvas</code> element is <span>without script</span>, the
- <code>canvas</code> element represents its <span>fallback
- content</span> instead.</p>
+ <p>In non-visual media, and in visual media if <span
+ title="concept-n-noscript">scripting is disabled</span> for the
+ <code>canvas</code> element, the <code>canvas</code> element
+ represents its <span>fallback content</span> instead.</p>
<p>The <code>canvas</code> element has two attributes to control the
size of the coordinate space: <dfn
@@ -37230,6 +37310,7 @@
http://www.mozilla.org/docs/dom/domref/dom_window_ref.html
http://lxr.mozilla.org/mozilla/source/dom/public/idl/base/nsIDOMWindow.idl - scrollBy, etc
http://lxr.mozilla.org/mozilla/source/dom/public/idl/base/nsIDOMWindowInternal.idl - DOM level 0
+ close() focus() blur()
-->
<p>The <dfn title="dom-window"><code>window</code></dfn>, <dfn
@@ -37237,7 +37318,7 @@
title="dom-self"><code>self</code></dfn> DOM attributes must all
return the <code>Window</code> object itself.</p>
- <p>The <code>Window</code> object also provides the scope for script
+ <p>The <code>Window</code> object also provides the scope for <span title="concept-script">script</span>
execution. Each <code>Document</code> in a <span>browsing
context</span> has an associated <dfn>list of added properties</dfn>
that, when a document is <span title="active
@@ -37343,9 +37424,10 @@
enabled</span>; otherwise, it must not be enabled unless the
<span>browsing context</span> was just created as part of the
<span>the rules for choosing a browsing context given a browsing
- context name</span>. The navigation must be done with the
- <span>script browsing context</span> of the script that invoked the
- method as the <span>source browsing context</span>.</p>
+ context name</span>. The navigation must be done with the <span
+ title="script's browsing context">browsing context</span> of the
+ <span title="concept-script">script</span> that invoked the method as the <span>source browsing
+ context</span>.</p>
<p>The method must return the <code>Window</code> object of the
default view of the <span>browsing context</span> that was
@@ -37378,6 +37460,44 @@
+ <h4>Garbage collection and browsing contexts</h4>
+
+ <p>A <span>browsing context</span> has a strong reference to each of
+ its <code>Document</code>s and <span title="view">views</span>, and
+ the user agent itself has a strong reference to its <span
+ title="top-level browsing context">top-level browsing
+ contexts</span>.</p>
+
+ <p>When a <span>browsing context</span> is to <dfn>discard a
+ <code>Document</code></dfn>, that means that it is to lose the
+ strong reference from the <code>Document</code>'s <span>browsing
+ context</span> to the <code>Document</code>.</p>
+
+ <p class="note">The <span>browsing context</span>'s <span>default
+ view</span>'s <code>Window</code> object <span title="implied strong
+ reference">has a strong reference of its own</span> to the
+ <code>Document</code> object of the <span>browsing context</span>'s
+ <span>active document</span>.</p>
+
+ <p>When <dfn>a <em><span>browsing context</span></em> is
+ discarded</dfn>, the strong reference from the user agent itself to
+ the <span>browsing context</span> must be severed, and all the
+ <code>Document</code> objects for all the entries in the
+ <span>browsing context</span>'s session history must be <span
+ title="discard a document">discarded</span> as well.</p>
+
+ <p>User agents may <span title="a browsing context is
+ discarded">discard</span> <span title="top-level browsing
+ context">top-level browsing contexts</span> at any time (typically,
+ in response to user requests, e.g. when a user closes a window
+ containing one or more <span title="top-level browsing
+ context">top-level browsing contexts</span>). Other <span
+ title="browsing context">browsing contexts</span> must be discarded
+ once their <code>Window</code> object is eligible for garbage
+ collection.</p>
+
+
+
<h3>Origin</h3>
<!-- Hallowed are the Ori -->
@@ -37871,6 +37991,8 @@
<h3 id="scripting">Scripting</h3>
+ <h4>Introduction</h4>
+
<p>Various mechanisms can cause author-provided executable code to
run in the context of a document. These mechanisms include, but are
probably not limited to:</p>
@@ -37895,91 +38017,293 @@
</ul>
- <p>When a script is created<!-- which is marked by SCRIPT EXEC in
- this spec -->, it is associated with a <span>script execution
- context</span>, a <span>script browsing context</span>, and a
- <span>script document context</span>.</p>
- <!-- SCRIPT EXEC -->
- <h4>Script execution contexts</h4>
+ <h4>Enabling and disabling scripting</h4>
- <p>The <dfn>script execution context</dfn> of a script is defined
- when that script is created. In this specification, it is either a
- <code>Window</code> object or an empty object; other specifications
- might make the script execution context be some other object.</p>
+ <p><dfn title="concept-bc-script">Scripting is enabled</dfn> in a
+ <em><span>browsing context</span></em> when all of the
+ following conditions are true:</p>
- <p>When the <span>script execution context</span> of a script is an
- empty object, it can't do anything that interacts with the
- environment.</p>
+ <ul>
- <p>A <span>script execution context</span> always has an associated
- <span>browsing context</span>, known as the <dfn>script browsing
- context</dfn>. If the <span>script execution context</span> is a
- <code>Window</code> object, then that object's <span>browsing
- context</span> is it. Otherwise, the <span>script execution
- context</span> is associated explicitly with a <span>browsing
- context</span> when it is created.</p>
+ <li>The user agent supports scripting.</li>
- <p>Every script whose <span>script execution context</span> is a
- <code>Window</code> object is also associated with a
- <code>Document</code> object, known as its <dfn>script document
- context</dfn>. It is used to <span title="resolve a
- url">resolve</span> URLs. The document is assigned when the script
- is created, as with the <span>script browsing context</span>.</p>
+ <li>The user has not disabled scripting for this <span>browsing
+ context</span> at this time. (User agents may provide users with
+ the option to disable scripting globally, or in a finer-grained
+ manner, e.g. on a per-origin basis.)</li>
+ <li id="sandboxScriptBlocked">The <span>browsing context</span>
+ does not have the <span>sandboxed scripts browsing context
+ flag</span> set.</li>
+
+ </ul>
+
+ <p><dfn title="concept-bc-noscript">Scripting is disabled</dfn> in a
+ <span>browsing context</span> when any of the above conditions are
+ false (i.e. when scripting is not <span
+ title="concept-bc-script">enabled</span>).</p>
+
<hr>
- <p>It is said that <dfn>scripting is disabled</dfn> in a
- <span>script execution context</span> when any of the following
- conditions are true:</p>
+ <p><dfn title="concept-n-script">Scripting is enabled</dfn> for a
+ <em>node</em> if the <code>Document</code> object of the node (the
+ node itself, if it is itself a <code>Document</code> object) has an
+ associated <span>browsing context</span>, and <span
+ title="concept-bc-script">scripting is enabled</span> in that
+ <span>browsing context</span>.</p>
- <ul>
+ <p><dfn title="concept-n-noscript">Scripting is disabled</dfn> for a
+ node if there is no such <span>browsing context</span>, or if <span
+ title="concept-bc-noscript">scripting is disabled</span> in that
+ <span>browsing context</span>.</p>
- <li>The user agent does not support scripting.</li>
- <li>The user has disabled scripting for this <span>script execution
- context</span>. (User agents may provide users with the option to
- disable scripting globally, on a per-origin basis, or in other ways
- down to the granularity of individual <span title="script execution
- context">script execution contexts</span>.)</li>
- <li id="designModeScriptBlocked">The <span>script execution
- context</span>'s associated <span>browsing context</span>'s
- <span>active document</span> has <code
- title="dom-document-designMode">designMode</code> enabled.</li>
+ <!-- SCRIPT EXEC (marks areas related to creation of scripts) -->
+ <h4>Processing model</h4>
- <li id="sandboxScriptBlocked">The <span>script execution
- context</span>'s associated <span>browsing context</span> has the
- <span>sandboxed scripts browsing context flag</span> set.</li>
+ <h5>Definitions</h5>
- </ul>
+ <p>A <dfn title="concept-script">script</dfn> has:</p>
- <p>A node is said to be <dfn>without script</dfn> if either the
- <code>Document</code> object of the node (the node itself, if it is
- itself a <code>Document</code> object) does not have an associated
- <span>browsing context</span>, or <span>scripting is disabled</span>
- in that <span>browsing context</span>.</p>
+ <dl>
- <p>A node is said to be <dfn>with script</dfn> if it is not
- <span>without script</span>.</p>
+ <dt>A <dfn>script execution environment</dfn></dt>
- <p class="XXX">If you can find a better pair of terms than
- "with script" and "without script" let me know. The only things I
- can find that are less confusing are also way, way longer.</p>
+ <dd>
- <p>When a script is to be executed in a <span>script execution
- context</span> in which <span>scripting is disabled</span>, the
- script must do nothing and return nothing (a void return value).</p>
+ <p>The characteristics of the script execution environment depend
+ on the language, and are not defined by this specification.</p>
- <p class="note">Thus, for instance, enabling <code
- title="dom-document-designMode">designMode</code> will disable any
- event handler attributes, event listeners, timeouts, etc, that were
- set by scripts in the document.</p>
+ <p class="example">In JavaScript, the script execution environment
+ consists of the interpreter, the stack of <i>execution
+ contexts</i>, the <i>global code</i> and <i>function code</i> and
+ the Function objects resulting, and so forth.</p>
+ </dd>
+ <dt>A <dfn>list of code entry-points</dfn></dt>
+ <dd>
+
+ <p>Each code entry-point represents a block of executable code
+ that the script exposes to other scripts and to the user
+ agent.</p>
+
+ <p class="example">Each Function object in a JavaScript
+ <span>script execution environment</span> has a corresponding code
+ entry-point, for instance.</p>
+
+ <p>The main program code of the script, if any, is the
+ <dfn><i>initial code entry-point</i></dfn>. Typically, the code
+ corresponding to this entry-point is executed immediately after
+ the script is parsed.</p>
+
+ <p class="example">In JavaScript, this corresponds to the
+ execution context of the global code.</p>
+
+ </dd>
+
+ <dt>A relationship with the <dfn>script's global object</dfn></dt>
+
+ <dd>
+
+ <p>An object that provides the APIs that the code can use.</p>
+
+ <p class="example">This is typically a <code>Window</code>
+ object. In JavaScript, this corresponds to the <i>global
+ object</i>.</p>
+
+ <p class="note">When a <span>script's global object</span> is an
+ empty object, it can't do anything that interacts with the
+ environment.</p>
+
+ </dd>
+
+ <dt>A relationship with the <dfn>script's browsing context</dfn></dt>
+
+ <dd>
+
+ <p>A <span>browsing context</span> that is assigned responsibility
+ for actions taken by the script.</p>
+
+ <p class="example">When a script creates and <span
+ title="navigate">navigates</span> a new <span>top-level browsing
+ context</span>, the <code title="dom-opener">opener</code>
+ attribute of the new <span>browsing context</span>'s
+ <code>Window</code> object will be set to the <span>script's
+ browsing context</span>'s <code>Window</code> object.</p>
+
+ </dd>
+
+ <dt>A <dfn title="script's character encoding">character encoding</dfn></dt>
+
+ <dd>
+
+ <p>A character encoding, set when the script is created, used to
+ encode URLs. <span id="sce-not-copy">If the character encoding is
+ set from another source, e.g. a <span>document's character
+ encoding</span>, then the <span>script's character encoding</span>
+ must follow the source, so that if the source's changes, so does
+ the script's.</span></p>
+
+ </dd>
+
+ <dt>A <dfn title="script's base URL">base URL</dfn></dt>
+
+ <dd>
+
+ <p>A <span>URL</span>, set when the script is created, used to
+ resolve relative URLs. <span id="sbu-not-copy">If the base URL is
+ set from another source, e.g. a <span>document base URL</span>,
+ then the <span>script's base URL</span> must follow the source, so
+ that if the source's changes, so does the script's.</span></p>
+
+ </dd>
+
+ <dt>Membership in a <dfn>script group</dfn></dt>
+
+ <dd>
+
+ <p>A group of one or more scripts that are loaded in the same
+ context, which are always disabled as a group. Scripts in a script
+ group all have the same <span title="script's global
+ object">global object</span> and <span title="script's browsing
+ context">browsing context</span>.</p>
+
+ <p>A script group can be <i>frozen</i>. When a script group is
+ frozen, any code defined in that script group will throw an
+ exception when invoked. A frozen script group can be
+ <i>unfrozen</i>, allowing scripts in that script group to run
+ normally again.</p>
+
+ </dd>
+
+ </dl>
+
+
+
+ <h5>Calling scripts</h5>
+
+ <p>When a user agent is to <dfn>jump to a code entry-point</dfn> for
+ a <span title="concept-script">script</span>, if <span
+ title="concept-bc-noscript">scripting is disabled</span> in the
+ <span>script's browsing context</span>, or if the script's
+ <span>script group</span> is <i>frozen</i>, then the user agent must
+ throw an <code>UNAVAILABLE_SCRIPT_ERR</code> exception. Otherwise,
+ the <span title="script execution environment">script execution
+ environment</span> for the <span
+ title="concept-script">script</span> must execute the code for the
+ given code entry-point.</p>
+
+ <p>When executable code in one <span
+ title="concept-script">script</span> makes a call to another <span
+ title="concept-script">script</span>, the user agent must <span
+ title="jump to a code entry-point">jump</span> to the corresponding
+ code entry-point in that second script.</p>
+
+ <p>Any time the user agent to invoke a callback defined in a <span
+ title="concept-script">script</span>, the user agent must <span
+ title="jump to a code entry-point">jump</span> to the corresponding
+ code entry-point in that second script.</p>
+
+
+
+ <h5>Creating scripts</h5>
+
+ <p>When the specification says that a <span
+ title="concept-script">script</span> is to be <dfn title="create a
+ script">created</dfn>, given some script source, its scripting
+ language, a global object, a browsing context, a character encoding,
+ a base URL, and a script group, the user agent must run the
+ following steps:</p>
+
+ <ol>
+
+ <li><p>Set up a <span>script execution environment</span> as
+ appropriate for the scripting language.</p></li>
+
+ <li><p>Parse/compile/initialise the source of the script using the
+ <span>script execution environment</span>, as appropriate for the
+ scripting language, and thus obtain the <span>list of code
+ entry-points</span> for the script. If the semantics of the
+ scripting language and the given source code are such that there is
+ executable code to be immediately run, then the <i>initial code
+ entry-point</i> is the entry-point for that code.</p></li>
+
+ <li><p>Set up the <span>script's global object</span>, the
+ <span>script's browsing context</span>, the <span>script's
+ character encoding</span>, and the <span>script's base URL</span>
+ from the settings passed to this algorithm.</p></li>
+
+ <li><p>Add the <span title="concept-script">script</span> to the given <span>script
+ group</span>.</p></li>
+
+ <li><p><span title="jump to a code entry-point">Jump</span> to the
+ <span title="concept-script">script</span>'s <i>initial code
+ entry-point</i>.</p></li>
+
+ </ol>
+
+ <hr>
+
+ <p>When the user agent is to <dfn>create an impotent script</dfn>,
+ given some script source, its scripting language, and a browsing
+ context, the user agent must <span>create a script</span>, using the
+ given script source and scripting language, using a new empty object
+ as the global object, using the given browsing context as the
+ browsing context, and using a new script group as the script
+ group. The character encoding and base URL for the resulting <span
+ title="concept-script">script</span> are not important as no APIs
+ are exposed to the script.</p>
+
+ <hr>
+
+ <p>When the specification says that a <span
+ title="concept-script">script</span> is to be <dfn title="create a
+ script from a node">created from a node</dfn> <var
+ title="">node</var>, given some script source and its scripting
+ language, the user agent <span>create a script</span>, using the
+ given script source and scripting language, and using <span>the
+ script settings determined from the node</span> <var
+ title="">node</var>.</p>
+
+ <p><dfn>The script settings determined from the node</dfn> <var
+ title="">node</var> are computed as follows:</p>
+
+ <ol>
+
+ <li><p>Let <var title="">document</var> be the
+ <code>Document</code> of <var title="">node</var> (or <var
+ title="">node</var> itself if it is a
+ <code>Document</code>).</p></li>
+
+ <li><p>The browsing context is the <span>browsing context</span> of
+ <var title="">document</var>.</p>
+
+ <li><p>The global object is the <code>Window</code> object of the
+ <span>default view</span> of the <span>browsing context</span> of
+ <var title="">document</var>.</p></li>
+
+ <li><p>The character encoding is the <span title="document's
+ character encoding">character encoding</span> of <var
+ title="">document</var>. (<a href="#sce-not-copy">This is a
+ reference, not a copy</a>.)</p></li>
+
+ <li><p>The base URL is the <span title="document base URL">base
+ URL</span> of <var title="">document</var>. (<a
+ href="#sbu-not-copy">This is a reference, not a copy</a>.)</p></li>
+
+ <li><p>The script group is the <span>current script group</span> of
+ <var title="">document</var>.</p></li>
+
+ </ol>
+
+
+
<h4>Event loops</h4>
<p>To coordinate events, user interaction, scripts, rendering,
@@ -38044,6 +38368,17 @@
</dl>
+ <p>Each <span title="concept-task">task</span> is associated with a
+ <code>Document</code>; if the task was queued in the context of an
+ element, then it is the element's <code>Document</code>; if the task
+ was queued in the context of a <span>browsing context</span>, then
+ it is the <span>browsing context</span>'a <span>active
+ document</span> at the time the task was queued; if the task was
+ queued by or for a <span title="concept-script">script</span> then
+ the document is the script's <span>script's browsing
+ context</span>'s <span>active document</span> at the time the task
+ was queued.</p>
+
<p>When a user agent is to <dfn>queue a task</dfn>, it must add the
given task to one of the <span title="task queue">task queues</span>
of the relevant <span>event loop</span>. All the tasks from one
@@ -38069,8 +38404,10 @@
<ol>
<li><p>Run the oldest task on one of the <span>event loop</span>'s
- <span title="task queue">task queues</span>. The user agent may
- pick any <span>task queue</span>.</p></li>
+ <span title="task queue">task queues</span>, ignoring tasks whose
+ associated <code>Document</code>s are not <span title="active
+ document">active</span>. The user agent may pick any <span>task
+ queue</span>.</p></li>
<li><p>Remove that task from its <span>task queue</span>.</p></li>
@@ -38142,61 +38479,123 @@
<!-- SCRIPT EXEC -->
<h4 id="javascript-protocol"><dfn title="javascript protocol">The <code title="">javascript:</code> protocol</dfn></h4>
- <p>A URL using the <code title="">javascript:</code> protocol must,
- if and when <dfn title="concept-js-deref">dereferenced</dfn>, be
- evaluated by executing the script obtained using the content
- retrieval operation defined for <code title="">javascript:</code>
- URLs. <a href="#refsJSURL">[JSURL]</a></p>
+ <p>When a <span>URL</span> using the <code
+ title="">javascript:</code> protocol is <dfn
+ title="concept-js-deref">dereferenced</dfn>, the user agent must run
+ the following steps:</p>
+ <ol>
+
+ <li><p>Let the script source be the string obtained using the
+ content retrieval operation defined for <code
+ title="">javascript:</code> URLs. <a
+ href="#refsJSURL">[JSURL]</a></p></li>
+
<!--
JSURL: http://ietfreport.isoc.org/all-ids/draft-hoehrmann-javascript-scheme-00.txt and
http://www.websitedev.de/ietf/draft-hoehrmann-javascript-scheme-00.txt should be as stable as it gets,
http://ietfreport.isoc.org/idref/draft-hoehrmann-javascript-scheme/ for the latest version
-->
- <p>When a <span>browsing context</span> is <span
- title="navigate">navigated</span> to a <code>javascript:</code> URL,
- and the <span>active document</span> of that browsing context has
- the <span>same origin</span> as the script given by that URL, the
- <span>script execution context</span> must be the
- <code>Window</code> object of the <span>browsing context</span>
- being navigated, and the <span>script document context</span> must
- be that <span>active document</span>.</p>
+ <li>
- <p>When a <span>browsing context</span> is <span
- title="navigate">navigated</span> to a <code>javascript:</code> URL,
- and the <span>active document</span> of that browsing context has an
- <span>origin</span> that is <em>not</em> the <span title="same
- origin">same</span> as that of the script given by the URL, the
- <span>script execution context</span> must be an empty object, and
- the <span>script browsing context</span> must be the <span>browsing
- context</span> being <span title="navigate">navigated</span>.</p>
+ <p>Use the appropriate step from the following list:</p>
- <p>Otherwise, if the <code>Document</code> object of the element,
- attribute, or style sheet from which the <code>javascript:</code>
- URL was reached has an associated <span>browsing context</span>, the
- <span>script execution context</span> must be an empty object, and
- the <span>script execution context</span>'s associated
- <span>browsing context</span> must be that <span>browsing
- context</span>.</p>
+ <dl>
- <p>Otherwise, the script is not executed and its return value is
- void.</p>
+ <dt>If a <span>browsing context</span> is being <span
+ title="navigate">navigated</span> to a <code>javascript:</code>
+ URL, and the <span>active document</span> of that browsing
+ context has the <span>same origin</span> as the script given by
+ that URL</dt>
- <p>If the result of executing the script is void (there is no return
- value), then the URL must be treated in a manner equivalent to an
- HTTP resource with an HTTP 204 No Content response.</p>
+ <dd>
- <p>Otherwise, the URL must be treated in a manner equivalent to an
- HTTP resource with a 200 OK response whose <span
- title="Content-Type">Content-Type metadata</span> is <code
- title="">text/html</code> and whose response body is the return
- value converted to a string value.</p>
+ <p><span title="create a script from a node">Create a
+ script</span> from the <code>Document</code> node of the
+ <span>active document</span>, using the aforementioned script
+ source, and assuming the scripting language is JavaScript.</p>
- <p class="note">Certain contexts, in particular <code>img</code>
- elements, ignore the <span title="Content-Type">Content-Type
- metadata</span>.</p>
+ <p>Let <var title="">result</var> be the return value of the
+ <i>initial code entry-point</i> of this <span
+ title="concept-script">script</span>. If an exception was
+ raised, let <var title="">result</var> be void instead.</p>
+ </dd>
+
+ <dt>If a <span>browsing context</span> is being <span
+ title="navigate">navigated</span> to a <code>javascript:</code>
+ URL, and the <span>active document</span> of that browsing
+ context has an <span>origin</span> that is <em>not</em> the <span
+ title="same origin">same</span> as that of the script given by
+ the URL</dt>
+
+ <dd>
+
+ <p><span>Create an impotent script</span> using the
+ aforementioned script source, with the scripting language set to
+ JavaScript, and with the <span>browsing context</span> being
+ <span title="navigate">navigated</span> as the browsing
+ context.</p>
+
+ <p>Let <var title="">result</var> be the return value of the
+ <i>initial code entry-point</i> of this <span
+ title="concept-script">script</span>. If an exception was
+ raised, let <var title="">result</var> be void instead.</p>
+
+ </dd>
+
+ <dt>If the <code>Document</code> object of the element,
+ attribute, or style sheet from which the <code>javascript:</code>
+ URL was reached has an associated <span>browsing
+ context</span></dt>
+
+ <dd>
+
+ <p><span>Create an impotent script</span> using the
+ aforementioned script source, with the scripting language set to
+ JavaScript, and with the <code>Document</code>'s object's
+ <span>browsing context</span> as the browsing context.</p>
+
+ <p>Let <var title="">result</var> be the return value of the
+ <i>initial code entry-point</i> of this <span
+ title="concept-script">script</span>. If an exception was
+ raised, let <var title="">result</var> be void instead.</p>
+
+ </dd>
+
+ <dt>Otherwise</dt>
+
+ <dd>
+
+ <p>Let <var title="">result</var> be void.</p>
+
+ </dd>
+
+ </dl>
+
+ </li>
+
+ <li>
+
+ <p>If the result of executing the script is void (there is no
+ return value), then the URL must be treated in a manner equivalent
+ to an HTTP resource with an HTTP 204 No Content response.</p>
+
+ <p>Otherwise, the URL must be treated in a manner equivalent to an
+ HTTP resource with a 200 OK response whose <span
+ title="Content-Type">Content-Type metadata</span> is <code
+ title="">text/html</code> and whose response body is the return
+ value converted to a string value.</p>
+
+ <p class="note">Certain contexts, in particular <code>img</code>
+ elements, ignore the <span title="Content-Type">Content-Type
+ metadata</span>.</p>
+
+ </li>
+
+ </ol>
+
<div class="example">
<p>So for example a <code title="">javascript:</code> URL for a
@@ -38219,10 +38618,10 @@
</div>
- <p class="note">The rules for handling script execution in a
- <span>script execution context</span> include making the script not
- execute (and just return void) in certain cases, e.g. in a sandbox
- or when the user has disabled scripting altogether.</p>
+ <p class="note">The rules for <span title="create a script">creating
+ a script</span> include making the script not execute (and just
+ return void) in certain cases, e.g. in a sandbox or when the user
+ has disabled scripting altogether.</p>
<h4>Events</h4>
@@ -38241,24 +38640,26 @@
<!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A...%3Cscript%3E%0Aw(a%3Ddocument.implementation.createDocument(null%2C%20null%2C%20null))%3B%0Aw(a.appendChild(a.createElementNS('http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%2C%20'html')))%3B%0Aw(b%3Da.firstChild.appendChild(a.createElementNS('http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%2C%20'body')))%3B%0Aw(b.test%20%3D%20w)%3B%0Aw(b.setAttribute('onclick'%2C%20'test(%22fire%3A%20%22%20%2B%20event)'))%3B%0Aw(b.onclick)%3B%0Aw(e%3Da.createEvent('Event'))%3B%0Aw(e.initEvent('click'%2C%20false%2C%20false))%3B%0Aw(b.dispatchEvent(e))%3B%0A%3C%2Fscript%3E -->
- <p><span>HTML elements</span> can have <dfn>event handler
- attributes</dfn> specified. These act as bubbling event listeners
- for the element on which they are specified.</p>
+ <p>Many objects can have <dfn>event handler attributes</dfn>
+ specified. These act as bubbling event listeners for the element on
+ which they are specified.</p>
- <p>Each event handler attribute has two parts, an <span title="event
- handler content attributes">event handler content attribute</span>
- and an <span title="event handler DOM attributes">event handler DOM
- attribute</span>. Event handler attributes must initially be set to
- null. When their value changes (through the changing of their event
- handler content attribute or their event handler DOM attribute),
- they will either be null, or have an <code>EventListener</code>
- object assigned to them.</p>
+ <p>On <span>HTML elements</span>, each event handler attribute has
+ two parts, an <span title="event handler content attributes">event
+ handler content attribute</span> and an <span title="event handler
+ DOM attributes">event handler DOM attribute</span>. Event handler
+ attributes must initially be set to null. When their value changes
+ (through the changing of their event handler content attribute or
+ their event handler DOM attribute), they will either be null, or
+ have an <code>EventListener</code> object assigned to them.</p>
<p>Objects other than <code>Element</code> objects, in particular
<code>Window</code>, only have <span title="event handler DOM
attributes">event handler DOM attribute</span> (since they have no
content attributes).</p>
+ <hr>
+
<p><dfn>Event handler content attributes</dfn>, when specified, must
contain valid ECMAScript code matching the ECMAScript <code
title="">FunctionBody</code> production. <a
@@ -38267,43 +38668,61 @@
<!-- SCRIPT EXEC -->
<p>When an event handler content attribute is set, if the element is
owned by a <code>Document</code> that is in a <span>browsing
- context</span>, its new value must be interpreted as the body of an
- anonymous function with a single argument called <code>event</code>,
- with the new function's scope chain being linked from the activation
- object of the handler, to the element, to the element's
- <code>form</code> element if it is a form control, to the
- <code>Document</code> object, to the <code>Window</code> object of
- the <span>browsing context</span> of that <code>Document</code>. The
- function's <code>this</code> parameter must be the
- <code>Element</code> object representing the element. The resulting
- function must then be set as the value of the corresponding event
- handler attribute, and the new value must be set as the value of the
- content attribute. If the given function body fails to compile, then
- the corresponding event handler attribute must be set to null
- instead (the content attribute must still be updated to the new
- value, though).</p>
+ context</span>, the user agent must run the following steps to
+ create a <span title="concept-script">script</span> after setting
+ the content attribute to its new value:</p>
- <p class="note">See ECMA262 Edition 3, sections 10.1.6 and 10.2.3,
- for more details on activation objects. <a
- href="#refsECMA262">[ECMA262]</a></p>
+ <ol>
- <p>The <span>script execution context</span> of the event handler
- must be the <code>Window</code> object at the end of the scope
- chain. The <span>script document context</span> of the event handler
- must be the <code>Document</code> object that owns the event handler
- content attribute that was set.</p>
+ <li><p>Set up a <span>script execution environment</span> for
+ JavaScript.</p></li>
- <p>When an event handler content attribute is set on an element
- owned by a <code>Document</code> that is not in a <span>browsing
- context</span>, the corresponding event handler attribute is not
- changed.</p>
+ <li><p>Using this script execution environment, interpret the
+ attribute's new value as the body of an anonymous function with a
+ single argument called <code>event</code>. Link the new function's
+ scope chain from the activation object of the handler, to the
+ element's object, to the element's <span>form owner</span>, if it
+ has one, to the element's <code>Document</code> object, to the
+ <code>Window</code> object of the <span>browsing context</span> of
+ that <code>Document</code>. Set the function's <code>this</code>
+ parameter to the <code>Element</code> object representing the
+ element. Let this function be the only entry in the script's
+ <span>list of code entry-points</span>.</p>
+ <p class="note">See ECMA262 Edition 3, sections 10.1.6 and 10.2.3,
+ for more details on activation objects. <a
+ href="#refsECMA262">[ECMA262]</a></p></li>
+
+ <li><p>If the previous steps failed to compile the script, then set
+ the corresponding event handler attribute to null and abort these
+ steps.</p></li>
+
+ <li><p>Set up the <span>script's global object</span>, the
+ <span>script's browsing context</span>, the <span>script's
+ character encoding</span>, and the <span>script's base URL</span>
+ from <span>the script settings determined from the node</span> on
+ which the attribute is being set, and add the <span title="concept-script">script</span> to the
+ <span>script group</span> determined from that node as
+ well.</p></li>
+
+ <li><p>Set the corresponding event handler attribute to the
+ aforementioned function.</p></li>
+
+ </ol>
+
+ <p class="note">When an event handler content attribute is set on an
+ element owned by a <code>Document</code> that is not in a
+ <span>browsing context</span>, the corresponding event handler
+ attribute is not changed.</p>
+
<p class="note">Removing an event handler content attribute does not
- reset the corresponding event handler attribute either.</p>
+ reset the corresponding event handler attribute.</p>
<!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A...%3Cbody%20onload%3D%22w(%27pass%27)%22%3E%0A%3Cscript%3Edocument.body.removeAttribute(%27onload%27)%3B%3C%2Fscript%3E -->
<p class="XXX">How do we allow non-JS event handlers?</p>
+ <hr>
+
<p><dfn>Event handler DOM attributes</dfn>, on setting, must set the
corresponding event handler attribute to their new value, and on
getting, must return whatever the current value of the corresponding
@@ -38555,18 +38974,37 @@
<dd><p>Must be invoked whenever an <code
title="event-unload">unload</code> event is targeted at or bubbles
- through the element.</p></dd> <!-- XXX need to fire this -->
+ through the element.</p></dd>
</dl>
<p>When an event handler attribute is invoked, its argument must be
- set to the <code>Event</code> object of the event in question. If
- the function returns the exact boolean value false, the event's
- <code>preventDefault()</code> method must then invoked. Exception:
- for historical reasons, for the HTML <code>mouseover</code> event,
- the <code>preventDefault()</code> method must be called when the
- function returns true instead.</p>
+ set to the <code>Event</code> object of the event in question.</p>
+ <p>The handler's return value must be processed as follows:</p>
+
+ <dl class="switch">
+
+ <dt>If the event type is <code class="event-mouseover">mouseover</code></dt>
+
+ <dd><p>If the return value is a boolean with the value true, then
+ the event must be canceled.</p></dd>
+
+ <dt>If the event object is a <code>BeforeUnloadEvent</code> object</dt>
+
+ <dd><p>If the return value is a string, and the event object's
+ <code title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
+ attribute's value is the empty string, then set the <code
+ title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
+ attribute's value to the return value.</p></dd>
+
+ <dt>Otherwise</dt>
+
+ <dd><p>If the return value is a boolean with the value false, then
+ the event must be canceled.</p></dd>
+
+ </dl>
+
<!-- IE actually uncancels the event if the function returns true -->
<p>All event handler attributes on an element, whether set to null
@@ -38920,7 +39358,7 @@
<li>have an <span>active document</span> whose
<span>origin</span> is the <span title="same origin">same</span>
- as the <span>origin</span> of the script that called the <code
+ as the <span>origin</span> of the <span title="concept-script">script</span> that called the <code
title="dom-showModalDialog">showModalDialog()</code> method at
the time the method was called,</li> <!-- Note that changing
document.domain to talk to another domain doesn't make you able
@@ -38969,7 +39407,7 @@
<li>
<p>Let the <span>dialog arguments' origin</span> be the
- <span>origin</span> of the script that called the <code
+ <span>origin</span> of the <span title="concept-script">script</span> that called the <code
title="dom-showModalDialog">showModalDialog()</code> method.</p>
</li>
@@ -38978,9 +39416,9 @@
<p><span>Navigate</span> the new browsing context to <var
title="">url</var>, with <span>replacement enabled</span>, and
- with the <span>script browsing context</span> of the script that
- invoked the method as the <span>source browsing
- context</span>.</p>
+ with the <span title="script's browsing context">browsing
+ context</span> of the <span title="concept-script">script</span> that invoked the method as the
+ <span>source browsing context</span>.</p>
</li>
@@ -39089,18 +39527,19 @@
title="">onclick</var>)</code></dfn> method, when invoked, must
cause the user agent to show a notification.</p>
- <p id="sandboxNotifications">If the method was invoked from a script
- whose <span>script browsing context</span> has the <span>sandboxed
- annoyances browsing context flag</span> set, then the notification
- must be shown within that <span>browsing context</span>. The
- notification is said to be a <dfn>sandboxed notification</dfn>.</p>
+ <p id="sandboxNotifications">If the method was invoked from a <span title="concept-script">script</span>
+ whose <span title="script's browsing context">browsing
+ context</span> has the <span>sandboxed annoyances browsing context
+ flag</span> set, then the notification must be shown within that
+ <span>browsing context</span>. The notification is said to be a
+ <dfn>sandboxed notification</dfn>.</p>
- <p>Otherwise, if the <span>origin</span> of the <span>script
- browsing context</span> of the script that invoked the method is
- <em>not</em> flagged as being a <span>trusted notification
- source</span>, then the notification should be rendered within the
- <span>top-level browsing context</span> of the <span>script browsing
- context</span> of the script that invoked the method. The
+ <p>Otherwise, if the <span>origin</span> of the <span
+ title="script's browsing context">browsing context</span> of the
+ <span title="concept-script">script</span> that invoked the method is <em>not</em> flagged as being a
+ <span>trusted notification source</span>, then the notification
+ should be rendered within the <span>top-level browsing
+ context</span> of the <span>script's browsing context</span>. The
notification is said to be a <dfn>normal notification</dfn>. User
agents should provide a way to set the origin's <span>trusted
notification source</span> flag from the notification, so that the
@@ -39149,16 +39588,16 @@
<p>When a <span>normal notification</span> (but not a
<span>sandboxed notification</span>) is shown, the user agent may
bring the user's attention to the <span>top-level browsing
- context</span> of the <span>script browsing context</span> of the
- script that invoked the method, if that would be useful; but user
- agents should not use system-wide notification mechanisms to do
- so.</p>
+ context</span> of the <span title="script's browsing
+ context">browsing context</span> of the <span title="concept-script">script</span> that invoked the
+ method, if that would be useful; but user agents should not use
+ system-wide notification mechanisms to do so.</p>
<p>When a <span>trusted notification</span> is shown, the user agent
- should bring the user's attention to the notification and the
- <span>script browsing context</span> of the script that invoked the
- method, as per the platform conventions for attracting the user's
- attention to applications.</p>
+ should bring the user's attention to the notification and the <span
+ title="script's browsing context">browsing context</span> of the
+ <span title="concept-script">script</span> that invoked the method, as per the platform conventions for
+ attracting the user's attention to applications.</p>
<div class="example">
@@ -39185,8 +39624,9 @@
<li>The <span title="meta-application-name">application
name</span>, if available, or else the <span
title="dom-document-title">document title</span>, of the
- <span>active document</span> of the <span>script browsing
- context</span> of the script that invoked the method.</li>
+ <span>active document</span> of the <span title="script's browsing
+ context">browsing context</span> of the <span title="concept-script">script</span> that invoked the
+ method.</li>
<li>An icon chosen from the <span title="external resource
link">external resource links</span> of type <code
@@ -39229,11 +39669,12 @@
<p>User agents should support user interaction with notifications,
if and as appropriate given the platform conventions. If a user
activates a notification, and the <var title="">onclick</var>
- callback argument was present and is not null, then the <span>script
- browsing context</span> of the function given by <var
- title="">onclick</var> should be brought to the user's attention,
- and the <var title="">onclick</var> callback should then be
- invoked.</p>
+ callback argument was present and is not null, then the <span
+ title="script's browsing context">browsing context</span> of the
+ <span title="concept-script">script</span> of the function given by
+ <var title="">onclick</var> should be brought to the user's
+ attention, and the <var title="">onclick</var> callback should then
+ be invoked.</p>
@@ -39425,9 +39866,8 @@
first occurrence of the exact literal string "<code>%s</code>"
with an escaped version of the URL of the content in question (as
defined below), then <span title="resolve a url">resolve</span>
- the resulting URL (using the <span>document base URL</span> of the
- <span>script document context</span> of the script that originally
- invoked the <code
+ the resulting URL (using the <span title="script's base URL">base
+ URL</span> of the script that originally invoked the <code
title="dom-navigator-registerContentHandler">registerContentHandler()</code>
or <code
title="dom-navigator-registerProtocolHandler">registerProtocolHandler()</code>
@@ -41839,8 +42279,9 @@
<p>Navigation for the <code
title="dom-location-assign">assign()</code> and <code
title="dom-location-replace">replace()</code> methods must be done
- with the <span>script browsing context</span> of the script that
- invoked the method as the <span>source browsing context</span>.</p>
+ with the <span title="script's browsing context">browsing
+ context</span> of the script that invoked the method as the
+ <span>source browsing context</span>.</p>
<!--XXX
<dfn title="dom-location-reload"><code>reload()</code></dfn>
@@ -42090,7 +42531,7 @@
synchronous, but if fetching the resource depends on external
resources, as it usually does for URLs that use HTTP or other
networking protocols, then at this point the user agents must
- yield to whatever script invoked the navigation steps, if they
+ yield to whatever <span title="concept-script">script</span> invoked the navigation steps, if they
were invoked by script.</p>
</li>
@@ -42279,19 +42720,11 @@
<li><p class="XXX">pause for scripts -- but don't use the
"pause" definition since that involves not running script!</p></li>
- <li><p class="XXX">onbeforeunload, and if present set flag that we will kill document</p></li>
- <!--
- when we define onbeforeunload, then we have to say that the JS
- implementation of EventListener::handleEvent checks for that event,
- treating the return value as the string to use for the unload warning
- message if there is a return value, and calling preventDefault if
- there isn't.
- -->
+ <li><p><span title="unload a document">Unload</span> the
+ <code>Document</code> object of the <span>current entry</span>,
+ with the <var title="">recycle</var> parameter set to
+ false.</p></li>
- <li><p class="XXX">onunload, and if present set flag that we will kill document</p></li>
-
- <li><p class="XXX">if flag is set: <span title="discard a document">discard the <code>Document</code></span></p></li>
-
<li>
<dl>
@@ -42692,8 +43125,8 @@
<ol>
- <li class="XXX">freeze any timers, intervals,
- XMLHttpRequests, database transactions, etc</li>
+ <li>Freeze the <span>active document</span>'s <span>current
+ script group</span>.</li>
<li>The user agent must move any properties that have been added
to the browsing context's default view's <code>Window</code>
@@ -42756,8 +43189,8 @@
<span>list of added properties</span> to browsing context's
default view's <code>Window</code> object.</li>
- <li class="XXX">unfreeze any timers, intervals,
- XMLHttpRequests, database transactions, etc</li>
+ <li>Unfreeze the <span>active document</span>'s <span>current
+ script group</span>.</li>
</ol>
@@ -42801,27 +43234,94 @@
affect .watch() when seen from other Windows?</p>
- <h4>Closing a browsing context</h4>
- <p class="XXX">Closing a browsing context and discarding it
- (vs closing it and keeping it around in memory).</p>
+ <h4>Unloading documents</h4>
- <p class="XXX">when a browsing context is closed, all session
- history entries' <code>Document</code> objects must be
- discarded.</p>
+ <p>When a user agent is to <dfn>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
+ re-used. (This is set by the <code
+ title="dom-document-open">document.open()</code> method.)</p>
- <p class="XXX">When a user agent is to <dfn>discard a
- <code>Document</code></dfn>, any frozen timers, intervals,
- XMLHttpRequests, database transactions, etc, must be killed, and any
- MessagePorts owned by the Window object must be
- unentangled.</p>
+ <ol>
- <p class="XXX">Also, <code title="event-unload">unload</code>
- events should fire.</p>
+ <li><p>Set <var title="">salvageable</var> to true.</p></li>
+ <li><p>Let <var title="">event</var> be a new
+ <code>BeforeUnloadEvent</code> event object with the name <code
+ title="event-beforeunload">beforeunload</code>, with no namespace,
+ which does not bubble but is cancelable.</p></li>
+ <li><p>Dispatch <var title="">event</var> at <span>the
+ <code>body</code> element</span>.</p></li>
+ <li><p>If any event listeners were triggered by the previous step,
+ then set <var title="">salvageable</var> to false.</p></li>
+ <li>
+
+ <p>If the <code
+ title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
+ attribute of the <var title="">event</var> object is not the empty
+ string, or if the event was canceled, then the user agent should
+ ask the user to confirm that they wish to unload the document.</p>
+
+ <p>The prompt shown by the user agent may include the string of
+ the <code
+ title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
+ attribute, or some leading subset thereof. (A user agent may want
+ to truncate the string to 1024 characters for display, for
+ instance.)</p>
+
+ <p>The user agent must <span>pause</span> while waiting for the
+ user's response.</p>
+
+ <p>If the user <dfn>refused to allow the document to be
+ unloaded</dfn> then these steps must be aborted.</p>
+
+ </li>
+
+ <li><p><span>Fire a simple event</span> called <code
+ title="event-unload">unload</code> at <span>the <code>body</code>
+ element</span>.</p></li>
+
+ <li><p>If any event listeners were triggered by the previous step,
+ then set <var title="">salvageable</var> to false.</p></li>
+
+ <li><p>If there are any outstanding transactions that have
+ callbacks that involve <span title="concept-script">scripts</span>
+ that are in the document's <span>current script group</span>, roll
+ them back (without invoking any of the callbacks) and set <var
+ title="">salvageable</var> to false.</p>
+
+ <li><p>If <var title="">salvageable</var> and <var
+ title="">recycle</var> are both false, <span title="discard a
+ document">discard the <code>Document</code></span>.</p></li>
+
+ </ol>
+
+
+
+ <h5>Event definition</h5>
+
+ <pre class="idl">interface <dfn>BeforeUnloadEvent</dfn> : Event {
+ attribute DOMString <span title="dom-BeforeUnloadEvent-returnValue">returnValue</span>;
+};</pre>
+
+ <p class="note">There are no <code>BeforeUnloadEvent</code>-specific
+ initialization methods.</p>
+
+ <p>The <dfn
+ title="dom-BeforeUnloadEvent-returnValue"><code>returnValue</code></dfn>
+ attribute represents the message to show the user. When the event is
+ created, the attribute must be set to the empty string. On getting,
+ it must return the last value it was set to. On setting, the
+ attribute must be set to the new value.</p>
+
+
+
+
<h3>Structured client-side storage</h3>
<h4 id="storage">Storing name/value pairs</h4>
@@ -43080,14 +43580,14 @@
separate, not affecting each other in any way.</p>
<p>When a new <span>top-level browsing context</span> is created by
- a script in an existing <span>browsing context</span>, or by the
- user following a link in an existing browsing context, or in some
- other way related to a specific <code>HTMLDocument</code>, then the
- session storage area of the <span>origin</span> of that
- <code>HTMLDocument</code> must be copied into the new browsing
- context when it is created. From that point on, however, the two
- session storage areas must be considered separate, not affecting
- each other in any way.</p>
+ a <span title="concept-script">script</span> in an existing
+ <span>browsing context</span>, or by the user following a link in an
+ existing browsing context, or in some other way related to a
+ specific <code>HTMLDocument</code>, then the session storage area of
+ the <span>origin</span> of that <code>HTMLDocument</code> must be
+ copied into the new browsing context when it is created. From that
+ point on, however, the two session storage areas must be considered
+ separate, not affecting each other in any way.</p>
<p id="sessionStorageEvent">When the <code
title="dom-Storage-setItem">setItem()</code>, <code
@@ -50206,11 +50706,11 @@
<ol>
<li><p><span>Create a new <code>MessagePort</code> object</span>
- owned by the <span>script execution context</span>, and let <var
+ owned by the <span>script's global object</span>, and let <var
title="">port1</var> be that object.</p></li>
<li><p><span>Create a new <code>MessagePort</code> object</span>
- owned by the <span>script execution context</span>, and let <var
+ owned by the <span>script's global object</span>, and let <var
title="">port2</var> be that object.</p></li>
<li><p><span>Entangle</span> the <var title="">port1</var> and <var
@@ -50265,8 +50765,8 @@
initially closed.</p>
<p>When the user agent is to <dfn>create a new
- <code>MessagePort</code> object</dfn> owned by a <span>script
- execution context</span> object <var title="">owner</var>, it must
+ <code>MessagePort</code> object</dfn> owned by a <span>script's
+ global object</span> object <var title="">owner</var>, it must
instantiate a new <code>MessagePort</code> object, and let its owner
be <var title="">owner</var>.</p>
@@ -50428,7 +50928,7 @@
argument.</p></li>
<li><p><span>Create a new <code>MessagePort</code> object</span>
- owned by the <span>script execution context</span>, and let <var
+ owned by the <span>script's global object</span>, and let <var
title="">port1</var> be that object.</p></li>
<li><p>If the <var title="">source port</var> is not entangled with
@@ -50567,7 +51067,7 @@
- <h5>Ports and browsing contexts</h5>
+ <h5 id="message-port-discarding">Ports and browsing contexts</h5>
<p>When a <code>Document</code> is <span title="discard a
document">discarded</span>, if there are any
@@ -50577,7 +51077,7 @@
<li>are entangled, and</li>
<li>are owned by the <span>browsing context</span> that contained that <code>Document</code>, and</li>
<li>were created while that <code>Document</code> was the <span>active document</span> of that <span>browsing context</span>, and</li>
- <li>are entangled with a port that is either not owned by that <span>browsing context</span> or was not created while that <code>Document</code> was the <span>active document</span> of that <span>browsing context</span>,</li>
+ <li>are entangled with a port that is either not owned by that <span>browsing context</span>, or were not created while that <code>Document</code> was the <span>active document</span> of that <span>browsing context</span>,</li>
</ul>
<p>...then the user agent must run the following steps for each such
@@ -52714,10 +53214,10 @@
<h5>The scripting state</h5>
- <p>The <dfn>scripting flag</dfn> is set to "enabled" if the
- <code>Document</code> with which the parser is associated was
- <span>with script</span> when the parser was created, and "disabled"
- otherwise.</p>
+ <p>The <dfn>scripting flag</dfn> is set to "enabled" if the <span
+ title="concept-n-script">scripting was enabled</span> for the
+ <code>Document</code> with which the parser is associated when the
+ parser was created, and "disabled" otherwise.</p>
<h4><dfn>Tokenization</dfn></h4>
@@ -58963,8 +59463,11 @@
<code>Window</code> object on which the <code
title="setTimeout">setTimeout()</code> method was invoked.</p>
- <p class="XXX">Need to define <var title="">language</var>
- values.</p>
+ <p class="XXX">Need to define <var title="">language</var> values;
+ need to define that the <span title="concept-script">script</span>
+ corresponding to the <var title="">code</var> argument is created
+ before the timer is set up, so that the rule on pausing the ticker,
+ below, makes sense.</p>
<p>The <dfn
title="dom-windowtimers-setInterval"><code>setInterval(...)</code></dfn>
@@ -58988,8 +59491,15 @@
with a value that does not correspond to an active timeout or
interval, the methods must return without doing anything.</p>
+ <p>For both <code
+ title="dom-windowtimers-setTimeout">setTimeout()</code> and <code
+ title="dom-windowtimers-setInterval">setInterval()</code>, the clock
+ upon which the timers are based must only tick while the
+ <span>script group</span> of their callbacks is not
+ <i>frozen</i>.</p>
+
<h3>Rendering and the DOM</h3>
<p class="XXX">This section is expected to be moved to its own