[html5] r6619 - [e] (0) Shake up the publication pipeline a bit. Merge the main two WHATWG specs [...]
whatwg at whatwg.org
whatwg at whatwg.org
Tue Oct 4 09:57:59 PDT 2011
Author: ianh
Date: 2011-10-04 09:57:57 -0700 (Tue, 04 Oct 2011)
New Revision: 6619
Modified:
index
source
Log:
[e] (0) Shake up the publication pipeline a bit. Merge the main two WHATWG specs. Update styles.
Modified: index
===================================================================
--- index 2011-10-04 15:43:21 UTC (rev 6618)
+++ index 2011-10-04 16:57:57 UTC (rev 6619)
@@ -213,9 +213,7 @@
src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
}
- </style><style>
- .domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
- </style><link href=data:text/css, id=complete rel=stylesheet title="Complete specification"><link href=data:text/css,.impl%20{%20display:%20none;%20}%0Ahtml%20{%20border:%20solid%20yellow;%20}%20.domintro:before%20{%20display:%20none;%20} id=author rel="alternate stylesheet" title="Author documentation only"><link href=data:text/css,.impl%20{%20background:%20%23FFEEEE;%20}%20.domintro:before%20{%20background:%20%23FFEEEE;%20} id=highlight rel="alternate stylesheet" title="Highlight implementation requirements"><link href=status.css rel=stylesheet><script>
+ </style><link href=status.css rel=stylesheet><script>
var startedInit = 0;
function init() {
startedInit = 1;
@@ -227,7 +225,6 @@
load('reviewer.js');
if (document.documentElement.className == "" || document.documentElement.className == "split index")
load('toc.js');
- load('styler.js');
load('updater.js');
load('dfn.js');
load('status.js');
@@ -239,20 +236,17 @@
if (!startedInit)
showAlert("Too slow? Try reading the multipage copy of the spec instead:", "http://whatwg.org/html");
}, 6000);
- </script><body class=draft onload=init()>
+ </script><body onload=init()>
<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
- <h2 class="no-num no-toc">Living Standard — Last Updated 2 October 2011</h2>
+ <h2 class="no-num no-toc">Living Standard — Last Updated 4 October 2011</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
- <dd><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/>http://whatwg.org/html</a></dd>
+ <dd><a href=http://www.whatwg.org/specs/web-apps/current-work/multipage/>http://www.whatwg.org/html</a></dd>
<dt>One-page version:</dt>
- <dd><a href=http://www.whatwg.org/specs/web-apps/current-work/>http://www.whatwg.org/specs/web-apps/current-work/</a></dd>
- <dt>PDF print versions:</dt>
- <dd>A4: <a href=http://www.whatwg.org/specs/web-apps/current-work/html-a4.pdf>http://www.whatwg.org/specs/web-apps/current-work/html-a4.pdf</a></dd>
- <dd>Letter: <a href=http://www.whatwg.org/specs/web-apps/current-work/html-letter.pdf>http://www.whatwg.org/specs/web-apps/current-work/html-letter.pdf</a></dd>
+ <dd><a href=http://www.whatwg.org/specs/web-apps/current-work/>http://whatwg.org/c</a></dd>
<dt>Participate:</dt>
<dd><a href=http://www.whatwg.org/mailing-list>whatwg at whatwg.org</a></dd>
<dd><a href=http://forums.whatwg.org/>http://forums.whatwg.org/</a></dd>
@@ -260,12 +254,12 @@
<dt>FAQ:</dt>
<dd><a href=http://wiki.whatwg.org/wiki/FAQ>http://wiki.whatwg.org/wiki/FAQ</a></dd>
<dt>Version history:</dt>
- <dd>Twitter messages (non-editorial changes only): <a href=http://twitter.com/WHATWG>http://twitter.com/WHATWG</a></dd>
+ <dd>Twitter updates: <a href=http://twitter.com/WHATWG>http://twitter.com/WHATWG</a></dd>
<dd>Commit-Watchers mailing list: <a href=http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org>http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a></dd>
<dd>Interactive Web interface: <a href=http://html5.org/tools/web-apps-tracker>http://html5.org/tools/web-apps-tracker</a></dd>
<dd>Subversion interface: <a href=http://svn.whatwg.org/>http://svn.whatwg.org/</a></dd>
<dt>Issues:</dt>
- <dd>To view the open bugs: <a href="http://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=HTML+WG&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=exact&email1=ian%40hixie.ch&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=">HTML bug list</a></dd>
+ <dd>To view the open bugs: <a href="http://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=exact&email1=ian%40hixie.ch&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=">HTML bug list</a></dd>
<dd>To file bugs, use the "submit review comments" feature at the bottom of the window</dd>
<dd>To send feedback by e-mail: <a href=http://www.whatwg.org/mailing-list>whatwg at whatwg.org</a></dd>
<dd>To view and vote on e-mail feedback: <a href=http://www.whatwg.org/issues/>http://www.whatwg.org/issues/</a></dd>
@@ -275,8 +269,18 @@
Mozilla Foundation, and Opera Software ASA.</p>
<p class=copyright>You are granted a license to use, reproduce
and create derivative works of this document.</p>
+ </header><hr><h2 class="no-num no-toc" id=abstract>Abstract</h2>
- </header><hr><h2 class="no-num no-toc" id=contents>Table of contents</h2>
+ <p>This specification defines a big part of the Web platform, in
+ lots of detail. Its place in the Web platform specification stack
+ relative to other specifications can be best summed up as
+ follows:</p>
+
+ <p><img alt="It consists of everything else, above such core technologies as HTTP, URI/IRIs, DOM Core, XML, Unicode, and ECMAScript; below presentation-layer technologies like CSS, XBL, and the NPAPI; and to the side of technologies like Geolocation, SVG, MathML, and XHR." height=359 src=http://images.whatwg.org/abstract.png width=398></p>
+
+
+
+ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--begin-toc-->
<ol class=toc>
@@ -1008,272 +1012,358 @@
<li><a href=#garbage-collection-0><span class=secno>9.6 </span>Garbage collection</a></li>
<li><a href=#event-definitions-1><span class=secno>9.7 </span>Event definitions</a></li>
<li><a href=#mediastreamevents><span class=secno>9.8 </span>Event Summary</a></ol></li>
- <li><a href=#comms><span class=secno>10 </span>Communication</a>
+ <li><a href=#workers><span class=secno>10 </span>Web workers</a>
<ol>
- <li><a href=#event-definitions-2><span class=secno>10.1 </span>Event definitions</a></li>
- <li><a href=#web-messaging><span class=secno>10.2 </span>Cross-document messaging</a>
+ <li><a href=#introduction-13><span class=secno>10.1 </span>Introduction</a>
<ol>
- <li><a href=#introduction-13><span class=secno>10.2.1 </span>Introduction</a></li>
- <li><a href=#security-postmsg><span class=secno>10.2.2 </span>Security</a>
+ <li><a href=#scope-0><span class=secno>10.1.1 </span>Scope</a></li>
+ <li><a href=#examples-4><span class=secno>10.1.2 </span>Examples</a>
<ol>
- <li><a href=#authors><span class=secno>10.2.2.1 </span>Authors</a></li>
- <li><a href=#user-agents><span class=secno>10.2.2.2 </span>User agents</a></ol></li>
- <li><a href=#posting-messages><span class=secno>10.2.3 </span>Posting messages</a></ol></li>
- <li><a href=#channel-messaging><span class=secno>10.3 </span>Channel messaging</a>
+ <li><a href=#a-background-number-crunching-worker><span class=secno>10.1.2.1 </span>A background number-crunching worker</a></li>
+ <li><a href=#a-worker-for-updating-a-client-side-database><span class=secno>10.1.2.2 </span>A worker for updating a client-side database</a></li>
+ <li><a href=#worker-used-for-background-i/o><span class=secno>10.1.2.3 </span>Worker used for background I/O</a></li>
+ <li><a href=#shared-workers-introduction><span class=secno>10.1.2.4 </span>Shared workers introduction</a></li>
+ <li><a href=#shared-state-using-a-shared-worker><span class=secno>10.1.2.5 </span>Shared state using a shared worker</a></li>
+ <li><a href=#delegation><span class=secno>10.1.2.6 </span>Delegation</a></ol></li>
+ <li><a href=#tutorials><span class=secno>10.1.3 </span>Tutorials</a>
+ <ol>
+ <li><a href=#creating-a-dedicated-worker><span class=secno>10.1.3.1 </span>Creating a dedicated worker</a></li>
+ <li><a href=#communicating-with-a-dedicated-worker><span class=secno>10.1.3.2 </span>Communicating with a dedicated worker</a></li>
+ <li><a href=#shared-workers><span class=secno>10.1.3.3 </span>Shared workers</a></ol></ol></li>
+ <li><a href=#infrastructure-0><span class=secno>10.2 </span>Infrastructure</a>
<ol>
- <li><a href=#introduction-14><span class=secno>10.3.1 </span>Introduction</a></li>
- <li><a href=#message-channels><span class=secno>10.3.2 </span>Message channels</a></li>
- <li><a href=#message-ports><span class=secno>10.3.3 </span>Message ports</a>
+ <li><a href=#the-global-scope><span class=secno>10.2.1 </span>The global scope</a>
<ol>
- <li><a href=#ports-and-garbage-collection><span class=secno>10.3.3.1 </span>Ports and garbage collection</a></ol></ol></ol></li>
- <li><a href=#syntax><span class=secno>11 </span>The HTML syntax</a>
+ <li><a href=#the-workerglobalscope-abstract-interface><span class=secno>10.2.1.1 </span>The <code>WorkerGlobalScope</code> abstract interface</a></li>
+ <li><a href=#dedicated-workers-and-the-dedicatedworkerglobalscope-interface><span class=secno>10.2.1.2 </span>Dedicated workers and the <code>DedicatedWorkerGlobalScope</code> interface</a></li>
+ <li><a href=#shared-workers-and-the-sharedworkerglobalscope-interface><span class=secno>10.2.1.3 </span>Shared workers and the <code>SharedWorkerGlobalScope</code> interface</a></ol></li>
+ <li><a href=#origins-of-workers><span class=secno>10.2.2 </span>Origins of workers</a></li>
+ <li><a href=#the-event-loop><span class=secno>10.2.3 </span>The event loop</a></li>
+ <li><a href="#the-worker's-lifetime"><span class=secno>10.2.4 </span>The worker's lifetime</a></li>
+ <li><a href=#processing-model-4><span class=secno>10.2.5 </span>Processing model</a></li>
+ <li><a href=#runtime-script-errors-0><span class=secno>10.2.6 </span>Runtime script errors</a></li>
+ <li><a href=#creating-workers><span class=secno>10.2.7 </span>Creating workers</a>
+ <ol>
+ <li><a href=#the-abstractworker-abstract-interface><span class=secno>10.2.7.1 </span>The <code>AbstractWorker</code> abstract interface</a></li>
+ <li><a href=#dedicated-workers-and-the-worker-interface><span class=secno>10.2.7.2 </span>Dedicated workers and the <code>Worker</code> interface</a></li>
+ <li><a href=#shared-workers-and-the-sharedworker-interface><span class=secno>10.2.7.3 </span>Shared workers and the <code>SharedWorker</code> interface</a></ol></ol></li>
+ <li><a href=#apis-available-to-workers><span class=secno>10.3 </span>APIs available to workers</a>
+ <ol>
+ <li><a href=#importing-scripts-and-libraries><span class=secno>10.3.1 </span>Importing scripts and libraries</a></li>
+ <li><a href=#the-workernavigator-object><span class=secno>10.3.2 </span>The <code>WorkerNavigator</code> object</a></li>
+ <li><a href=#interface-objects-and-constructors><span class=secno>10.3.3 </span>Interface objects and constructors</a></li>
+ <li><a href=#worker-locations><span class=secno>10.3.4 </span>Worker locations</a></ol></ol></li>
+ <li><a href=#comms><span class=secno>11 </span>Communication</a>
<ol>
- <li><a href=#writing><span class=secno>11.1 </span>Writing HTML documents</a>
+ <li><a href=#event-definitions-2><span class=secno>11.1 </span>Event definitions</a></li>
+ <li><a href=#server-sent-events><span class=secno>11.2 </span>Server-sent events</a>
<ol>
- <li><a href=#the-doctype><span class=secno>11.1.1 </span>The DOCTYPE</a></li>
- <li><a href=#elements-0><span class=secno>11.1.2 </span>Elements</a>
+ <li><a href=#server-sent-events-intro><span class=secno>11.2.1 </span>Introduction</a></li>
+ <li><a href=#the-eventsource-interface><span class=secno>11.2.2 </span>The <code>EventSource</code> interface</a></li>
+ <li><a href=#processing-model-5><span class=secno>11.2.3 </span>Processing model</a></li>
+ <li><a href=#parsing-an-event-stream><span class=secno>11.2.4 </span>Parsing an event stream</a></li>
+ <li><a href=#event-stream-interpretation><span class=secno>11.2.5 </span>Interpreting an event stream</a></li>
+ <li><a href=#notes><span class=secno>11.2.6 </span>Notes</a></li>
+ <li><a href=#eventsource-push><span class=secno>11.2.7 </span>Connectionless push and other features</a></li>
+ <li><a href=#garbage-collection-1><span class=secno>11.2.8 </span>Garbage collection</a></li>
+ <li><a href=#iana-considerations><span class=secno>11.2.9 </span>IANA considerations</a>
<ol>
- <li><a href=#start-tags><span class=secno>11.1.2.1 </span>Start tags</a></li>
- <li><a href=#end-tags><span class=secno>11.1.2.2 </span>End tags</a></li>
- <li><a href=#attributes-0><span class=secno>11.1.2.3 </span>Attributes</a></li>
- <li><a href=#optional-tags><span class=secno>11.1.2.4 </span>Optional tags</a></li>
- <li><a href=#element-restrictions><span class=secno>11.1.2.5 </span>Restrictions on content models</a></li>
- <li><a href=#cdata-rcdata-restrictions><span class=secno>11.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</a></ol></li>
- <li><a href=#text-1><span class=secno>11.1.3 </span>Text</a>
+ <li><a href=#text/event-stream><span class=secno>11.2.9.1 </span><code>text/event-stream</code></a></li>
+ <li><a href=#last-event-id><span class=secno>11.2.9.2 </span><code>Last-Event-ID</code></a></ol></ol></li>
+ <li><a href=#network><span class=secno>11.3 </span>Web sockets</a>
+ <ol>
+ <li><a href=#network-intro><span class=secno>11.3.1 </span>Introduction</a></li>
+ <li><a href=#the-websocket-interface><span class=secno>11.3.2 </span>The <code>WebSocket</code> interface</a></li>
+ <li><a href=#feedback-from-the-protocol><span class=secno>11.3.3 </span>Feedback from the protocol</a>
<ol>
- <li><a href=#newlines><span class=secno>11.1.3.1 </span>Newlines</a></ol></li>
- <li><a href=#character-references><span class=secno>11.1.4 </span>Character references</a></li>
- <li><a href=#cdata-sections><span class=secno>11.1.5 </span>CDATA sections</a></li>
- <li><a href=#comments><span class=secno>11.1.6 </span>Comments</a></ol></li>
- <li><a href=#parsing><span class=secno>11.2 </span>Parsing HTML documents</a>
+ <li><a href=#event-definitions-3><span class=secno>11.3.3.1 </span>Event definitions</a></li>
+ <li><a href=#garbage-collection-2><span class=secno>11.3.3.2 </span>Garbage collection</a></ol></ol></li>
+ <li><a href=#web-messaging><span class=secno>11.4 </span>Cross-document messaging</a>
<ol>
- <li><a href=#overview-of-the-parsing-model><span class=secno>11.2.1 </span>Overview of the parsing model</a></li>
- <li><a href=#the-input-stream><span class=secno>11.2.2 </span>The input stream</a>
+ <li><a href=#introduction-14><span class=secno>11.4.1 </span>Introduction</a></li>
+ <li><a href=#security-postmsg><span class=secno>11.4.2 </span>Security</a>
<ol>
- <li><a href=#determining-the-character-encoding><span class=secno>11.2.2.1 </span>Determining the character encoding</a></li>
- <li><a href=#character-encodings-0><span class=secno>11.2.2.2 </span>Character encodings</a></li>
- <li><a href=#preprocessing-the-input-stream><span class=secno>11.2.2.3 </span>Preprocessing the input stream</a></li>
- <li><a href=#changing-the-encoding-while-parsing><span class=secno>11.2.2.4 </span>Changing the encoding while parsing</a></ol></li>
- <li><a href=#parse-state><span class=secno>11.2.3 </span>Parse state</a>
+ <li><a href=#authors><span class=secno>11.4.2.1 </span>Authors</a></li>
+ <li><a href=#user-agents><span class=secno>11.4.2.2 </span>User agents</a></ol></li>
+ <li><a href=#posting-messages><span class=secno>11.4.3 </span>Posting messages</a></ol></li>
+ <li><a href=#channel-messaging><span class=secno>11.5 </span>Channel messaging</a>
+ <ol>
+ <li><a href=#introduction-15><span class=secno>11.5.1 </span>Introduction</a></li>
+ <li><a href=#message-channels><span class=secno>11.5.2 </span>Message channels</a></li>
+ <li><a href=#message-ports><span class=secno>11.5.3 </span>Message ports</a>
<ol>
- <li><a href=#the-insertion-mode><span class=secno>11.2.3.1 </span>The insertion mode</a></li>
- <li><a href=#the-stack-of-open-elements><span class=secno>11.2.3.2 </span>The stack of open elements</a></li>
- <li><a href=#the-list-of-active-formatting-elements><span class=secno>11.2.3.3 </span>The list of active formatting elements</a></li>
- <li><a href=#the-element-pointers><span class=secno>11.2.3.4 </span>The element pointers</a></li>
- <li><a href=#other-parsing-state-flags><span class=secno>11.2.3.5 </span>Other parsing state flags</a></ol></li>
- <li><a href=#tokenization><span class=secno>11.2.4 </span>Tokenization</a>
+ <li><a href=#ports-and-garbage-collection><span class=secno>11.5.3.1 </span>Ports and garbage collection</a></ol></ol></ol></li>
+ <li><a href=#webstorage><span class=secno>12 </span>Web storage</a>
+ <ol>
+ <li><a href=#introduction-16><span class=secno>12.1 </span>Introduction</a></li>
+ <li><a href=#storage><span class=secno>12.2 </span>The API</a>
+ <ol>
+ <li><a href=#the-storage-interface><span class=secno>12.2.1 </span>The <code>Storage</code> interface</a></li>
+ <li><a href=#the-sessionstorage-attribute><span class=secno>12.2.2 </span>The <code title=dom-sessionStorage>sessionStorage</code> attribute</a></li>
+ <li><a href=#the-localstorage-attribute><span class=secno>12.2.3 </span>The <code title=dom-localStorage>localStorage</code> attribute</a>
<ol>
- <li><a href=#data-state><span class=secno>11.2.4.1 </span>Data state</a></li>
- <li><a href=#character-reference-in-data-state><span class=secno>11.2.4.2 </span>Character reference in data state</a></li>
- <li><a href=#rcdata-state><span class=secno>11.2.4.3 </span>RCDATA state</a></li>
- <li><a href=#character-reference-in-rcdata-state><span class=secno>11.2.4.4 </span>Character reference in RCDATA state</a></li>
- <li><a href=#rawtext-state><span class=secno>11.2.4.5 </span>RAWTEXT state</a></li>
- <li><a href=#script-data-state><span class=secno>11.2.4.6 </span>Script data state</a></li>
- <li><a href=#plaintext-state><span class=secno>11.2.4.7 </span>PLAINTEXT state</a></li>
- <li><a href=#tag-open-state><span class=secno>11.2.4.8 </span>Tag open state</a></li>
- <li><a href=#end-tag-open-state><span class=secno>11.2.4.9 </span>End tag open state</a></li>
- <li><a href=#tag-name-state><span class=secno>11.2.4.10 </span>Tag name state</a></li>
- <li><a href=#rcdata-less-than-sign-state><span class=secno>11.2.4.11 </span>RCDATA less-than sign state</a></li>
- <li><a href=#rcdata-end-tag-open-state><span class=secno>11.2.4.12 </span>RCDATA end tag open state</a></li>
- <li><a href=#rcdata-end-tag-name-state><span class=secno>11.2.4.13 </span>RCDATA end tag name state</a></li>
- <li><a href=#rawtext-less-than-sign-state><span class=secno>11.2.4.14 </span>RAWTEXT less-than sign state</a></li>
- <li><a href=#rawtext-end-tag-open-state><span class=secno>11.2.4.15 </span>RAWTEXT end tag open state</a></li>
- <li><a href=#rawtext-end-tag-name-state><span class=secno>11.2.4.16 </span>RAWTEXT end tag name state</a></li>
- <li><a href=#script-data-less-than-sign-state><span class=secno>11.2.4.17 </span>Script data less-than sign state</a></li>
- <li><a href=#script-data-end-tag-open-state><span class=secno>11.2.4.18 </span>Script data end tag open state</a></li>
- <li><a href=#script-data-end-tag-name-state><span class=secno>11.2.4.19 </span>Script data end tag name state</a></li>
- <li><a href=#script-data-escape-start-state><span class=secno>11.2.4.20 </span>Script data escape start state</a></li>
- <li><a href=#script-data-escape-start-dash-state><span class=secno>11.2.4.21 </span>Script data escape start dash state</a></li>
- <li><a href=#script-data-escaped-state><span class=secno>11.2.4.22 </span>Script data escaped state</a></li>
- <li><a href=#script-data-escaped-dash-state><span class=secno>11.2.4.23 </span>Script data escaped dash state</a></li>
- <li><a href=#script-data-escaped-dash-dash-state><span class=secno>11.2.4.24 </span>Script data escaped dash dash state</a></li>
- <li><a href=#script-data-escaped-less-than-sign-state><span class=secno>11.2.4.25 </span>Script data escaped less-than sign state</a></li>
- <li><a href=#script-data-escaped-end-tag-open-state><span class=secno>11.2.4.26 </span>Script data escaped end tag open state</a></li>
- <li><a href=#script-data-escaped-end-tag-name-state><span class=secno>11.2.4.27 </span>Script data escaped end tag name state</a></li>
- <li><a href=#script-data-double-escape-start-state><span class=secno>11.2.4.28 </span>Script data double escape start state</a></li>
- <li><a href=#script-data-double-escaped-state><span class=secno>11.2.4.29 </span>Script data double escaped state</a></li>
- <li><a href=#script-data-double-escaped-dash-state><span class=secno>11.2.4.30 </span>Script data double escaped dash state</a></li>
- <li><a href=#script-data-double-escaped-dash-dash-state><span class=secno>11.2.4.31 </span>Script data double escaped dash dash state</a></li>
- <li><a href=#script-data-double-escaped-less-than-sign-state><span class=secno>11.2.4.32 </span>Script data double escaped less-than sign state</a></li>
- <li><a href=#script-data-double-escape-end-state><span class=secno>11.2.4.33 </span>Script data double escape end state</a></li>
- <li><a href=#before-attribute-name-state><span class=secno>11.2.4.34 </span>Before attribute name state</a></li>
- <li><a href=#attribute-name-state><span class=secno>11.2.4.35 </span>Attribute name state</a></li>
- <li><a href=#after-attribute-name-state><span class=secno>11.2.4.36 </span>After attribute name state</a></li>
- <li><a href=#before-attribute-value-state><span class=secno>11.2.4.37 </span>Before attribute value state</a></li>
- <li><a href=#attribute-value-(double-quoted)-state><span class=secno>11.2.4.38 </span>Attribute value (double-quoted) state</a></li>
- <li><a href=#attribute-value-(single-quoted)-state><span class=secno>11.2.4.39 </span>Attribute value (single-quoted) state</a></li>
- <li><a href=#attribute-value-(unquoted)-state><span class=secno>11.2.4.40 </span>Attribute value (unquoted) state</a></li>
- <li><a href=#character-reference-in-attribute-value-state><span class=secno>11.2.4.41 </span>Character reference in attribute value state</a></li>
- <li><a href=#after-attribute-value-(quoted)-state><span class=secno>11.2.4.42 </span>After attribute value (quoted) state</a></li>
- <li><a href=#self-closing-start-tag-state><span class=secno>11.2.4.43 </span>Self-closing start tag state</a></li>
- <li><a href=#bogus-comment-state><span class=secno>11.2.4.44 </span>Bogus comment state</a></li>
- <li><a href=#markup-declaration-open-state><span class=secno>11.2.4.45 </span>Markup declaration open state</a></li>
- <li><a href=#comment-start-state><span class=secno>11.2.4.46 </span>Comment start state</a></li>
- <li><a href=#comment-start-dash-state><span class=secno>11.2.4.47 </span>Comment start dash state</a></li>
- <li><a href=#comment-state><span class=secno>11.2.4.48 </span>Comment state</a></li>
- <li><a href=#comment-end-dash-state><span class=secno>11.2.4.49 </span>Comment end dash state</a></li>
- <li><a href=#comment-end-state><span class=secno>11.2.4.50 </span>Comment end state</a></li>
- <li><a href=#comment-end-bang-state><span class=secno>11.2.4.51 </span>Comment end bang state</a></li>
- <li><a href=#doctype-state><span class=secno>11.2.4.52 </span>DOCTYPE state</a></li>
- <li><a href=#before-doctype-name-state><span class=secno>11.2.4.53 </span>Before DOCTYPE name state</a></li>
- <li><a href=#doctype-name-state><span class=secno>11.2.4.54 </span>DOCTYPE name state</a></li>
- <li><a href=#after-doctype-name-state><span class=secno>11.2.4.55 </span>After DOCTYPE name state</a></li>
- <li><a href=#after-doctype-public-keyword-state><span class=secno>11.2.4.56 </span>After DOCTYPE public keyword state</a></li>
- <li><a href=#before-doctype-public-identifier-state><span class=secno>11.2.4.57 </span>Before DOCTYPE public identifier state</a></li>
- <li><a href=#doctype-public-identifier-(double-quoted)-state><span class=secno>11.2.4.58 </span>DOCTYPE public identifier (double-quoted) state</a></li>
- <li><a href=#doctype-public-identifier-(single-quoted)-state><span class=secno>11.2.4.59 </span>DOCTYPE public identifier (single-quoted) state</a></li>
- <li><a href=#after-doctype-public-identifier-state><span class=secno>11.2.4.60 </span>After DOCTYPE public identifier state</a></li>
- <li><a href=#between-doctype-public-and-system-identifiers-state><span class=secno>11.2.4.61 </span>Between DOCTYPE public and system identifiers state</a></li>
- <li><a href=#after-doctype-system-keyword-state><span class=secno>11.2.4.62 </span>After DOCTYPE system keyword state</a></li>
- <li><a href=#before-doctype-system-identifier-state><span class=secno>11.2.4.63 </span>Before DOCTYPE system identifier state</a></li>
- <li><a href=#doctype-system-identifier-(double-quoted)-state><span class=secno>11.2.4.64 </span>DOCTYPE system identifier (double-quoted) state</a></li>
- <li><a href=#doctype-system-identifier-(single-quoted)-state><span class=secno>11.2.4.65 </span>DOCTYPE system identifier (single-quoted) state</a></li>
- <li><a href=#after-doctype-system-identifier-state><span class=secno>11.2.4.66 </span>After DOCTYPE system identifier state</a></li>
- <li><a href=#bogus-doctype-state><span class=secno>11.2.4.67 </span>Bogus DOCTYPE state</a></li>
- <li><a href=#cdata-section-state><span class=secno>11.2.4.68 </span>CDATA section state</a></li>
- <li><a href=#tokenizing-character-references><span class=secno>11.2.4.69 </span>Tokenizing character references</a></ol></li>
- <li><a href=#tree-construction><span class=secno>11.2.5 </span>Tree construction</a>
+ <li><a href=#security-localStorage><span class=secno>12.2.3.1 </span>Security</a></ol></li>
+ <li><a href=#the-storage-event><span class=secno>12.2.4 </span>The <code title=event-storage>storage</code> event</a>
<ol>
- <li><a href=#creating-and-inserting-elements><span class=secno>11.2.5.1 </span>Creating and inserting elements</a></li>
- <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>11.2.5.2 </span>Closing elements that have implied end tags</a></li>
- <li><a href=#foster-parenting><span class=secno>11.2.5.3 </span>Foster parenting</a></li>
- <li><a href=#parsing-main-inhtml><span class=secno>11.2.5.4 </span>The rules for parsing tokens in HTML content</a>
+ <li><a href=#event-definition-0><span class=secno>12.2.4.1 </span>Event definition</a></ol></li>
+ <li><a href=#threads><span class=secno>12.2.5 </span>Threads</a></ol></li>
+ <li><a href=#disk-space-0><span class=secno>12.3 </span>Disk space</a></li>
+ <li><a href=#privacy><span class=secno>12.4 </span>Privacy</a>
+ <ol>
+ <li><a href=#user-tracking><span class=secno>12.4.1 </span>User tracking</a></li>
+ <li><a href=#sensitivity-of-data><span class=secno>12.4.2 </span>Sensitivity of data</a></ol></li>
+ <li><a href=#security-storage><span class=secno>12.5 </span>Security</a>
+ <ol>
+ <li><a href=#dns-spoofing-attacks><span class=secno>12.5.1 </span>DNS spoofing attacks</a></li>
+ <li><a href=#cross-directory-attacks><span class=secno>12.5.2 </span>Cross-directory attacks</a></li>
+ <li><a href=#implementation-risks><span class=secno>12.5.3 </span>Implementation risks</a></ol></ol></li>
+ <li><a href=#syntax><span class=secno>13 </span>The HTML syntax</a>
+ <ol>
+ <li><a href=#writing><span class=secno>13.1 </span>Writing HTML documents</a>
+ <ol>
+ <li><a href=#the-doctype><span class=secno>13.1.1 </span>The DOCTYPE</a></li>
+ <li><a href=#elements-0><span class=secno>13.1.2 </span>Elements</a>
+ <ol>
+ <li><a href=#start-tags><span class=secno>13.1.2.1 </span>Start tags</a></li>
+ <li><a href=#end-tags><span class=secno>13.1.2.2 </span>End tags</a></li>
+ <li><a href=#attributes-0><span class=secno>13.1.2.3 </span>Attributes</a></li>
+ <li><a href=#optional-tags><span class=secno>13.1.2.4 </span>Optional tags</a></li>
+ <li><a href=#element-restrictions><span class=secno>13.1.2.5 </span>Restrictions on content models</a></li>
+ <li><a href=#cdata-rcdata-restrictions><span class=secno>13.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</a></ol></li>
+ <li><a href=#text-1><span class=secno>13.1.3 </span>Text</a>
+ <ol>
+ <li><a href=#newlines><span class=secno>13.1.3.1 </span>Newlines</a></ol></li>
+ <li><a href=#character-references><span class=secno>13.1.4 </span>Character references</a></li>
+ <li><a href=#cdata-sections><span class=secno>13.1.5 </span>CDATA sections</a></li>
+ <li><a href=#comments><span class=secno>13.1.6 </span>Comments</a></ol></li>
+ <li><a href=#parsing><span class=secno>13.2 </span>Parsing HTML documents</a>
+ <ol>
+ <li><a href=#overview-of-the-parsing-model><span class=secno>13.2.1 </span>Overview of the parsing model</a></li>
+ <li><a href=#the-input-stream><span class=secno>13.2.2 </span>The input stream</a>
+ <ol>
+ <li><a href=#determining-the-character-encoding><span class=secno>13.2.2.1 </span>Determining the character encoding</a></li>
+ <li><a href=#character-encodings-0><span class=secno>13.2.2.2 </span>Character encodings</a></li>
+ <li><a href=#preprocessing-the-input-stream><span class=secno>13.2.2.3 </span>Preprocessing the input stream</a></li>
+ <li><a href=#changing-the-encoding-while-parsing><span class=secno>13.2.2.4 </span>Changing the encoding while parsing</a></ol></li>
+ <li><a href=#parse-state><span class=secno>13.2.3 </span>Parse state</a>
+ <ol>
+ <li><a href=#the-insertion-mode><span class=secno>13.2.3.1 </span>The insertion mode</a></li>
+ <li><a href=#the-stack-of-open-elements><span class=secno>13.2.3.2 </span>The stack of open elements</a></li>
+ <li><a href=#the-list-of-active-formatting-elements><span class=secno>13.2.3.3 </span>The list of active formatting elements</a></li>
+ <li><a href=#the-element-pointers><span class=secno>13.2.3.4 </span>The element pointers</a></li>
+ <li><a href=#other-parsing-state-flags><span class=secno>13.2.3.5 </span>Other parsing state flags</a></ol></li>
+ <li><a href=#tokenization><span class=secno>13.2.4 </span>Tokenization</a>
+ <ol>
+ <li><a href=#data-state><span class=secno>13.2.4.1 </span>Data state</a></li>
+ <li><a href=#character-reference-in-data-state><span class=secno>13.2.4.2 </span>Character reference in data state</a></li>
+ <li><a href=#rcdata-state><span class=secno>13.2.4.3 </span>RCDATA state</a></li>
+ <li><a href=#character-reference-in-rcdata-state><span class=secno>13.2.4.4 </span>Character reference in RCDATA state</a></li>
+ <li><a href=#rawtext-state><span class=secno>13.2.4.5 </span>RAWTEXT state</a></li>
+ <li><a href=#script-data-state><span class=secno>13.2.4.6 </span>Script data state</a></li>
+ <li><a href=#plaintext-state><span class=secno>13.2.4.7 </span>PLAINTEXT state</a></li>
+ <li><a href=#tag-open-state><span class=secno>13.2.4.8 </span>Tag open state</a></li>
+ <li><a href=#end-tag-open-state><span class=secno>13.2.4.9 </span>End tag open state</a></li>
+ <li><a href=#tag-name-state><span class=secno>13.2.4.10 </span>Tag name state</a></li>
+ <li><a href=#rcdata-less-than-sign-state><span class=secno>13.2.4.11 </span>RCDATA less-than sign state</a></li>
+ <li><a href=#rcdata-end-tag-open-state><span class=secno>13.2.4.12 </span>RCDATA end tag open state</a></li>
+ <li><a href=#rcdata-end-tag-name-state><span class=secno>13.2.4.13 </span>RCDATA end tag name state</a></li>
+ <li><a href=#rawtext-less-than-sign-state><span class=secno>13.2.4.14 </span>RAWTEXT less-than sign state</a></li>
+ <li><a href=#rawtext-end-tag-open-state><span class=secno>13.2.4.15 </span>RAWTEXT end tag open state</a></li>
+ <li><a href=#rawtext-end-tag-name-state><span class=secno>13.2.4.16 </span>RAWTEXT end tag name state</a></li>
+ <li><a href=#script-data-less-than-sign-state><span class=secno>13.2.4.17 </span>Script data less-than sign state</a></li>
+ <li><a href=#script-data-end-tag-open-state><span class=secno>13.2.4.18 </span>Script data end tag open state</a></li>
+ <li><a href=#script-data-end-tag-name-state><span class=secno>13.2.4.19 </span>Script data end tag name state</a></li>
+ <li><a href=#script-data-escape-start-state><span class=secno>13.2.4.20 </span>Script data escape start state</a></li>
+ <li><a href=#script-data-escape-start-dash-state><span class=secno>13.2.4.21 </span>Script data escape start dash state</a></li>
+ <li><a href=#script-data-escaped-state><span class=secno>13.2.4.22 </span>Script data escaped state</a></li>
+ <li><a href=#script-data-escaped-dash-state><span class=secno>13.2.4.23 </span>Script data escaped dash state</a></li>
+ <li><a href=#script-data-escaped-dash-dash-state><span class=secno>13.2.4.24 </span>Script data escaped dash dash state</a></li>
+ <li><a href=#script-data-escaped-less-than-sign-state><span class=secno>13.2.4.25 </span>Script data escaped less-than sign state</a></li>
+ <li><a href=#script-data-escaped-end-tag-open-state><span class=secno>13.2.4.26 </span>Script data escaped end tag open state</a></li>
+ <li><a href=#script-data-escaped-end-tag-name-state><span class=secno>13.2.4.27 </span>Script data escaped end tag name state</a></li>
+ <li><a href=#script-data-double-escape-start-state><span class=secno>13.2.4.28 </span>Script data double escape start state</a></li>
+ <li><a href=#script-data-double-escaped-state><span class=secno>13.2.4.29 </span>Script data double escaped state</a></li>
+ <li><a href=#script-data-double-escaped-dash-state><span class=secno>13.2.4.30 </span>Script data double escaped dash state</a></li>
+ <li><a href=#script-data-double-escaped-dash-dash-state><span class=secno>13.2.4.31 </span>Script data double escaped dash dash state</a></li>
+ <li><a href=#script-data-double-escaped-less-than-sign-state><span class=secno>13.2.4.32 </span>Script data double escaped less-than sign state</a></li>
+ <li><a href=#script-data-double-escape-end-state><span class=secno>13.2.4.33 </span>Script data double escape end state</a></li>
+ <li><a href=#before-attribute-name-state><span class=secno>13.2.4.34 </span>Before attribute name state</a></li>
+ <li><a href=#attribute-name-state><span class=secno>13.2.4.35 </span>Attribute name state</a></li>
+ <li><a href=#after-attribute-name-state><span class=secno>13.2.4.36 </span>After attribute name state</a></li>
+ <li><a href=#before-attribute-value-state><span class=secno>13.2.4.37 </span>Before attribute value state</a></li>
+ <li><a href=#attribute-value-(double-quoted)-state><span class=secno>13.2.4.38 </span>Attribute value (double-quoted) state</a></li>
+ <li><a href=#attribute-value-(single-quoted)-state><span class=secno>13.2.4.39 </span>Attribute value (single-quoted) state</a></li>
+ <li><a href=#attribute-value-(unquoted)-state><span class=secno>13.2.4.40 </span>Attribute value (unquoted) state</a></li>
+ <li><a href=#character-reference-in-attribute-value-state><span class=secno>13.2.4.41 </span>Character reference in attribute value state</a></li>
+ <li><a href=#after-attribute-value-(quoted)-state><span class=secno>13.2.4.42 </span>After attribute value (quoted) state</a></li>
+ <li><a href=#self-closing-start-tag-state><span class=secno>13.2.4.43 </span>Self-closing start tag state</a></li>
+ <li><a href=#bogus-comment-state><span class=secno>13.2.4.44 </span>Bogus comment state</a></li>
+ <li><a href=#markup-declaration-open-state><span class=secno>13.2.4.45 </span>Markup declaration open state</a></li>
+ <li><a href=#comment-start-state><span class=secno>13.2.4.46 </span>Comment start state</a></li>
+ <li><a href=#comment-start-dash-state><span class=secno>13.2.4.47 </span>Comment start dash state</a></li>
+ <li><a href=#comment-state><span class=secno>13.2.4.48 </span>Comment state</a></li>
+ <li><a href=#comment-end-dash-state><span class=secno>13.2.4.49 </span>Comment end dash state</a></li>
+ <li><a href=#comment-end-state><span class=secno>13.2.4.50 </span>Comment end state</a></li>
+ <li><a href=#comment-end-bang-state><span class=secno>13.2.4.51 </span>Comment end bang state</a></li>
+ <li><a href=#doctype-state><span class=secno>13.2.4.52 </span>DOCTYPE state</a></li>
+ <li><a href=#before-doctype-name-state><span class=secno>13.2.4.53 </span>Before DOCTYPE name state</a></li>
+ <li><a href=#doctype-name-state><span class=secno>13.2.4.54 </span>DOCTYPE name state</a></li>
+ <li><a href=#after-doctype-name-state><span class=secno>13.2.4.55 </span>After DOCTYPE name state</a></li>
+ <li><a href=#after-doctype-public-keyword-state><span class=secno>13.2.4.56 </span>After DOCTYPE public keyword state</a></li>
+ <li><a href=#before-doctype-public-identifier-state><span class=secno>13.2.4.57 </span>Before DOCTYPE public identifier state</a></li>
+ <li><a href=#doctype-public-identifier-(double-quoted)-state><span class=secno>13.2.4.58 </span>DOCTYPE public identifier (double-quoted) state</a></li>
+ <li><a href=#doctype-public-identifier-(single-quoted)-state><span class=secno>13.2.4.59 </span>DOCTYPE public identifier (single-quoted) state</a></li>
+ <li><a href=#after-doctype-public-identifier-state><span class=secno>13.2.4.60 </span>After DOCTYPE public identifier state</a></li>
+ <li><a href=#between-doctype-public-and-system-identifiers-state><span class=secno>13.2.4.61 </span>Between DOCTYPE public and system identifiers state</a></li>
+ <li><a href=#after-doctype-system-keyword-state><span class=secno>13.2.4.62 </span>After DOCTYPE system keyword state</a></li>
+ <li><a href=#before-doctype-system-identifier-state><span class=secno>13.2.4.63 </span>Before DOCTYPE system identifier state</a></li>
+ <li><a href=#doctype-system-identifier-(double-quoted)-state><span class=secno>13.2.4.64 </span>DOCTYPE system identifier (double-quoted) state</a></li>
+ <li><a href=#doctype-system-identifier-(single-quoted)-state><span class=secno>13.2.4.65 </span>DOCTYPE system identifier (single-quoted) state</a></li>
+ <li><a href=#after-doctype-system-identifier-state><span class=secno>13.2.4.66 </span>After DOCTYPE system identifier state</a></li>
+ <li><a href=#bogus-doctype-state><span class=secno>13.2.4.67 </span>Bogus DOCTYPE state</a></li>
+ <li><a href=#cdata-section-state><span class=secno>13.2.4.68 </span>CDATA section state</a></li>
+ <li><a href=#tokenizing-character-references><span class=secno>13.2.4.69 </span>Tokenizing character references</a></ol></li>
+ <li><a href=#tree-construction><span class=secno>13.2.5 </span>Tree construction</a>
+ <ol>
+ <li><a href=#creating-and-inserting-elements><span class=secno>13.2.5.1 </span>Creating and inserting elements</a></li>
+ <li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>13.2.5.2 </span>Closing elements that have implied end tags</a></li>
+ <li><a href=#foster-parenting><span class=secno>13.2.5.3 </span>Foster parenting</a></li>
+ <li><a href=#parsing-main-inhtml><span class=secno>13.2.5.4 </span>The rules for parsing tokens in HTML content</a>
<ol>
- <li><a href=#the-initial-insertion-mode><span class=secno>11.2.5.4.1 </span>The "initial" insertion mode</a></li>
- <li><a href=#the-before-html-insertion-mode><span class=secno>11.2.5.4.2 </span>The "before html" insertion mode</a></li>
- <li><a href=#the-before-head-insertion-mode><span class=secno>11.2.5.4.3 </span>The "before head" insertion mode</a></li>
- <li><a href=#parsing-main-inhead><span class=secno>11.2.5.4.4 </span>The "in head" insertion mode</a></li>
- <li><a href=#parsing-main-inheadnoscript><span class=secno>11.2.5.4.5 </span>The "in head noscript" insertion mode</a></li>
- <li><a href=#the-after-head-insertion-mode><span class=secno>11.2.5.4.6 </span>The "after head" insertion mode</a></li>
- <li><a href=#parsing-main-inbody><span class=secno>11.2.5.4.7 </span>The "in body" insertion mode</a></li>
- <li><a href=#parsing-main-incdata><span class=secno>11.2.5.4.8 </span>The "text" insertion mode</a></li>
- <li><a href=#parsing-main-intable><span class=secno>11.2.5.4.9 </span>The "in table" insertion mode</a></li>
- <li><a href=#parsing-main-intabletext><span class=secno>11.2.5.4.10 </span>The "in table text" insertion mode</a></li>
- <li><a href=#parsing-main-incaption><span class=secno>11.2.5.4.11 </span>The "in caption" insertion mode</a></li>
- <li><a href=#parsing-main-incolgroup><span class=secno>11.2.5.4.12 </span>The "in column group" insertion mode</a></li>
- <li><a href=#parsing-main-intbody><span class=secno>11.2.5.4.13 </span>The "in table body" insertion mode</a></li>
- <li><a href=#parsing-main-intr><span class=secno>11.2.5.4.14 </span>The "in row" insertion mode</a></li>
- <li><a href=#parsing-main-intd><span class=secno>11.2.5.4.15 </span>The "in cell" insertion mode</a></li>
- <li><a href=#parsing-main-inselect><span class=secno>11.2.5.4.16 </span>The "in select" insertion mode</a></li>
- <li><a href=#parsing-main-inselectintable><span class=secno>11.2.5.4.17 </span>The "in select in table" insertion mode</a></li>
- <li><a href=#parsing-main-afterbody><span class=secno>11.2.5.4.18 </span>The "after body" insertion mode</a></li>
- <li><a href=#parsing-main-inframeset><span class=secno>11.2.5.4.19 </span>The "in frameset" insertion mode</a></li>
- <li><a href=#parsing-main-afterframeset><span class=secno>11.2.5.4.20 </span>The "after frameset" insertion mode</a></li>
- <li><a href=#the-after-after-body-insertion-mode><span class=secno>11.2.5.4.21 </span>The "after after body" insertion mode</a></li>
- <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>11.2.5.4.22 </span>The "after after frameset" insertion mode</a></ol></li>
- <li><a href=#parsing-main-inforeign><span class=secno>11.2.5.5 </span>The rules for parsing tokens in foreign content</a></ol></li>
- <li><a href=#the-end><span class=secno>11.2.6 </span>The end</a></li>
- <li><a href=#coercing-an-html-dom-into-an-infoset><span class=secno>11.2.7 </span>Coercing an HTML DOM into an infoset</a></li>
- <li><a href=#an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>11.2.8 </span>An introduction to error handling and strange cases in the parser</a>
+ <li><a href=#the-initial-insertion-mode><span class=secno>13.2.5.4.1 </span>The "initial" insertion mode</a></li>
+ <li><a href=#the-before-html-insertion-mode><span class=secno>13.2.5.4.2 </span>The "before html" insertion mode</a></li>
+ <li><a href=#the-before-head-insertion-mode><span class=secno>13.2.5.4.3 </span>The "before head" insertion mode</a></li>
+ <li><a href=#parsing-main-inhead><span class=secno>13.2.5.4.4 </span>The "in head" insertion mode</a></li>
+ <li><a href=#parsing-main-inheadnoscript><span class=secno>13.2.5.4.5 </span>The "in head noscript" insertion mode</a></li>
+ <li><a href=#the-after-head-insertion-mode><span class=secno>13.2.5.4.6 </span>The "after head" insertion mode</a></li>
+ <li><a href=#parsing-main-inbody><span class=secno>13.2.5.4.7 </span>The "in body" insertion mode</a></li>
+ <li><a href=#parsing-main-incdata><span class=secno>13.2.5.4.8 </span>The "text" insertion mode</a></li>
+ <li><a href=#parsing-main-intable><span class=secno>13.2.5.4.9 </span>The "in table" insertion mode</a></li>
+ <li><a href=#parsing-main-intabletext><span class=secno>13.2.5.4.10 </span>The "in table text" insertion mode</a></li>
+ <li><a href=#parsing-main-incaption><span class=secno>13.2.5.4.11 </span>The "in caption" insertion mode</a></li>
+ <li><a href=#parsing-main-incolgroup><span class=secno>13.2.5.4.12 </span>The "in column group" insertion mode</a></li>
+ <li><a href=#parsing-main-intbody><span class=secno>13.2.5.4.13 </span>The "in table body" insertion mode</a></li>
+ <li><a href=#parsing-main-intr><span class=secno>13.2.5.4.14 </span>The "in row" insertion mode</a></li>
+ <li><a href=#parsing-main-intd><span class=secno>13.2.5.4.15 </span>The "in cell" insertion mode</a></li>
+ <li><a href=#parsing-main-inselect><span class=secno>13.2.5.4.16 </span>The "in select" insertion mode</a></li>
+ <li><a href=#parsing-main-inselectintable><span class=secno>13.2.5.4.17 </span>The "in select in table" insertion mode</a></li>
+ <li><a href=#parsing-main-afterbody><span class=secno>13.2.5.4.18 </span>The "after body" insertion mode</a></li>
+ <li><a href=#parsing-main-inframeset><span class=secno>13.2.5.4.19 </span>The "in frameset" insertion mode</a></li>
+ <li><a href=#parsing-main-afterframeset><span class=secno>13.2.5.4.20 </span>The "after frameset" insertion mode</a></li>
+ <li><a href=#the-after-after-body-insertion-mode><span class=secno>13.2.5.4.21 </span>The "after after body" insertion mode</a></li>
+ <li><a href=#the-after-after-frameset-insertion-mode><span class=secno>13.2.5.4.22 </span>The "after after frameset" insertion mode</a></ol></li>
+ <li><a href=#parsing-main-inforeign><span class=secno>13.2.5.5 </span>The rules for parsing tokens in foreign content</a></ol></li>
+ <li><a href=#the-end><span class=secno>13.2.6 </span>The end</a></li>
+ <li><a href=#coercing-an-html-dom-into-an-infoset><span class=secno>13.2.7 </span>Coercing an HTML DOM into an infoset</a></li>
+ <li><a href=#an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>13.2.8 </span>An introduction to error handling and strange cases in the parser</a>
<ol>
- <li><a href=#misnested-tags:-b-i-/b-/i><span class=secno>11.2.8.1 </span>Misnested tags: <b><i></b></i></a></li>
- <li><a href=#misnested-tags:-b-p-/b-/p><span class=secno>11.2.8.2 </span>Misnested tags: <b><p></b></p></a></li>
- <li><a href=#unexpected-markup-in-tables><span class=secno>11.2.8.3 </span>Unexpected markup in tables</a></li>
- <li><a href=#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>11.2.8.4 </span>Scripts that modify the page as it is being parsed</a></li>
- <li><a href=#the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>11.2.8.5 </span>The execution of scripts that are moving across multiple documents</a></li>
- <li><a href=#unclosed-formatting-elements><span class=secno>11.2.8.6 </span>Unclosed formatting elements</a></ol></ol></li>
- <li><a href=#serializing-html-fragments><span class=secno>11.3 </span>Serializing HTML fragments</a></li>
- <li><a href=#parsing-html-fragments><span class=secno>11.4 </span>Parsing HTML fragments</a></li>
- <li><a href=#named-character-references><span class=secno>11.5 </span>Named character references</a></ol></li>
- <li><a href=#the-xhtml-syntax><span class=secno>12 </span>The XHTML syntax</a>
+ <li><a href=#misnested-tags:-b-i-/b-/i><span class=secno>13.2.8.1 </span>Misnested tags: <b><i></b></i></a></li>
+ <li><a href=#misnested-tags:-b-p-/b-/p><span class=secno>13.2.8.2 </span>Misnested tags: <b><p></b></p></a></li>
+ <li><a href=#unexpected-markup-in-tables><span class=secno>13.2.8.3 </span>Unexpected markup in tables</a></li>
+ <li><a href=#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>13.2.8.4 </span>Scripts that modify the page as it is being parsed</a></li>
+ <li><a href=#the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>13.2.8.5 </span>The execution of scripts that are moving across multiple documents</a></li>
+ <li><a href=#unclosed-formatting-elements><span class=secno>13.2.8.6 </span>Unclosed formatting elements</a></ol></ol></li>
+ <li><a href=#serializing-html-fragments><span class=secno>13.3 </span>Serializing HTML fragments</a></li>
+ <li><a href=#parsing-html-fragments><span class=secno>13.4 </span>Parsing HTML fragments</a></li>
+ <li><a href=#named-character-references><span class=secno>13.5 </span>Named character references</a></ol></li>
+ <li><a href=#the-xhtml-syntax><span class=secno>14 </span>The XHTML syntax</a>
<ol>
- <li><a href=#writing-xhtml-documents><span class=secno>12.1 </span>Writing XHTML documents</a></li>
- <li><a href=#parsing-xhtml-documents><span class=secno>12.2 </span>Parsing XHTML documents</a></li>
- <li><a href=#serializing-xhtml-fragments><span class=secno>12.3 </span>Serializing XHTML fragments</a></li>
- <li><a href=#parsing-xhtml-fragments><span class=secno>12.4 </span>Parsing XHTML fragments</a></ol></li>
- <li><a href=#rendering><span class=secno>13 </span>Rendering</a>
+ <li><a href=#writing-xhtml-documents><span class=secno>14.1 </span>Writing XHTML documents</a></li>
+ <li><a href=#parsing-xhtml-documents><span class=secno>14.2 </span>Parsing XHTML documents</a></li>
+ <li><a href=#serializing-xhtml-fragments><span class=secno>14.3 </span>Serializing XHTML fragments</a></li>
+ <li><a href=#parsing-xhtml-fragments><span class=secno>14.4 </span>Parsing XHTML fragments</a></ol></li>
+ <li><a href=#rendering><span class=secno>15 </span>Rendering</a>
<ol>
- <li><a href=#introduction-15><span class=secno>13.1 </span>Introduction</a></li>
- <li><a href=#the-css-user-agent-style-sheet-and-presentational-hints><span class=secno>13.2 </span>The CSS user agent style sheet and presentational hints</a></li>
- <li><a href=#non-replaced-elements><span class=secno>13.3 </span>Non-replaced elements</a>
+ <li><a href=#introduction-17><span class=secno>15.1 </span>Introduction</a></li>
+ <li><a href=#the-css-user-agent-style-sheet-and-presentational-hints><span class=secno>15.2 </span>The CSS user agent style sheet and presentational hints</a></li>
+ <li><a href=#non-replaced-elements><span class=secno>15.3 </span>Non-replaced elements</a>
<ol>
- <li><a href=#hidden-elements><span class=secno>13.3.1 </span>Hidden elements</a></li>
- <li><a href=#the-page><span class=secno>13.3.2 </span>The page</a></li>
- <li><a href=#flow-content-1><span class=secno>13.3.3 </span>Flow content</a></li>
- <li><a href=#phrasing-content-1><span class=secno>13.3.4 </span>Phrasing content</a></li>
- <li><a href=#bidirectional-text><span class=secno>13.3.5 </span>Bidirectional text</a></li>
- <li><a href=#sections-and-headings><span class=secno>13.3.6 </span>Sections and headings</a></li>
- <li><a href=#lists><span class=secno>13.3.7 </span>Lists</a></li>
- <li><a href=#tables><span class=secno>13.3.8 </span>Tables</a></li>
- <li><a href=#form-controls><span class=secno>13.3.9 </span>Form controls</a></li>
- <li><a href=#the-hr-element-0><span class=secno>13.3.10 </span>The <code>hr</code> element</a></li>
- <li><a href=#the-fieldset-element-0><span class=secno>13.3.11 </span>The <code>fieldset</code> element</a></ol></li>
- <li><a href=#replaced-elements><span class=secno>13.4 </span>Replaced elements</a>
+ <li><a href=#hidden-elements><span class=secno>15.3.1 </span>Hidden elements</a></li>
+ <li><a href=#the-page><span class=secno>15.3.2 </span>The page</a></li>
+ <li><a href=#flow-content-1><span class=secno>15.3.3 </span>Flow content</a></li>
+ <li><a href=#phrasing-content-1><span class=secno>15.3.4 </span>Phrasing content</a></li>
+ <li><a href=#bidirectional-text><span class=secno>15.3.5 </span>Bidirectional text</a></li>
+ <li><a href=#sections-and-headings><span class=secno>15.3.6 </span>Sections and headings</a></li>
+ <li><a href=#lists><span class=secno>15.3.7 </span>Lists</a></li>
+ <li><a href=#tables><span class=secno>15.3.8 </span>Tables</a></li>
+ <li><a href=#form-controls><span class=secno>15.3.9 </span>Form controls</a></li>
+ <li><a href=#the-hr-element-0><span class=secno>15.3.10 </span>The <code>hr</code> element</a></li>
+ <li><a href=#the-fieldset-element-0><span class=secno>15.3.11 </span>The <code>fieldset</code> element</a></ol></li>
+ <li><a href=#replaced-elements><span class=secno>15.4 </span>Replaced elements</a>
<ol>
- <li><a href=#embedded-content-2><span class=secno>13.4.1 </span>Embedded content</a></li>
- <li><a href=#timed-text-tracks-0><span class=secno>13.4.2 </span>Timed text tracks</a>
+ <li><a href=#embedded-content-2><span class=secno>15.4.1 </span>Embedded content</a></li>
+ <li><a href=#timed-text-tracks-0><span class=secno>15.4.2 </span>Timed text tracks</a>
<ol>
- <li><a href=#webvtt-cue-text-rendering-rules><span class=secno>13.4.2.1 </span>WebVTT cue text rendering rules</a></li>
- <li><a href=#applying-css-properties-to-webvtt-node-objects><span class=secno>13.4.2.2 </span>Applying CSS properties to WebVTT Node Objects</a></li>
- <li><a href=#css-extensions><span class=secno>13.4.2.3 </span>CSS extensions</a>
+ <li><a href=#webvtt-cue-text-rendering-rules><span class=secno>15.4.2.1 </span>WebVTT cue text rendering rules</a></li>
+ <li><a href=#applying-css-properties-to-webvtt-node-objects><span class=secno>15.4.2.2 </span>Applying CSS properties to WebVTT Node Objects</a></li>
+ <li><a href=#css-extensions><span class=secno>15.4.2.3 </span>CSS extensions</a>
<ol>
- <li><a href="#the-'::cue'-pseudo-element"><span class=secno>13.4.2.3.1 </span>The '::cue' pseudo-element</a></li>
- <li><a href="#the-':past'-and-':future'-pseudo-classes"><span class=secno>13.4.2.3.2 </span>The ':past' and ':future' pseudo-classes</a></ol></ol></li>
- <li><a href=#images-0><span class=secno>13.4.3 </span>Images</a></li>
- <li><a href=#attributes-for-embedded-content-and-images><span class=secno>13.4.4 </span>Attributes for embedded content and images</a></li>
- <li><a href=#image-maps-0><span class=secno>13.4.5 </span>Image maps</a></li>
- <li><a href=#toolbars-0><span class=secno>13.4.6 </span>Toolbars</a></ol></li>
- <li><a href=#bindings><span class=secno>13.5 </span>Bindings</a>
+ <li><a href="#the-'::cue'-pseudo-element"><span class=secno>15.4.2.3.1 </span>The '::cue' pseudo-element</a></li>
+ <li><a href="#the-':past'-and-':future'-pseudo-classes"><span class=secno>15.4.2.3.2 </span>The ':past' and ':future' pseudo-classes</a></ol></ol></li>
+ <li><a href=#images-0><span class=secno>15.4.3 </span>Images</a></li>
+ <li><a href=#attributes-for-embedded-content-and-images><span class=secno>15.4.4 </span>Attributes for embedded content and images</a></li>
+ <li><a href=#image-maps-0><span class=secno>15.4.5 </span>Image maps</a></li>
+ <li><a href=#toolbars-0><span class=secno>15.4.6 </span>Toolbars</a></ol></li>
+ <li><a href=#bindings><span class=secno>15.5 </span>Bindings</a>
<ol>
- <li><a href=#introduction-16><span class=secno>13.5.1 </span>Introduction</a></li>
- <li><a href=#the-button-element-0><span class=secno>13.5.2 </span>The <code>button</code> element</a></li>
- <li><a href=#the-details-element-0><span class=secno>13.5.3 </span>The <code>details</code> element</a></li>
- <li><a href=#the-input-element-as-a-text-entry-widget><span class=secno>13.5.4 </span>The <code>input</code> element as a text entry widget</a></li>
- <li><a href=#the-input-element-as-domain-specific-widgets><span class=secno>13.5.5 </span>The <code>input</code> element as domain-specific widgets</a></li>
- <li><a href=#the-input-element-as-a-range-control><span class=secno>13.5.6 </span>The <code>input</code> element as a range control</a></li>
- <li><a href=#the-input-element-as-a-color-well><span class=secno>13.5.7 </span>The <code>input</code> element as a color well</a></li>
- <li><a href=#the-input-element-as-a-checkbox-and-radio-button-widgets><span class=secno>13.5.8 </span>The <code>input</code> element as a checkbox and radio button widgets</a></li>
- <li><a href=#the-input-element-as-a-file-upload-control><span class=secno>13.5.9 </span>The <code>input</code> element as a file upload control</a></li>
- <li><a href=#the-input-element-as-a-button><span class=secno>13.5.10 </span>The <code>input</code> element as a button</a></li>
- <li><a href=#the-marquee-element-0><span class=secno>13.5.11 </span>The <code>marquee</code> element</a></li>
- <li><a href=#the-meter-element-0><span class=secno>13.5.12 </span>The <code>meter</code> element</a></li>
- <li><a href=#the-progress-element-0><span class=secno>13.5.13 </span>The <code>progress</code> element</a></li>
- <li><a href=#the-select-element-0><span class=secno>13.5.14 </span>The <code>select</code> element</a></li>
- <li><a href=#the-textarea-element-0><span class=secno>13.5.15 </span>The <code>textarea</code> element</a></li>
- <li><a href=#the-keygen-element-0><span class=secno>13.5.16 </span>The <code>keygen</code> element</a></li>
- <li><a href=#the-time-element-0><span class=secno>13.5.17 </span>The <code>time</code> element</a></ol></li>
- <li><a href=#frames-and-framesets><span class=secno>13.6 </span>Frames and framesets</a></li>
- <li><a href=#interactive-media><span class=secno>13.7 </span>Interactive media</a>
+ <li><a href=#introduction-18><span class=secno>15.5.1 </span>Introduction</a></li>
+ <li><a href=#the-button-element-0><span class=secno>15.5.2 </span>The <code>button</code> element</a></li>
+ <li><a href=#the-details-element-0><span class=secno>15.5.3 </span>The <code>details</code> element</a></li>
+ <li><a href=#the-input-element-as-a-text-entry-widget><span class=secno>15.5.4 </span>The <code>input</code> element as a text entry widget</a></li>
+ <li><a href=#the-input-element-as-domain-specific-widgets><span class=secno>15.5.5 </span>The <code>input</code> element as domain-specific widgets</a></li>
+ <li><a href=#the-input-element-as-a-range-control><span class=secno>15.5.6 </span>The <code>input</code> element as a range control</a></li>
+ <li><a href=#the-input-element-as-a-color-well><span class=secno>15.5.7 </span>The <code>input</code> element as a color well</a></li>
+ <li><a href=#the-input-element-as-a-checkbox-and-radio-button-widgets><span class=secno>15.5.8 </span>The <code>input</code> element as a checkbox and radio button widgets</a></li>
+ <li><a href=#the-input-element-as-a-file-upload-control><span class=secno>15.5.9 </span>The <code>input</code> element as a file upload control</a></li>
+ <li><a href=#the-input-element-as-a-button><span class=secno>15.5.10 </span>The <code>input</code> element as a button</a></li>
+ <li><a href=#the-marquee-element-0><span class=secno>15.5.11 </span>The <code>marquee</code> element</a></li>
+ <li><a href=#the-meter-element-0><span class=secno>15.5.12 </span>The <code>meter</code> element</a></li>
+ <li><a href=#the-progress-element-0><span class=secno>15.5.13 </span>The <code>progress</code> element</a></li>
+ <li><a href=#the-select-element-0><span class=secno>15.5.14 </span>The <code>select</code> element</a></li>
+ <li><a href=#the-textarea-element-0><span class=secno>15.5.15 </span>The <code>textarea</code> element</a></li>
+ <li><a href=#the-keygen-element-0><span class=secno>15.5.16 </span>The <code>keygen</code> element</a></li>
+ <li><a href=#the-time-element-0><span class=secno>15.5.17 </span>The <code>time</code> element</a></ol></li>
+ <li><a href=#frames-and-framesets><span class=secno>15.6 </span>Frames and framesets</a></li>
+ <li><a href=#interactive-media><span class=secno>15.7 </span>Interactive media</a>
<ol>
- <li><a href=#links,-forms,-and-navigation><span class=secno>13.7.1 </span>Links, forms, and navigation</a></li>
- <li><a href=#the-title-attribute-0><span class=secno>13.7.2 </span>The <code title=attr-title>title</code> attribute</a></li>
- <li><a href=#editing-hosts><span class=secno>13.7.3 </span>Editing hosts</a></li>
- <li><a href=#text-rendered-in-native-user-interfaces><span class=secno>13.7.4 </span>Text rendered in native user interfaces</a></ol></li>
- <li><a href=#print-media><span class=secno>13.8 </span>Print media</a></ol></li>
- <li><a href=#obsolete><span class=secno>14 </span>Obsolete features</a>
+ <li><a href=#links,-forms,-and-navigation><span class=secno>15.7.1 </span>Links, forms, and navigation</a></li>
+ <li><a href=#the-title-attribute-0><span class=secno>15.7.2 </span>The <code title=attr-title>title</code> attribute</a></li>
+ <li><a href=#editing-hosts><span class=secno>15.7.3 </span>Editing hosts</a></li>
+ <li><a href=#text-rendered-in-native-user-interfaces><span class=secno>15.7.4 </span>Text rendered in native user interfaces</a></ol></li>
+ <li><a href=#print-media><span class=secno>15.8 </span>Print media</a></ol></li>
+ <li><a href=#obsolete><span class=secno>16 </span>Obsolete features</a>
<ol>
- <li><a href=#obsolete-but-conforming-features><span class=secno>14.1 </span>Obsolete but conforming features</a>
+ <li><a href=#obsolete-but-conforming-features><span class=secno>16.1 </span>Obsolete but conforming features</a>
<ol>
- <li><a href=#warnings-for-obsolete-but-conforming-features><span class=secno>14.1.1 </span>Warnings for obsolete but conforming features</a></ol></li>
- <li><a href=#non-conforming-features><span class=secno>14.2 </span>Non-conforming features</a></li>
- <li><a href=#requirements-for-implementations><span class=secno>14.3 </span>Requirements for implementations</a>
+ <li><a href=#warnings-for-obsolete-but-conforming-features><span class=secno>16.1.1 </span>Warnings for obsolete but conforming features</a></ol></li>
+ <li><a href=#non-conforming-features><span class=secno>16.2 </span>Non-conforming features</a></li>
+ <li><a href=#requirements-for-implementations><span class=secno>16.3 </span>Requirements for implementations</a>
<ol>
- <li><a href=#the-applet-element><span class=secno>14.3.1 </span>The <code>applet</code> element</a></li>
- <li><a href=#the-marquee-element><span class=secno>14.3.2 </span>The <code>marquee</code> element</a></li>
- <li><a href=#frames><span class=secno>14.3.3 </span>Frames</a></li>
- <li><a href=#other-elements,-attributes-and-apis><span class=secno>14.3.4 </span>Other elements, attributes and APIs</a></ol></ol></li>
- <li><a href=#iana><span class=secno>15 </span>IANA considerations</a>
+ <li><a href=#the-applet-element><span class=secno>16.3.1 </span>The <code>applet</code> element</a></li>
+ <li><a href=#the-marquee-element><span class=secno>16.3.2 </span>The <code>marquee</code> element</a></li>
+ <li><a href=#frames><span class=secno>16.3.3 </span>Frames</a></li>
+ <li><a href=#other-elements,-attributes-and-apis><span class=secno>16.3.4 </span>Other elements, attributes and APIs</a></ol></ol></li>
+ <li><a href=#iana><span class=secno>17 </span>IANA considerations</a>
<ol>
- <li><a href=#text/html><span class=secno>15.1 </span><code>text/html</code></a></li>
- <li><a href=#text/html-sandboxed><span class=secno>15.2 </span><code>text/html-sandboxed</code></a></li>
- <li><a href=#multipart/x-mixed-replace><span class=secno>15.3 </span><code>multipart/x-mixed-replace</code></a></li>
- <li><a href=#application/xhtml+xml><span class=secno>15.4 </span><code>application/xhtml+xml</code></a></li>
- <li><a href=#application/x-www-form-urlencoded><span class=secno>15.5 </span><code>application/x-www-form-urlencoded</code></a></li>
- <li><a href=#text/cache-manifest><span class=secno>15.6 </span><code>text/cache-manifest</code></a></li>
- <li><a href=#text/ping><span class=secno>15.7 </span><code>text/ping</code></a></li>
- <li><a href=#text/vtt><span class=secno>15.8 </span><code>text/vtt</code></a></li>
- <li><a href=#application/microdata+json><span class=secno>15.9 </span><code>application/microdata+json</code></a></li>
- <li><a href=#application/html-peer-connection-data><span class=secno>15.10 </span><code>application/html-peer-connection-data</code></a></li>
- <li><a href=#ping-from><span class=secno>15.11 </span><code>Ping-From</code></a></li>
- <li><a href=#ping-to><span class=secno>15.12 </span><code>Ping-To</code></a></li>
- <li><a href=#web+-scheme-prefix><span class=secno>15.13 </span><code>web+</code> scheme prefix</a></ol></li>
+ <li><a href=#text/html><span class=secno>17.1 </span><code>text/html</code></a></li>
+ <li><a href=#text/html-sandboxed><span class=secno>17.2 </span><code>text/html-sandboxed</code></a></li>
+ <li><a href=#multipart/x-mixed-replace><span class=secno>17.3 </span><code>multipart/x-mixed-replace</code></a></li>
+ <li><a href=#application/xhtml+xml><span class=secno>17.4 </span><code>application/xhtml+xml</code></a></li>
+ <li><a href=#application/x-www-form-urlencoded><span class=secno>17.5 </span><code>application/x-www-form-urlencoded</code></a></li>
+ <li><a href=#text/cache-manifest><span class=secno>17.6 </span><code>text/cache-manifest</code></a></li>
+ <li><a href=#text/ping><span class=secno>17.7 </span><code>text/ping</code></a></li>
+ <li><a href=#text/vtt><span class=secno>17.8 </span><code>text/vtt</code></a></li>
+ <li><a href=#application/microdata+json><span class=secno>17.9 </span><code>application/microdata+json</code></a></li>
+ <li><a href=#application/html-peer-connection-data><span class=secno>17.10 </span><code>application/html-peer-connection-data</code></a></li>
+ <li><a href=#ping-from><span class=secno>17.11 </span><code>Ping-From</code></a></li>
+ <li><a href=#ping-to><span class=secno>17.12 </span><code>Ping-To</code></a></li>
+ <li><a href=#web+-scheme-prefix><span class=secno>17.13 </span><code>web+</code> scheme prefix</a></ol></li>
<li><a class=no-num href=#index>Index</a>
<ol>
<li><a class=no-num href=#elements-1>Elements</a></li>
<li><a class=no-num href=#element-content-categories>Element content categories</a></li>
<li><a class=no-num href=#attributes-1>Attributes</a></li>
- <li><a class=no-num href=#interfaces>Interfaces</a></li>
- <li><a class=no-num href=#events-0>Events</a></ol></li>
+ <li><a class=no-num href=#interfaces>Interfaces</a></ol></li>
<li><a class=no-num href=#references>References</a></li>
<li><a class=no-num href=#acknowledgements>Acknowledgements</a></ol>
<!--end-toc-->
@@ -1307,19 +1397,19 @@
<p>The WHATWG work is all published in one specification
+ (the one you are reading right now),
- (known as "<a href=http://www.whatwg.org/specs/web-apps/current-work/complete/>Web Applications 1.0</a>"),
parts of which are republished in a variety of other forms,
including an edition optimized for Web developers
- (known as <a href=http://developers.whatwg.org/>HTML5</a>),
+ (known as <a href=http://developers.whatwg.org/>HTML5</a>).
- and one which focuses mainly on the core HTML language
+ <!-- and one which focuses mainly on the core HTML language -->
+ <!-- (known as the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">HTML Living Standard</a>). -->
- (which you are reading right now).
In addition, two subparts of the specification are republished as
separate documents, for ease of reference:
@@ -1331,7 +1421,6 @@
<p>The W3C also publishes parts of this specification as separate
documents. One of these parts is called "HTML5"; it is a subset of
-
this specification (the HTML Living Standard).
</p>
@@ -1350,6 +1439,7 @@
a whole reach a more mature state.</p>
-->
+
<h6 class=no-toc id=how-do-the-whatwg-and-w3c-specifications-differ?><span class=secno>1.1.1 </span>How do the WHATWG and W3C specifications differ?</h6>
<p>The features present in both the WHATWG and W3C specifications
@@ -1634,8 +1724,8 @@
<p>A separate document has been published by the W3C HTML working
- group to document the differences between this specification and the
- language described in the HTML4 specification. <a href=#refsHTMLDIFF>[HTMLDIFF]</a></p>
+ group to document the differences between the HTML specified in this
+ document and the language described in the HTML4 specification. <a href=#refsHTMLDIFF>[HTMLDIFF]</a></p>
@@ -1670,7 +1760,7 @@
<p>To avoid exposing Web authors to the complexities of
multithreading, the HTML and DOM APIs are designed such that no
script can ever detect the simultaneous execution of other
- scripts. Even with <span title=Worker>workers</span>, the intent
+ scripts. Even with <a href=#worker title=Worker>workers</a>, the intent
is that the behavior of implementations can be thought of as
completely serializing the execution of all scripts in all <a href=#browsing-context title="browsing context">browsing contexts</a>.</p>
@@ -1806,13 +1896,29 @@
section.</dd>
+ <dt><a href=#workers>Web workers</a></dt>
+ <dd>This specification defines an API for background threads in
+ JavaScript.</dd>
+
+
+
+ <dt><a href=#webstorage>Web storage</a></dt>
+
+ <dd>This specification defines a client-side storage mechanism
+ based on name-value pairs.</dd>
+
+
<!--POSTMSG-->
<dt><a href=#comms>The communication APIs</a></dt>
<dd>This section describes some mechanisms that applications
written in HTML can use to communicate with other applications from
different domains running on the same client.
+
+ It also introduces a server-push event stream mechanism, and a
+ two-way full-duplex socket protocol for scripts.
+
</dd>
<!--POSTMSG-->
@@ -3928,6 +4034,39 @@
</dd>
+
+ <dt>The WebSocket protocol</dt>
+
+ <dd>
+
+ <div data-component="WebSocket API (editor: Ian Hickson)"><!--websocket-api-->
+
+ <p>The following terms are defined in the WebSocket protocol
+ specification: <a href=#refsWSP>[WSP]</a></p>
+
+ <ul class=brief><li><dfn id="parse-a-websocket-url's-components">parse a WebSocket URL's components</dfn>
+ <li><dfn id=establish-a-websocket-connection>establish a WebSocket connection</dfn>
+ <li><dfn id=the-websocket-connection-is-established>the WebSocket connection is established</dfn>
+ <li><dfn id="validate-the-server's-response">validate the server's response</dfn>
+ <li><dfn id=extensions-in-use>extensions in use</dfn>
+ <li><dfn id=subprotocol-in-use>subprotocol in use</dfn>
+ <li><dfn id=headers-to-send-appropriate-cookies>headers to send appropriate cookies</dfn>
+ <li><dfn id="cookies-set-during-the-server's-opening-handshake">cookies set during the server's opening handshake</dfn>
+ <li><dfn id=a-websocket-message-has-been-received>a WebSocket message has been received</dfn>
+ <li><dfn id=fail-the-websocket-connection>fail the WebSocket connection</dfn>
+ <li><dfn id=close-the-websocket-connection>close the WebSocket connection</dfn>
+ <li><dfn id=start-the-websocket-closing-handshake>start the WebSocket closing handshake</dfn>
+ <li><dfn id=the-websocket-closing-handshake-is-started>the WebSocket closing handshake is started</dfn>
+ <li><dfn id=the-websocket-connection-is-closed>the WebSocket connection is closed</dfn> (possibly <i title="">cleanly</i>)
+ <li><dfn id=the-websocket-connection-close-code>the WebSocket connection close code</dfn>
+ <li><dfn id=the-websocket-connection-close-reason>the WebSocket connection close reason</dfn>
+
+ </ul></div><!--data-component-->
+
+ </dd>
+
+
+
</dl><p>This specification does not <em>require</em> support of any
particular network protocol, style sheet language, scripting
language, or any of the DOM specifications beyond those described
@@ -12701,7 +12840,7 @@
<code><a href=#window>Window</a></code>, <code><a href=#location>Location</a></code>, <code><a href=#history-0>History</a></code>,
<code><a href=#applicationcache>ApplicationCache</a></code>, and <code><a href=#navigator>Navigator</a></code>, objects,
the various <code><a href=#barprop>BarProp</a></code> objects, the two
- <code>Storage</code> objects, the various
+ <code><a href=#storage-0>Storage</a></code> objects, the various
<code><a href=#htmlcollection>HTMLCollection</a></code> objects, and objects defined by other
specifications, like <code>Selection</code> and the document's
<code>UndoManager</code>. It also includes all the Web IDL
@@ -18893,7 +19032,7 @@
<dt>Contexts in which this element can be used:</dt>
<dd>Before <code><a href=#the-dd-element>dd</a></code> or <code><a href=#the-dt-element>dt</a></code> elements inside <code><a href=#the-dl-element>dl</a></code> elements.</dd>
<dt>Content model:</dt>
- <dd><a href=#phrasing-content>Phrasing content</a>.</dd>
+ <dd><a href=#flow-content>Flow content</a>, but with no <code><a href=#the-header-element>header</a></code>, <code><a href=#the-footer-element>footer</a></code>, <a href=#sectioning-content>sectioning content</a>, or <a href=#heading-content>heading content</a> descendants.</dd>
<dt>Content attributes:</dt>
<dd><a href=#global-attributes>Global attributes</a></dd>
<dt>DOM interface:</dt>
@@ -23870,10 +24009,7 @@
<p>This flag also <a href=#sandboxCookies>prevents script from
reading from or writing to the <code title=dom-document-cookie>document.cookie</code> IDL
- attribute</a>, and blocks access to <code title=dom-localStorage>localStorage</code>.
-
- <a href=#refsWEBSTORAGE>[WEBSTORAGE]</a>
-
+ attribute</a>, and blocks access to <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code>.
</p>
<div class=note>
@@ -40258,7 +40394,8 @@
<dt>Contexts in which this element can be used:</dt>
<dd>As a child of a <code><a href=#the-tr-element>tr</a></code> element.</dd>
<dt>Content model:</dt>
- <dd><a href=#phrasing-content>Phrasing content</a>.</dd>
+ <dd><a href=#flow-content>Flow content</a>, but with no <code><a href=#the-header-element>header</a></code>, <code><a href=#the-footer-element>footer</a></code>, <a href=#sectioning-content>sectioning content</a>, or <a href=#heading-content>heading content</a> descendants.</dd>
+ <!-- EDITING NOTE: If you remove 'heading content' from the list above, make sure to fix the definition of 'sectioning root' to include <th> -->
<dt>Content attributes:</dt>
<dd><a href=#global-attributes>Global attributes</a></dd>
<dd><code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code></dd>
@@ -62557,7 +62694,7 @@
<code><a href=#document>Document</a></code>.</li>
</ol><p class=note>Whenever a <code><a href=#document>Document</a></code> object is <a href=#discard-a-document title="discard a Document">discarded</a>, it is also removed from
- the list of <span>the worker's <code><a href=#document>Document</a></code>s</span> of each
+ the list of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> of each
worker whose list contains that <code><a href=#document>Document</a></code>.</p>
<p>When <dfn id=a-browsing-context-is-discarded>a <em><span>browsing context</span></em> is
@@ -65549,17 +65686,14 @@
<ol><li>
- <p><span>Make disappear</span> any <code>WebSocket</code> objects
- that were created by the <code title=dom-WebSocket>WebSocket()</code> constructor whose global
+ <p><a href=#make-disappear>Make disappear</a> any <code><a href=#websocket>WebSocket</a></code> objects
+ that were created by the <code title=dom-WebSocket><a href=#dom-websocket>WebSocket()</a></code> constructor whose global
object is the <code><a href=#document>Document</a></code>'s <code><a href=#window>Window</a></code> object.
- <a href=#refsWEBSOCKET>[WEBSOCKET]</a>
-
-
</p>
- <p>If this affected any <code>WebSocket</code> objects, the set
+ <p>If this affected any <code><a href=#websocket>WebSocket</a></code> objects, the set
<code><a href=#document>Document</a></code>'s <var title=concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></var> state to
false.</p>
@@ -65974,23 +66108,17 @@
group">application cache groups</a> exist.</p>
<hr><p>A <dfn id=cache-host>cache host</dfn> is a <code><a href=#document>Document</a></code> or a
- <code>SharedWorkerGlobalScope</code> object. A <a href=#cache-host>cache
+ <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object. A <a href=#cache-host>cache
host</a> can be associated with an <a href=#application-cache>application
cache</a>.
-
- <a href=#refsWEBWORKERS>[WEBWORKERS]</a>
-
</p>
<p>A <code><a href=#document>Document</a></code> initially is not associated with an
<a href=#application-cache>application cache</a>, but can become associated with one
early during the page load process, when steps <a href=#parser-appcache>in the parser</a> and in the <a href=#navigate title=navigate>navigation</a> sections cause <a href=#concept-appcache-init title=concept-appcache-init>cache selection</a> to occur.</p>
- <p>A <code>SharedWorkerGlobalScope</code> can be associated with an
+ <p>A <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> can be associated with an
<a href=#application-cache>application cache</a> when it is created.
-
- <a href=#refsWEBWORKERS>[WEBWORKERS]</a>
-
</p>
<p>Each <a href=#cache-host>cache host</a> has an associated
@@ -67588,9 +67716,6 @@
<dd>
<p>(In a shared worker.) Returns the <code><a href=#applicationcache>ApplicationCache</a></code> object that applies to the current shared worker.
-
- <a href=#refsWEBWORKERS>[WEBWORKERS]</a>
-
</p>
</dd>
@@ -67665,16 +67790,13 @@
attribute on <code><a href=#window>Window</a></code> objects must return the
<code><a href=#applicationcache>ApplicationCache</a></code> object associated with the
<code><a href=#window>Window</a></code> object's <a href=#active-document>active document</a>. The <dfn id=dom-sharedworkerglobalscope-applicationcache title=dom-SharedWorkerGlobalScope-applicationCache><code>applicationCache</code></dfn>
- attribute on <code>SharedWorkerGlobalScope</code> objects must
+ attribute on <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> objects must
return the <code><a href=#applicationcache>ApplicationCache</a></code> object associated with the
worker.
-
- <a href=#refsWEBWORKERS>[WEBWORKERS]</a>
-
</p>
<p class=note>A <code><a href=#window>Window</a></code> or
- <code>SharedWorkerGlobalScope</code> object has an associated
+ <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object has an associated
<code><a href=#applicationcache>ApplicationCache</a></code> object even if that <a href=#cache-host>cache
host</a> has no actual <a href=#application-cache>application cache</a>.</p>
@@ -67841,17 +67963,17 @@
return true otherwise.</p>
<p>When the value that would be returned by the <code title=dom-navigator-onLine><a href=#dom-navigator-online>navigator.onLine</a></code> attribute of a
- <code><a href=#window>Window</a></code> or <code>WorkerGlobalScope</code> changes from
+ <code><a href=#window>Window</a></code> or <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> changes from
true to false, the user agent must <a href=#queue-a-task>queue a task</a> to
<a href=#fire-a-simple-event>fire a simple event</a> named <dfn id=event-offline title=event-offline><code>offline</code></dfn> at the
- <code><a href=#window>Window</a></code> or <code>WorkerGlobalScope</code> object.</p>
+ <code><a href=#window>Window</a></code> or <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object.</p>
<p>On the other hand, when the value that would be returned by the
<code title=dom-navigator-onLine><a href=#dom-navigator-online>navigator.onLine</a></code> attribute
- of a <code><a href=#window>Window</a></code> or <code>WorkerGlobalScope</code> changes
+ of a <code><a href=#window>Window</a></code> or <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> changes
from false to true, the user agent must <a href=#queue-a-task>queue a task</a> to
<a href=#fire-a-simple-event>fire a simple event</a> named <dfn id=event-online title=event-online><code>online</code></dfn> at the
- <code><a href=#window>Window</a></code> or <code>WorkerGlobalScope</code> object.</p>
+ <code><a href=#window>Window</a></code> or <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object.</p>
<p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#networking-task-source>networking task
source</a>.</p>
@@ -68305,11 +68427,6 @@
context</a> always has an <a href=#event-loop>event loop</a> coordinating
its activities.</p>
-
- <p class=note>Other specifications can define new kinds of event
- loops that aren't associated with browsing contexts; in particular,
- the Web Workers specification does so.</p>
-
<p>An <a href=#event-loop>event loop</a> has one or more <dfn id=task-queue title="task
queue">task queues</dfn>. A <a href=#task-queue>task queue</a> is an ordered
@@ -69116,7 +69233,7 @@
<tr><td><dfn id=handler-window-onpopstate title=handler-window-onpopstate><code>onpopstate</code></dfn> <td> <code title=event-popstate><a href=#event-popstate>popstate</a></code> <!-- new -->
<tr><td><dfn id=handler-window-onresize title=handler-window-onresize><code>onresize</code></dfn> <td> <code title=event-resize>resize</code> <!-- widely used --> <!-- [CSSOM] -->
<tr><td><dfn id=handler-window-onscroll title=handler-window-onscroll><code>onscroll</code></dfn> <td> <code title=event-scroll>scroll</code>
- <tr><td><dfn id=handler-window-onstorage title=handler-window-onstorage><code>onstorage</code></dfn> <td> <code title=event-storage>storage</code> <!-- new -->
+ <tr><td><dfn id=handler-window-onstorage title=handler-window-onstorage><code>onstorage</code></dfn> <td> <code title=event-storage><a href=#event-storage>storage</a></code> <!-- new -->
<tr><td><dfn id=handler-window-onunload title=handler-window-onunload><code>onunload</code></dfn> <td> <code title=event-unload>unload</code> <!-- widely used -->
</table><p class=note>The <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code>
handler is also used for <a href=#runtime-script-errors>reporting script errors</a>.</p>
@@ -69250,7 +69367,7 @@
</dl><div class=impl>
<p class=note>The <code><a href=#windowbase64>WindowBase64</a></code> interface adds to the
- <code><a href=#window>Window</a></code> interface and the <code>WorkerUtils</code>
+ <code><a href=#window>Window</a></code> interface and the <code><a href=#workerutils>WorkerUtils</a></code>
interface (part of Web Workers).</p>
<p>The <dfn id=dom-windowbase64-btoa title=dom-windowbase64-btoa><code>btoa()</code></dfn>
@@ -69510,11 +69627,8 @@
<div class=impl>
<p class=note>The <code><a href=#windowtimers>WindowTimers</a></code> interface adds to the
- <code><a href=#window>Window</a></code> interface and the <code>WorkerUtils</code>
+ <code><a href=#window>Window</a></code> interface and the <code><a href=#workerutils>WorkerUtils</a></code>
interface (part of Web Workers).
-
- <a href=#refsWEBWORKERS>[WEBWORKERS]</a>
-
</p>
<p>Each object that implements the <code><a href=#windowtimers>WindowTimers</a></code>
@@ -69556,7 +69670,7 @@
necessarily consecutively).</p>
<p>Otherwise, if the <a href=#method-context>method context</a> is a
- <code>WorkerUtils</code> object, wait until <var title="">timeout</var> milliseconds have passed with the worker
+ <code><a href=#workerutils>WorkerUtils</a></code> object, wait until <var title="">timeout</var> milliseconds have passed with the worker
not suspended (not necessarily consecutively).</p>
<p>Otherwise, act as described in the specification that defines
@@ -69654,7 +69768,7 @@
milliseconds (not necessarily consecutively).</p>
<p>Otherwise, if the <a href=#method-context>method context</a> is a
- <code>WorkerUtils</code> object, wait until <var title="">interval</var> milliseconds have passed with the worker
+ <code><a href=#workerutils>WorkerUtils</a></code> object, wait until <var title="">interval</var> milliseconds have passed with the worker
not suspended (not necessarily consecutively).</p>
<p>Otherwise, act as described in the specification that defines
@@ -69695,7 +69809,7 @@
<hr><p>The <dfn id=method-context>method context</dfn>, when referenced by the algorithms
in this section, is the object on which the method for which the
algorithm is running is implemented (a <code><a href=#window>Window</a></code> or
- <code>WorkerUtils</code> object).</p>
+ <code><a href=#workerutils>WorkerUtils</a></code> object).</p>
<p>When the above methods are invoked and try to <dfn id=get-the-timed-task>get the timed
task</dfn> <var title="">handle</var> in list <var title="">list</var>,
@@ -69712,7 +69826,7 @@
<p class=note>Setting <var title="">thisArg</var> to undefined
means that the function code will be executed with the <code title="">this</code> keyword bound to the <code><a href=#windowproxy>WindowProxy</a></code>
- or the <code>WorkerGlobalScope</code> object, as if the code was
+ or the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, as if the code was
running in the global scope.</p>
<p>Otherwise, continue with the remaining steps.</p>
@@ -69741,14 +69855,14 @@
a reference, not a copy</a>).</p>
<p>Otherwise, if the <a href=#method-context>method context</a> is a
- <code>WorkerUtils</code> object, let <var title="">global
+ <code><a href=#workerutils>WorkerUtils</a></code> object, let <var title="">global
object</var>, <var title="">browsing context</var>, <var title="">document</var>, <var title="">character encoding</var>,
and <var title="">base URL</var> be the <a href="#script's-global-object">script's global
object</a>, <a href="#script's-browsing-context">script's browsing context</a>,
<a href="#script's-document">script's document</a>, <a href="#script's-url-character-encoding">script's URL character
encoding</a>, and <a href="#script's-base-url">script's base URL</a> (respectively)
of the <a href=#concept-script title=concept-script>script</a> that the
- <span>run a worker</span> algorithm created when it created the
+ <a href=#run-a-worker>run a worker</a> algorithm created when it created the
<a href=#method-context>method context</a>.</p>
<p>Otherwise, act as described in the specification that defines
@@ -70919,24 +71033,18 @@
<dd>
<p>If a script uses the <code title=dom-document-cookie><a href=#dom-document-cookie>document.cookie</a></code> API, or the
- <code title=dom-localStorage>localStorage</code> API, the
+ <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> API, the
browser will block other scripts from accessing cookies or storage
until the first script finishes.
-
- <a href=#refsWEBSTORAGE>[WEBSTORAGE]</a>
-
</p>
<p>Calling the <code title=dom-navigator-yieldForStorageUpdates><a href=#dom-navigator-yieldforstorageupdates>navigator.yieldForStorageUpdates()</a></code>
method tells the user agent to unblock any other scripts that may
be blocked, even though the script hasn't returned.</p>
- <p>Values of cookies and items in the <code>Storage</code> objects
- of <code title=dom-localStorage>localStorage</code> attributes
+ <p>Values of cookies and items in the <code><a href=#storage-0>Storage</a></code> objects
+ of <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attributes
can change after calling this method, whence its name.
-
- <a href=#refsWEBSTORAGE>[WEBSTORAGE]</a>
-
</p>
</dd>
@@ -75864,7 +75972,7 @@
first have an indirect communications channel, known as the
<i>signaling channel</i>, via which messages can be exchanged with
the other peer. Typically, this will take the form of
- <code>XMLHttpRequest</code>-based or <code>WebSocket</code>-based
+ <code>XMLHttpRequest</code>-based or <code><a href=#websocket>WebSocket</a></code>-based
communication through the server: messages are sent to the server
with a session identifier, and the server then routes them to the
other peer using the same session. The precise details of this
@@ -77024,23 +77132,2331 @@
</table></div>
<!--PEERCONNECTION-->
+
+
+
+
+
+
+
+ <div data-component="Web Workers (editor: Ian Hickson)">
+
+ <h2 id=workers><span class=secno>10 </span>Web workers</h2>
+
+
+
+
+ <h3 id=introduction-13><span class=secno>10.1 </span>Introduction</h3>
+
+ <h4 id=scope-0><span class=secno>10.1.1 </span>Scope</h4>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>This specification defines an API for running scripts in the
+ background independently of any user interface scripts.</p>
+
+ <p>This allows for long-running scripts that are not interrupted by
+ scripts that respond to clicks or other user interactions, and
+ allows long tasks to be executed without yielding to keep the page
+ responsive.</p>
+
+ <p>Workers (as these background scripts are called herein) are
+ relatively heavy-weight, and are not intended to be used in large
+ numbers. For example, it would be inappropriate to launch one worker
+ for each pixel of a four megapixel image. The examples below show
+ some appropriate uses of workers.</p>
+
+ <p>Generally, workers are expected to be long-lived, have a high
+ start-up performance cost, and a high per-instance memory cost.</p>
+
+
+ <h4 id=examples-4><span class=secno>10.1.2 </span>Examples</h4>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>There are a variety of uses that workers can be put to. The
+ following subsections show various examples of this use.</p>
+
+ <h5 id=a-background-number-crunching-worker><span class=secno>10.1.2.1 </span>A background number-crunching worker</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>The simplest use of workers is for performing a computationally
+ expensive task without interrupting the user interface.</p>
+
+ <p>In this example, the main document spawns a worker to
+ (naïvely) compute prime numbers, and progressively displays the
+ most recently found prime number.</p>
+
+ <p>The main page is as follows:</p>
+
+ <pre><!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Worker example: One-core computation</title>
+ </head>
+ <body>
+ <p>The highest prime number discovered so far is: <output id="result"></output></p>
+ <script>
+ var worker = new Worker('worker.js');
+ worker.onmessage = function (event) {
+ document.getElementById('result').textContent = event.data;
+ };
+ </script>
+ </body>
+</html></pre>
+
+ <p>The <code title=dom-Worker><a href=#dom-worker>Worker()</a></code> constructor call
+ creates a worker and returns a <code><a href=#worker>Worker</a></code> object
+ representing that worker, which is used to communicate with the
+ worker. That object's <code title=handler-Worker-onmessage><a href=#handler-worker-onmessage>onmessage</a></code> event handler allows the code to receive messages from the worker.</p>
+
+ <p>The worker itself is as follows:</p>
+
+ <pre>var n = 1;
+search: while (true) {
+ n += 1;
+ for (var i = 2; i <= Math.sqrt(n); i += 1)
+ if (n % i == 0)
+ continue search;
+ // found a prime!
+ postMessage(n);
+}</pre>
+
+ <p>The bulk of this code is simply an unoptimized search for a prime
+ number. The <code title=dom-DedicatedWorkerGlobalScope-postMessage><a href=#dom-dedicatedworkerglobalscope-postmessage>postMessage()</a></code>
+ method is used to send a message back to the page when a prime is
+ found.</p>
+
+ <p><a href=http://www.whatwg.org/demos/workers/primes/page.html>View this example online</a>.</p>
+
+
+
+ <h5 id=a-worker-for-updating-a-client-side-database><span class=secno>10.1.2.2 </span>A worker for updating a client-side database</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>In this example, the main document spawns a worker whose only
+ task is to listen for notifications from the server, and, when
+ appropriate, either add or remove data from the client-side
+ database.</p>
+
+ <p>Since no communication occurs between the worker and the main
+ page, the main page can start the worker by just doing:</p>
+
+ <pre><script>
+ new Worker('worker.js');
+</script></pre>
+
+ <p>The worker itself is as follows:</p>
+
+ <pre>var server = new WebSocket('ws://whatwg.org/database');
+var database = openDatabase('demobase', '1.0', 'Demo Database', 10240);
+server.onmessage = function (event) {
+ // data is in the format "command key value"
+ var data = event.data.split(' ');
+ switch (data[0]) {
+ case '+':
+ database.transaction(function(tx) {
+ tx.executeSql('INSERT INTO pairs (key, value) VALUES (?, ?)', data[1], data[2]);
+ });
+ case '-':
+ database.transaction(function(tx) {
+ tx.executeSql('DELETE FROM pairs WHERE key=? AND value=?', data[1], data[2]);
+ });
+ }
+};</pre>
+
+ <p>This connects to the server using the <code><a href=#websocket>WebSocket</a></code>
+ mechanism and opens the local database (which, we presume, has been
+ created earlier). The worker then just listens for messages from the
+ server and acts on them as appropriate, forever (or until the main
+ page is closed).</p>
+
+ <p><a href=http://www.whatwg.org/demos/workers/database-updater/page.html>View
+ this example online</a>. (This example will not actually function,
+ since the server does not actually exist and the database is not
+ created by this sample code.)</p>
+
+
+
+ <h5 id=worker-used-for-background-i/o><span class=secno>10.1.2.3 </span>Worker used for background I/O</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>In this example, the main document uses two workers, one for
+ fetching stock updates for at regular intervals, and one for
+ fetching performing search queries that the user requests.</p>
+
+ <p>The main page is as follows:</p>
+
+ <pre><!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Worker example: Stock ticker</title>
+ <script>
+ // TICKER
+ var symbol = 'GOOG'; // default symbol to watch
+ var ticker = new Worker('ticker.js');
+
+ // SEARCHER
+ var searcher = new Worker('searcher.js');
+ function search(query) {
+ searcher.postMessage(query);
+ }
+
+ // SYMBOL SELECTION UI
+ function select(newSymbol) {
+ symbol = newSymbol;
+ ticker.postMessage(symbol);
+ }
+ </script>
+ </head>
+ <body onload="search('')">
+ <p><output id="symbol"></output> <output id="value"></output></p>
+ <script>
+ ticker.onmessage = function (event) {
+ var data = event.data.split(' ');
+ document.getElementById('symbol').textContent = data[0];
+ document.getElementById('value').textContent = data[1];
+ };
+ ticker.postMessage(symbol);
+ </script>
+ <p><label>Search: <input type="text" autofocus oninput="search(this.value)"></label></p>
+ <ul id="results"></ul>
+ <script>
+ searcher.onmessage = function (event) {
+ var data = event.data.split(' ');
+ var results = document.getElementById('results');
+ while (results.hasChildNodes()) // clear previous results
+ results.removeChild(results.firstChild);
+ for (var i = 0; i < data.length; i += 1) {
+ // add a list item with a button for each result
+ var li = document.createElement('li');
+ var button = document.createElement('button');
+ button.value = data[i];
+ button.type = 'button';
+ button.onclick = function () { select(this.value); };
+ button.textContent = data[i];
+ li.appendChild(button);
+ results.appendChild(li);
+ }
+ };
+ </script>
+ <p>(The data in this example is not real. Try searching for "Google" or "Apple".)</p>
+ </body>
+</html></pre>
+
+ <p>The two workers use a common library for performing the actual
+ network calls. This library is as follows:</p>
+
+ <pre>function get(url) {
+ try {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, false);
+ xhr.send();
+ return xhr.responseText;
+ } catch (e) {
+ return ''; // turn all errors into empty results
+ }
+}</pre>
+
+ <p>The stock updater worker is as follows:</p>
+
+ <pre>importScripts('io.js');
+var timer;
+var symbol;
+function update() {
+ postMessage(symbol + ' ' + get('stock.cgi?' + symbol));
+ timer = setTimeout(update, 10000);
+}
+onmessage = function (event) {
+ if (timer)
+ clearTimeout(timer);
+ symbol = event.data;
+ update();
+};</pre>
+
+ <p>The search query worker is as follows:</p>
+
+ <pre>importScripts('io.js');
+onmessage = function (event) {
+ postMessage(get('search.cgi?' + event.data));
+};</pre>
+
+ <p><a href=http://www.whatwg.org/demos/workers/stocks/page.html>View this example online</a>.</p>
+
+
+ <h5 id=shared-workers-introduction><span class=secno>10.1.2.4 </span>Shared workers introduction</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>This section introduces shared workers using a Hello World
+ example. Shared workers use slightly different APIs, since each
+ worker can have multiple connections.</p>
+
+ <p>This first example shows how you connect to a worker and how a
+ worker can send a message back to the page when it connects to
+ it. Received messages are displayed in a log.</p>
+
+ <p>Here is the HTML page:</p>
+
+ <pre><!DOCTYPE HTML>
+<title>Shared workers: demo 1</title>
+<pre id="log">Log:</pre>
+<script>
+ var worker = new SharedWorker('test.js');
+ var log = document.getElementById('log');
+ worker.port.onmessage = function(e) { // note: not worker.onmessage!
+ log.textContent += '\n' + e.data;
+ }
+</script>
+</pre>
+
+ <p>Here is the JavaScript worker:</p>
+
+ <pre>onconnect = function(e) {
+ var port = e.ports[0];
+ port.postMessage('Hello World!');
+}
+</pre>
+
+ <p><a href=http://www.whatwg.org/demos/workers/shared/001/test.html>View this example online</a>.</p>
+
+ <hr><p>This second example extends the first one by changing two things:
+ first, messages are received using <code title="">addEventListener()</code> instead of an <a href=#event-handler-idl-attributes title="event
+ handler IDL attributes">event handler IDL attribute</a>, and
+ second, a message is sent <em>to</em> the worker, causing the worker
+ to send another message in return. Received messages are again
+ displayed in a log.</p>
+
+ <p>Here is the HTML page:</p>
+
+ <pre><!DOCTYPE HTML>
+<title>Shared workers: demo 2</title>
+<pre id="log">Log:</pre>
+<script>
+ var worker = new SharedWorker('test.js');
+ var log = document.getElementById('log');
+ worker.port.addEventListener('message', function(e) {
+ log.textContent += '\n' + e.data;
+ }, false);
+ worker.port.start(); // note: need this when using addEventListener
+ worker.port.postMessage('ping');
+</script>
+</pre>
+
+ <p>Here is the JavaScript worker:</p>
+
+ <pre>onconnect = function(e) {
+ var port = e.ports[0];
+ port.postMessage('Hello World!');
+ port.onmessage = function(e) {
+ port.postMessage('pong'); // not e.ports[0].postMessage!
+ // e.target.postMessage('pong'); would work also
+ }
+}
+</pre>
+
+ <p><a href=http://www.whatwg.org/demos/workers/shared/002/test.html>View this example online</a>.</p>
+
+ <hr><p>Finally, the example is extended to show how two pages can
+ connect to the same worker; in this case, the second page is merely
+ in an <code><a href=#the-iframe-element>iframe</a></code> on the first page, but the same principle
+ would apply to an entirely separate page in a separate
+ <a href=#top-level-browsing-context>top-level browsing context</a>.</p>
+
+ <p>Here is the outer HTML page:</p>
+
+ <pre><!DOCTYPE HTML>
+<title>Shared workers: demo 3</title>
+<pre id="log">Log:</pre>
+<script>
+ var worker = new SharedWorker('test.js');
+ var log = document.getElementById('log');
+ worker.port.addEventListener('message', function(e) {
+ log.textContent += '\n' + e.data;
+ }, false);
+ worker.port.start();
+ worker.port.postMessage('ping');
+</script>
+<iframe src="inner.html"></iframe>
+</pre>
+
+ <p>Here is the inner HTML page:</p>
+
+ <pre><!DOCTYPE HTML>
+<title>Shared workers: demo 3 inner frame</title>
+<pre id=log>Inner log:</pre>
+<script>
+ var worker = new SharedWorker('test.js');
+ var log = document.getElementById('log');
+ worker.port.onmessage = function(e) {
+ log.textContent += '\n' + e.data;
+ }
+</script>
+</pre>
+
+ <p>Here is the JavaScript worker:</p>
+
+ <pre>var count = 0;
+onconnect = function(e) {
+ count += 1;
+ var port = e.ports[0];
+ port.postMessage('Hello World! You are connection #' + count);
+ port.onmessage = function(e) {
+ port.postMessage('pong');
+ }
+}
+</pre>
+
+ <p><a href=http://www.whatwg.org/demos/workers/shared/003/test.html>View this example online</a>.</p>
+
+
+ <h5 id=shared-state-using-a-shared-worker><span class=secno>10.1.2.5 </span>Shared state using a shared worker</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>In this example, multiple windows (viewers) can be opened that
+ are all viewing the same map. All the windows share the same map
+ information, with a single worker coordinating all the viewers. Each
+ viewer can move around independently, but if they set any data on
+ the map, all the viewers are updated.</p>
+
+ <p>The main page isn't interesting, it merely provides a way to open
+ the viewers:</p>
+
+ <pre><!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Workers example: Multiviewer</title>
+ <script>
+ function openViewer() {
+ window.open('viewer.html');
+ }
+ </script>
+ </head>
+ <body>
+ <p><button type=button onclick="openViewer()">Open a new
+ viewer</button></p>
+ <p>Each viewer opens in a new window. You can have as many viewers
+ as you like, they all view the same data.</p>
+ </body>
+</html></pre>
+
+ <p>The viewer is more involved:</p>
+
+ <pre><!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Workers example: Multiviewer viewer</title>
+ <script>
+ var worker = new SharedWorker('worker.js', 'core');
+
+ // CONFIGURATION
+ function configure(event) {
+ if (event.data.substr(0, 4) != 'cfg ') return;
+ var name = event.data.substr(4).split(' ', 1);
+ // update display to mention our name is name
+ document.getElementsByTagName('h1')[0].textContent += ' ' + name;
+ // no longer need this listener
+ worker.port.removeEventListener('message', configure, false);
+ }
+ worker.port.addEventListener('message', configure, false);
+
+ // MAP
+ function paintMap(event) {
+ if (event.data.substr(0, 4) != 'map ') return;
+ var data = event.data.substr(4).split(',');
+ // display tiles data[0] .. data[8]
+ var canvas = document.getElementById('map');
+ var context = canvas.getContext('2d');
+ for (var y = 0; y < 3; y += 1) {
+ for (var x = 0; x < 3; x += 1) {
+ var tile = data[y * 3 + x];
+ if (tile == '0')
+ context.fillStyle = 'green';
+ else
+ context.fillStyle = 'maroon';
+ fillRect(x * 50, y * 50, 50, 50);
+ }
+ }
+ }
+ worker.port.addEventListener('message', paintMap, false);
+
+ // PUBLIC CHAT
+ function updatePublicChat(event) {
+ if (event.data.substr(0, 4) != 'txt ') return;
+ var name = event.data.substr(4).split(' ', 1);
+ var message = event.data.substr(4 + length(name) + 1);
+ // display "<name> message" in public chat
+ var dialog = document.getElementById('public');
+ var dt = document.createElement('dt');
+ dt.textContent = name;
+ dialog.appendChild(dt);
+ var dd = document.createElement('dd');
+ dd.textContent = message;
+ dialog.appendChild(dd);
+ }
+ worker.port.addEventListener('message', updatePublicChat, false);
+
+ // PRIVATE CHAT
+ function startPrivateChat(event) {
+ if (event.data.substr(0, 4) != 'msg ') return;
+ var name = event.data.substr(4).split(' ', 1);
+ var port = event.ports[0];
+ // display a private chat UI
+ var ul = document.getElementById('private');
+ var li = document.createElement('li');
+ var h3 = document.createElement('h3');
+ h3.textContent = 'Private chat with ' + name;
+ li.appendChild(h3);
+ var dialog = document.createElement('dialog');
+ var addMessage = function(name, message) {
+ var dt = document.createElement('dt');
+ dt.textContent = name;
+ dialog.appendChild(dt);
+ var dd = document.createElement('dd');
+ dd.textContent = message;
+ dialog.appendChild(dd);
+ };
+ port.onmessage = function (event) {
+ addMessage(name, event.data);
+ };
+ li.appendChild(dialog);
+ var form = document.createElement('form');
+ var p = document.createElement('p');
+ var input = document.createElement('input');
+ input.size = 50;
+ p.appendChild(input);
+ p.appendChild(document.createTextNode(' '));
+ var button = document.createElement('button');
+ button.textContent = 'Post';
+ p.appendChild(button);
+ form.onsubmit = function () {
+ port.postMessage(input.value);
+ addMessage('me', input.value);
+ input.value = '';
+ return false;
+ };
+ form.appendChild(p);
+ li.appendChild(form);
+ }
+ worker.port.addEventListener('message', startPrivateChat, false);
+
+ worker.port.start();
+ </script>
+ </head>
+ <body>
+ <h1>Viewer</h1>
+ <h2>Map</h2>
+ <p><canvas id="map" height=150 width=150></canvas></p>
+ <p>
+ <button type=button onclick="worker.port.postMessage('mov left')">Left</button>
+ <button type=button onclick="worker.port.postMessage('mov up')">Up</button>
+ <button type=button onclick="worker.port.postMessage('mov down')">Down</button>
+ <button type=button onclick="worker.port.postMessage('mov right')">Right</button>
+ <button type=button onclick="worker.port.postMessage('set 0')">Set 0</button>
+ <button type=button onclick="worker.port.postMessage('set 1')">Set 1</button>
+ </p>
+ <h2>Public Chat</h2>
+ <dialog id="public"></dialog>
+ <form onsubmit="worker.port.postMessage('txt ' + message.value); message.value = ''; return false;">
+ <p>
+ <input type="text" name="message" size="50">
+ <button>Post</button>
+ </p>
+ </form>
+ <h2>Private Chat</h2>
+ <ul id="private"></ul>
+ </body>
+</html>
+</pre>
+
+ <p>There are several key things worth noting about the way the
+ viewer is written.</p>
+
+ <p><strong>Multiple listeners</strong>. Instead of a single message
+ processing function, the code here attaches multiple event
+ listeners, each one performing a quick check to see if it is
+ relevant for the message. In this example it doesn't make much
+ difference, but if multiple authors wanted to collaborate using a
+ single port to communicate with a worker, it would allow for
+ independent code instead of changes having to all be made to a
+ single event handling function.</p>
+
+ <p>Registering event listeners in this way also allows you to
+ unregister specific listeners when you are done with them, as is
+ done with the <code title="">configure()</code> method in this
+ example.</p>
+
+ <p>Finally, the worker:</p>
+
+ <pre>
+var nextName = 0;
+function getNextName() {
+ // this could use more friendly names
+ // but for now just return a number
+ return nextName++;
+}
+
+var map = [
+ [0, 0, 0, 0, 0, 0, 0],
+ [1, 1, 0, 1, 0, 1, 1],
+ [0, 1, 0, 1, 0, 0, 0],
+ [0, 1, 0, 1, 0, 1, 1],
+ [0, 0, 0, 1, 0, 0, 0],
+ [1, 0, 0, 1, 1, 1, 1],
+ [1, 1, 0, 1, 1, 0, 1],
+];
+
+function wrapX(x) {
+ if (x < 0) return wrapX(x + map[0].length);
+ if (x >= map[0].length) return wrapX(x - map[0].length);
+ return x;
+}
+
+function wrapY(y) {
+ if (y < 0) return wrapY(y + map.length);
+ if (y >= map[0].length) return wrapY(y - map.length);
+ return y;
+}
+
+function sendMapData(callback) {
+ var data = '';
+ for (var y = viewer.y-1; y <= viewer.y+1; y += 1) {
+ for (var x = viewer.x-1; x <= viewer.x+1; x += 1) {
+ if (data != '')
+ data += ',';
+ data += map[y][x];
+ }
+ }
+ callback('map ' + data);
+}
+
+var viewers = {};
+onconnect = function (event) {
+ event.ports[0]._name = getNextName();
+ event.ports[0]._data = { port: event.port, x: 0, y: 0, };
+ viewers[event.ports[0]._name] = event.port._data;
+ event.ports[0].postMessage('cfg ' + name);
+ event.ports[0].onmessage = getMessage;
+ sendMapData(event.ports[0].postMessage);
+};
+
+function getMessage(event) {
+ switch (event.data.substr(0, 4)) {
+ case 'mov ':
+ var direction = event.data.substr(4);
+ var dx = 0;
+ var dy = 0;
+ switch (direction) {
+ case 'up': dy = -1; break;
+ case 'down': dy = 1; break;
+ case 'left': dx = -1; break;
+ case 'right': dx = 1; break;
+ }
+ event.target._data.x = wrapX(event.target._data.x + dx);
+ event.target._data.y = wrapY(event.target._data.y + dy);
+ sendMapData(event.target.postMessage);
+ break;
+ case 'set ':
+ var value = event.data.substr(4);
+ map[event.target._data.y][event.target._data.x] = value;
+ for (var viewer in viewers)
+ sendMapData(viewers[viewer].port.postMessage);
+ break;
+ case 'txt ':
+ var name = event.target._name;
+ var message = event.data.substr(4);
+ for (var viewer in viewers)
+ viewers[viewer].port.postMessage('txt ' + name + ' ' + message);
+ break;
+ case 'msg ':
+ var party1 = event._data;
+ var party2 = viewers[event.data.substr(4).split(' ', 1)];
+ if (party2) {
+ var channel = new MessageChannel();
+ party1.port.postMessage('msg ' + party2.name, [channel.port1]);
+ party2.port.postMessage('msg ' + party1.name, [channel.port2]);
+ }
+ break;
+ }
+}</pre>
+
+ <p><strong>Connecting to multiple pages</strong>. The script uses
+ the <code title=handler-SharedWorkerGlobalScope-onconnect><a href=#handler-sharedworkerglobalscope-onconnect>onconnect</a></code>
+ event listener to listen for multiple connections.</p>
+
+ <p><strong>Direct channels</strong>. When the worker receives a
+ "msg" message from one viewer naming another viewer, it sets up a
+ direct connection between the two, so that the two viewers can
+ communicate directly without the worker having to proxy all the
+ messages.</p>
+
+ <p><a href=http://www.whatwg.org/demos/workers/multiviewer/page.html>View this example online</a>.</p>
+
+
+ <h5 id=delegation><span class=secno>10.1.2.6 </span>Delegation</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>With multicore CPUs becoming prevalent, one way to obtain better
+ performance is to split computationally expensive tasks amongst
+ multiple workers. In this example, a computationally expensive task
+ that is to be performed for every number from 1 to 10,000,000 is
+ farmed out to ten subworkers.</p>
+
+ <p>The main page is as follows, it just reports the result:</p>
+
+ <pre><!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Worker example: Multicore computation</title>
+ </head>
+ <body>
+ <p>Result: <output id="result"></output></p>
+ <script>
+ var worker = new Worker('worker.js');
+ worker.onmessage = function (event) {
+ document.getElementById('result').textContent = event.data;
+ };
+ </script>
+ </body>
+</html></pre>
+
+ <p>The worker itself is as follows:</p>
+
+ <pre>// settings
+var num_workers = 10;
+var items_per_worker = 1000000;
+
+// start the workers
+var result = 0;
+var pending_workers = num_workers;
+for (var i = 0; i < num_workers; i += 1) {
+ var worker = new Worker('core.js');
+ worker.postMessage(i * items_per_worker);
+ worker.postMessage((i+1) * items_per_worker);
+ worker.onmessage = storeResult;
+}
+
+// handle the results
+function storeResult(event) {
+ result += 1*event.data;
+ pending_workers -= 1;
+ if (pending_workers <= 0)
+ postMessage(result); // finished!
+}</pre>
+
+ <p>It consists of a loop to start the subworkers, and then a handler
+ that waits for all the subworkers to respond.</p>
+
+ <p>The subworkers are implemented as follows:</p>
+
+ <pre>var start;
+onmessage = getStart;
+function getStart(event) {
+ start = 1*event.data;
+ onmessage = getEnd;
+}
+
+var end;
+function getEnd(event) {
+ end = 1*event.data;
+ onmessage = null;
+ work();
+}
+
+function work() {
+ var result = 0;
+ for (var i = start; i < end; i += 1) {
+ // perform some complex calculation here
+ result += 1;
+ }
+ postMessage(result);
+ close();
+}</pre>
+
+ <p>They receive two numbers in two events, perform the computation
+ for the range of numbers thus specified, and then report the result
+ back to the parent.</p>
+
+ <p><a href=http://www.whatwg.org/demos/workers/multicore/page.html>View this example online</a>.</p>
+
+<!--(this uses startConversation, which is currently commented out)
+
+ <h5>Providing libraries</h5>
+
+ <!- -END dev-html- -><p><i>This section is non-normative.</i></p><!- -START dev-html- ->
+
+ <p>Suppose that a cryptography library is made available that
+ provides three tasks:</p>
+
+ <dl>
+
+ <dt>Generate a public/private key pair</dt>
+
+ <dd>Takes a port, on which it will send two messages, first the
+ public key and then the private key.</dd>
+
+ <dt>Given a plaintext and a public key, return the corresponding cyphertext</dt>
+
+ <dd>Takes a port, to which any number of messages can be sent, the
+ first giving the public key, and the remainder giving the
+ plaintext, each of which is encrypted and then sent on that same
+ channel as the cyphertext. The user can close the port when it is
+ done encrypting content.</dd>
+
+ <dt>Given a cyphertext and a private key, return the corresponding plaintext</dt>
+
+ <dd>Takes a port, to which any number of messages can be sent, the
+ first giving the private key, and the remainder giving the
+ cyphertext, each of which is decrypted and then sent on that same
+ channel as the plaintext. The user can close the port when it is
+ done decrypting content.</dd>
+
+ </dl>
+
+ <p>The library itself is as follows:</p>
+
+ <pre>function handleMessage(e) {
+ if (e.data == "genkeys")
+ genkeys(e.ports[0]);
+ else if (e.data == "encrypt")
+ encrypt(e.ports[0]);
+ else if (e.data == "decrypt")
+ decrypt(e.ports[0]);
+}
+
+function genkeys(p) {
+ var keys = _generateKeyPair();
+ p.postMessage(keys[0]);
+ p.postMessage(keys[1]);
+}
+
+function encrypt(p) {
+ var key, state = 0;
+ p.onmessage = function (e) {
+ if (state == 0) {
+ key = e.data;
+ state = 1;
+ } else {
+ p.postMessage(_encrypt(key, e.data));
+ }
+ };
+}
+
+function decrypt(p) {
+ var key, state = 0;
+ p.onmessage = function (e) {
+ if (state == 0) {
+ key = e.data;
+ state = 1;
+ } else {
+ p.postMessage(_decrypt(key, e.data));
+ }
+ };
+}
+
+// support being used as a shared worker as well as a dedicated worker
+if ('onmessage' in this) // dedicated worker
+ onmessage = handleMessage;
+else // shared worker
+ onconnect = function (e) { e.port.onmessage = handleMessage; }
+
+
+// the "crypto" functions:
+
+function _generateKeyPair() {
+ return [Math.random(), Math.random()];
+}
+
+function _encrypt(k, s) {
+ return 'encrypted-' + k + ' ' + s;
+}
+
+function _decrypt(k, s) {
+ return s.substr(s.indexOf(' ')+1);
+}</pre>
+
+ <p>Note that the crypto functions here are just stubs and don't do
+ real cryptography.</p>
+
+ <p>This library could be used as follows:</p>
+
+ <pre><!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Worker example: Crypto library</title>
+ <script>
+ var cryptoLib = new Worker('libcrypto-v1.js'); // or could use 'libcrypto-v2.js'
+ function getKeys() {
+ var state = 0;
+ cryptoLib.startConversation("genkeys").onmessage = function (e) {
+ if (state == 0)
+ document.getElementById('public').value = e.data;
+ else if (state == 1)
+ document.getElementById('private').value = e.data;
+ state += 1;
+ };
+ }
+ function enc() {
+ var port = cryptoLib.startConversation("encrypt");
+ port.postMessage(document.getElementById('public').value);
+ port.postMessage(document.getElementById('input').value);
+ port.onmessage = function (e) {
+ document.getElementById('input').value = e.data;
+ port.close();
+ };
+ }
+ function dec() {
+ var port = cryptoLib.startConversation("decrypt");
+ port.postMessage(document.getElementById('private').value);
+ port.postMessage(document.getElementById('input').value);
+ port.onmessage = function (e) {
+ document.getElementById('input').value = e.data;
+ port.close();
+ };
+ }
+ </script>
+ <style>
+ textarea { display: block; }
+ </style>
+ </head>
+ <body onload="getKeys()">
+ <fieldset>
+ <legend>Keys</legend>
+ <p><label>Public Key: <textarea id="public"></textarea></label></p>
+ <p><label>Private Key: <textarea id="private"></textarea></label></p>
+ </fieldset>
+ <p><label>Input: <textarea id="input"></textarea></label></p>
+ <p><button onclick="enc()">Encrypt</button> <button onclick="dec()">Decrypt</button></p>
+ </body>
+</html></pre>
+
+ <p>A later version of the API, though, might want to offload all the
+ crypto work onto subworkers. This could be done as follows:</p>
+
+ <pre>function handleMessage(e) {
+ if (e.data == "genkeys")
+ genkeys(e.ports[0]);
+ else if (e.data == "encrypt")
+ encrypt(e.ports[0]);
+ else if (e.data == "decrypt")
+ decrypt(e.ports[0]);
+}
+
+function genkeys(p) {
+ var generator = new Worker('libcrypto-v2-generator.js');
+ generator.postMessage('', [p]);
+}
+
+function encrypt(p) {
+ p.onmessage = function (e) {
+ var key = e.data;
+ var encryptor = new Worker('libcrypto-v2-encryptor.js');
+ encryptor.postMessage(key, [p]);
+ };
+}
+
+function encrypt(p) {
+ p.onmessage = function (e) {
+ var key = e.data;
+ var decryptor = new Worker('libcrypto-v2-decryptor.js');
+ decryptor.postMessage(key, [p]);
+ };
+}
+
+// support being used as a shared worker as well as a dedicated worker
+if ('onmessage' in this) // dedicated worker
+ onmessage = handleMessage;
+else // shared worker
+ onconnect = function (e) { e.ports[0].onmessage = handleMessage };
+</pre>
+
+ <p>The little subworkers would then be as follows.</p>
+
+ <p>For generating key pairs:</p>
+
+ <pre>onmessage = function (e) {
+ var k = _generateKeyPair();
+ e.ports[0].postMessage(k[0]);
+ e.ports[0].postMessage(k[1]);
+ close();
+}
+
+function _generateKeyPair() {
+ return [Math.random(), Math.random()];
+}</pre>
+
+ <p>For encrypting:</p>
+
+ <pre>onmessage = function (e) {
+ var key = e.data;
+ e.ports[0].onmessage = function (e) {
+ var s = e.data;
+ postMessage(_encrypt(key, s));
+ }
+}
+
+function _encrypt(k, s) {
+ return 'encrypted-' + k + ' ' + s;
+}</pre>
+
+ <p>For decrypting:</p>
+
+ <pre>onmessage = function (e) {
+ var key = e.data;
+ e.ports[0].onmessage = function (e) {
+ var s = e.data;
+ postMessage(_decrypt(key, s));
+ }
+}
+
+function _decrypt(k, s) {
+ return s.substr(s.indexOf(' ')+1);
+}</pre>
+
+ <p>Notice how the users of the API don't have to even know that this
+ is happening — the API hasn't changed; the library can
+ delegate to subworkers without changing its API, even though it is
+ accepting data using message channels.</p>
+
+ <p><a href="http://www.whatwg.org/demos/workers/crypto/page.html">View this example online</a>.</p>
+
+(end startConversation block) (beware nested comments)-->
+
+
+ <h4 id=tutorials><span class=secno>10.1.3 </span>Tutorials</h4>
+
+ <h5 id=creating-a-dedicated-worker><span class=secno>10.1.3.1 </span>Creating a dedicated worker</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>Creating a worker requires a URL to a JavaScript file. The <code title=dom-Worker><a href=#dom-worker>Worker()</a></code> constructor is invoked with the
+ URL to that file as its only argument; a worker is then created and
+ returned:</p>
+
+ <pre>var worker = new Worker('helper.js');</pre>
+
+
+ <h5 id=communicating-with-a-dedicated-worker><span class=secno>10.1.3.2 </span>Communicating with a dedicated worker</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>Dedicated workers use <code><a href=#messageport>MessagePort</a></code> objects behind the
+ scenes, and thus support all the same features, such as sending
+ structured data, transferring binary data, and transferring other
+ ports.</p>
+
+ <p>To receive messages from a dedicated worker, use the <code title=handler-worker-onmessage><a href=#handler-worker-onmessage>onmessage</a></code> <a href=#event-handler-idl-attributes title="event
+ handler IDL attributes">event handler IDL attribute</a> on the
+ <code><a href=#worker>Worker</a></code> object:</p>
+
+ <pre>worker.onmessage = function (event) { ... };</pre>
+
+ <p>You can also use the <code title=dom-EventTarget-addEventListener>addEventListener()</code> method.</p>
+
+ <p class=note>The implicit <code><a href=#messageport>MessagePort</a></code> used by
+ dedicated workers has its <a href=#port-message-queue>port message queue</a> implicitly
+ enabled when it is created, so there is no equivanet to the
+ <code><a href=#messageport>MessagePort</a></code> interface's <code title=dom-MessagePort-start><a href=#dom-messageport-start>start()</a></code> method on the
+ <code><a href=#worker>Worker</a></code> interface.</p>
+
+ <p>To <em>send</em> data to a worker, use the <code title=dom-Worker-postMessage><a href=#dom-worker-postmessage>postMessage()</a></code> method.
+ Structured data can be sent over this communication channel. To send
+ <code><a href=#arraybuffer>ArrayBuffer</a></code> objects efficiently (by transferring them
+ rather than cloning them), list them in an array in the second
+ argument.</p>
+
+ <pre>worker.postMessage({
+ operation: 'find-edges',
+ input: buffer, // an ArrayBuffer object
+ threshold: 0.6,
+}, [buffer]);</pre>
+
+ <p>To receive a message inside the worker, the <code title=handler-DedicatedWorkerGlobalScope-onmessage><a href=#handler-dedicatedworkerglobalscope-onmessage>onmessage</a></code>
+ <a href=#event-handler-idl-attributes title="event handler IDL attributes">event handler IDL
+ attribute</a> is used.</p>
+
+ <pre>onmessage = function (event) { ... };</pre>
+
+ <p>You can again also use the <code title=dom-EventTarget-addEventListener>addEventListener()</code>
+ method.</p>
+
+ <p>In either case, the data is provided in the event object's <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute.</p>
+
+ <p>To send messages back, you again use <code title=dom-DedicatedWorkerGlobalScope-postMessage><a href=#dom-dedicatedworkerglobalscope-postmessage>postMessage()</a></code>.
+ It supports the structured data in the same manner.</p>
+
+ <pre>postMessage(event.data.input, [event.data.input]); // transfer the buffer back</pre>
+
+
+ <h5 id=shared-workers><span class=secno>10.1.3.3 </span>Shared workers</h5>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>Shared workers are identified in one of two ways: either by the
+ URL of the script used to create it, or by explicit name. When
+ created by name, the URL used by the first page to create the worker
+ with that name is the URL of the script that will be used for that
+ worker. This allows multiple applications on a domain to all use a
+ single shared worker to provide a common service, without the
+ applications having to keep track of a common URL for the script
+ used to provide the service.</p>
+
+ <p class=note>In either case, shared workers are scoped by
+ <a href=#origin>origin</a>. Two different sites using the same names will
+ not collide.</p>
+
+ <p>Creating shared workers is done using the <code title=dom-SharedWorker><a href=#dom-sharedworker>SharedWorker()</a></code> constructor. This
+ constructor takes the URL to the script to use for its first
+ argument, and the name of the worker, if any, as the second
+ argument.</p>
+
+ <pre>var worker = new SharedWorker('service.js');</pre>
+
+ <p>Communicating with shared workers is done with explicit
+ <code><a href=#messageport>MessagePort</a></code> objects. The object returned by the <code title=dom-SharedWorker><a href=#dom-sharedworker>SharedWorker()</a></code> constructor holds a
+ reference to the port on its <code title=dom-SharedWorker-port><a href=#dom-sharedworker-port>port</a></code> attribute.</p>
+
+ <pre>worker.port.onmessage = function (event) { ... };
+worker.port.postMessage('some message');
+worker.port.postMessage({ foo: 'structured'; bar: ['data', 'also', 'possible']});</pre>
+
+ <p>Inside the shared worker, new clients of the worker are announced
+ using the <code title=event-connect>connect</code> event. The port
+ for the new client is given by the event object's <code title=dom-messageevent-ports><a href=#dom-messageevent-ports>ports</a></code> array as its first (and
+ only) value.</p>
+
+ <pre>onconnect = function (event) {
+ var newPort = event.ports[0];
+ // set up a listener
+ newPort.onmessage = function (event) { ... };
+ // send a message back to the port
+ newPort.postMessage('ready!'); // can also send structured data, of course
+};</pre>
+
+
+
+
+ <h3 id=infrastructure-0><span class=secno>10.2 </span>Infrastructure</h3>
+
+ <p>There are two kinds of workers; dedicated workers, and shared
+ workers. Dedicated workers, once created, and are linked to their
+ creator; but message ports can be used to communicate from a
+ dedicated worker to multiple other browsing contexts or
+ workers. Shared workers, on the other hand, are named, and once
+ created any script running in the same <a href=#origin>origin</a> can
+ obtain a reference to that worker and communicate with it.</p>
+
+
+
+ <h4 id=the-global-scope><span class=secno>10.2.1 </span>The global scope</h4>
+
+ <p>The global scope is the "inside" of a worker.</p>
+
+ <h5 id=the-workerglobalscope-abstract-interface><span class=secno>10.2.1.1 </span>The <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> abstract interface</h5>
+
+ <pre class=idl>interface <dfn id=workerglobalscope>WorkerGlobalScope</dfn> : <a href=#eventtarget>EventTarget</a> {
+ readonly attribute <a href=#workerglobalscope>WorkerGlobalScope</a> <a href=#dom-workerglobalscope-self title=dom-WorkerGlobalScope-self>self</a>;
+ readonly attribute <a href=#workerlocation>WorkerLocation</a> <a href=#dom-workerglobalscope-location title=dom-WorkerGlobalScope-location>location</a>;
+
+ void <a href=#dom-workerglobalscope-close title=dom-WorkerGlobalScope-close>close</a>();
+<!-- v2-onclose [TreatNonCallableAsNull] attribute <span>Function</span>? <span title="handler-WorkerGlobalScope-onclose">onclose</span>;
+--> [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-workerglobalscope-onerror title=handler-WorkerGlobalScope-onerror>onerror</a>;
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-workerglobalscope-onoffline title=handler-WorkerGlobalScope-onoffline>onoffline</a>;
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-workerglobalscope-ononline title=handler-WorkerGlobalScope-ononline>ononline</a>;
+};
+<a href=#workerglobalscope>WorkerGlobalScope</a> implements <a href=#workerutils>WorkerUtils</a>;</pre>
+
+ <p>The <dfn id=dom-workerglobalscope-self title=dom-WorkerGlobalScope-self><code>self</code></dfn> attribute
+ must return the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object itself.</p>
+
+ <p>The <dfn id=dom-workerglobalscope-location title=dom-WorkerGlobalScope-location><code>location</code></dfn>
+ attribute must return the <code><a href=#workerlocation>WorkerLocation</a></code> object created
+ for the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object when the worker was
+ created. It represents the <a href=#absolute-url>absolute URL</a> of the script
+ that was used to initialize the worker, after any redirects.</p>
+
+ <hr><p>When a script invokes the <dfn id=dom-workerglobalscope-close title=dom-WorkerGlobalScope-close><code>close()</code></dfn>
+ method on a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, the user agent
+ must run the following steps (atomically):</p>
+
+ <ol><li><p>Discard any <a href=#concept-task title=concept-task>tasks</a> that
+ have been added to the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task
+ queue">task queues</a>.</p>
+
+<!-- v2-onclose
+ <li><p><span>Queue a task</span> to <span>fire a simple
+ event</span> named <code title="event-close">close</code> at the
+ <code>WorkerGlobalScope</code> object.</p></li>
+-->
+
+ <li><p>Set the worker's <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's
+ <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag to
+ true. (This prevents any further tasks from being queued.)</li>
+
+ </ol><p>The following are the <a href=#event-handlers>event handlers</a> (and their
+ corresponding <a href=#event-handler-event-type title="event handler event type">event handler
+ event types</a>) that must be supported, as IDL attributes, by
+ objects implementing the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code>
+ interface:</p>
+
+ <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a>
+ <tbody><!-- v2-onclose <tr><td><dfn title="handler-WorkerGlobalScope-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code> --><tr><td><dfn id=handler-workerglobalscope-onerror title=handler-WorkerGlobalScope-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code>
+ <tr><td><dfn id=handler-workerglobalscope-onoffline title=handler-WorkerGlobalScope-onoffline><code>onoffline</code></dfn> <td> <code title=event-offline><a href=#event-offline>offline</a></code> <!-- new -->
+ <tr><td><dfn id=handler-workerglobalscope-ononline title=handler-WorkerGlobalScope-ononline><code>ononline</code></dfn> <td> <code title=event-online><a href=#event-online>online</a></code> <!-- new -->
+ </table><hr><p>The <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> interface must not exist if
+ the interface's <span>relevant namespace object</span> is a
+ <code><a href=#window>Window</a></code> object. <a href=#refsWEBIDL>[WEBIDL]</a></p>
+
+
+
+ <h5 id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface><span class=secno>10.2.1.2 </span>Dedicated workers and the <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> interface</h5>
+
+ <pre class=idl>[Supplemental, NoInterfaceObject]
+interface <dfn id=dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</dfn> : <a href=#workerglobalscope>WorkerGlobalScope</a> {
+ void <a href=#dom-dedicatedworkerglobalscope-postmessage title=dom-DedicatedWorkerGlobalScope-postMessage>postMessage</a>(any message, optional sequence<<a href=#transferable>Transferable</a>> transfer);<!--
+ <span>MessagePort</span> <span title="dom-DedicatedWorkerGlobalScope-startConversation">startConversation</span>(any message);-->
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-dedicatedworkerglobalscope-onmessage title=handler-DedicatedWorkerGlobalScope-onmessage>onmessage</a>;
+};</pre>
+
+ <p><code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> objects act as if they
+ had an implicit <code><a href=#messageport>MessagePort</a></code> associated with them. This
+ port is part of a channel that is set up when the worker is created,
+ but it is not exposed. This object must never be garbage collected
+ before the <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object.</p>
+
+ <p>All messages received by that port must immediately be retargeted
+ at the <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object.</p>
+
+ <p>The <dfn id=dom-dedicatedworkerglobalscope-postmessage title=dom-DedicatedWorkerGlobalScope-postMessage><code>postMessage()</code></dfn><!--
+ and <dfn
+ title="dom-DedicatedWorkerGlobalScope-startConversation"><code>startConversation()</code></dfn>-->
+ method<!--s (startConversation)--> on
+ <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> objects must act as if, when
+ invoked, it<!--/they (startConversation)--> immediately invoked the
+ method of the same name on the port, with the same arguments, and
+ returned the same return value.</p>
+
+ <p>The following are the <a href=#event-handlers>event handlers</a> (and their
+ corresponding <a href=#event-handler-event-type title="event handler event type">event handler
+ event types</a>) that must be supported, as IDL attributes, by
+ objects implementing the <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code>
+ interface:</p>
+
+ <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a>
+ <tbody><tr><td><dfn id=handler-dedicatedworkerglobalscope-onmessage title=handler-DedicatedWorkerGlobalScope-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code>
+ </table><p>For the purposes of the <a href=#application-cache>application cache</a> networking
+ model, a dedicated worker is an extension of the <a href=#cache-host>cache
+ host</a> from which it was created.</p>
+
+
+
+ <h5 id=shared-workers-and-the-sharedworkerglobalscope-interface><span class=secno>10.2.1.3 </span>Shared workers and the <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> interface</h5>
+
+ <pre class=idl>[Supplemental, NoInterfaceObject]
+interface <dfn id=sharedworkerglobalscope>SharedWorkerGlobalScope</dfn> : <a href=#workerglobalscope>WorkerGlobalScope</a> {
+ readonly attribute DOMString <a href=#dom-sharedworkerglobalscope-name title=dom-SharedWorkerGlobalScope-name>name</a>;
+ readonly attribute <a href=#applicationcache>ApplicationCache</a> <a href=#dom-sharedworkerglobalscope-applicationcache title=dom-SharedWorkerGlobalScope-applicationCache>applicationCache</a>;
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-sharedworkerglobalscope-onconnect title=handler-SharedWorkerGlobalScope-onconnect>onconnect</a>;
+};</pre>
+
+ <p>Shared workers receive message ports through <code title=event-WorkerGlobalScope-connect>connect</code> events on
+ their global object for each connection.</p>
+
+ <p>The <dfn id=dom-sharedworkerglobalscope-name title=dom-SharedWorkerGlobalScope-name><code>name</code></dfn>
+ attribute must return the value it was assigned when the
+ <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object was created by the
+ "<a href=#run-a-worker>run a worker</a>" algorithm. Its value represents the name
+ that can be used to obtain a reference to the worker using the
+ <code><a href=#sharedworker>SharedWorker</a></code> constructor.</p>
+
+ <p>The following are the <a href=#event-handlers>event handlers</a> (and their
+ corresponding <a href=#event-handler-event-type title="event handler event type">event handler
+ event types</a>) that must be supported, as IDL attributes, by
+ objects implementing the <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code>
+ interface:</p>
+
+ <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a>
+ <tbody><tr><td><dfn id=handler-sharedworkerglobalscope-onconnect title=handler-SharedWorkerGlobalScope-onconnect><code>onconnect</code></dfn> <td> <code title=event-connect>connect</code>
+ </table><p>For the purposes of the <a href=#application-cache>application cache</a> networking
+ model, a shared worker is its own <a href=#cache-host>cache host</a>. The
+ <a href=#run-a-worker>run a worker</a> algorithm takes care of associating the
+ worker with an <a href=#application-cache>application cache</a>.</p>
+
+ <p class=note>The <code title=dom-SharedWorkerGlobalScope-applicationCache><a href=#dom-sharedworkerglobalscope-applicationcache>applicationCache</a></code>
+ attribute returns the <code><a href=#applicationcache>ApplicationCache</a></code> object for the
+ worker.</p><!-- normative conf criteria is in the appcache section
+ -->
+
+
+ <h4 id=origins-of-workers><span class=secno>10.2.2 </span>Origins of workers</h4>
+
+ <p>Both the <a href=#origin>origin</a> and <a href=#effective-script-origin>effective script
+ origin</a> of scripts running in workers are the
+ <a href=#origin>origin</a> of the <a href=#absolute-url>absolute URL</a> given in that
+ the worker's <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code> attribute
+ represents.</p>
+
+
+
+ <h4 id=the-event-loop><span class=secno>10.2.3 </span>The event loop</h4>
+
+ <p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object has an <a href=#event-loop>event
+ loop</a> distinct from those defined for <a href=#unit-of-related-similar-origin-browsing-contexts title="unit of
+ related similar-origin browsing contexts">units of related
+ similar-origin browsing contexts</a>. This <a href=#event-loop>event
+ loop</a> has no associated <a href=#browsing-context>browsing context</a>, and its
+ <a href=#task-queue title="task queue">task queues</a> only have events,
+ callbacks, and networking activity as <a href=#concept-task title=concept-task>tasks</a>. The processing model of these
+ <a href=#event-loop title="event loop">event loops</a> is defined below in the
+ <a href=#run-a-worker>run a worker</a> algorithm.</p>
+
+ <p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object also has a <dfn id=dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</dfn> flag, which must
+ initially be false, but which can get set to true by the algorithms
+ in the processing model section below.</p>
+
+ <p>Once the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is set to
+ true, the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task queue">task
+ queues</a> must discard any further <a href=#concept-task title=concept-task>tasks</a> that would be added to them (tasks
+ already on the queue are unaffected except where otherwise
+ specified). Effectively, once the <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is true,
+ timers stop firing, notifications for all pending asynchronous
+ operations are dropped, etc.</p>
+
+
+
+ <h4 id="the-worker's-lifetime"><span class=secno>10.2.4 </span>The worker's lifetime</h4>
+
+ <p>Workers communicate with other workers and with <a href=#browsing-context title="browsing context">browsing contexts</a> through <a href=#channel-messaging title="channel messaging">message channels</a> and their
+ <code><a href=#messageport>MessagePort</a></code> objects.</p>
+
+ <p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> <var title="">worker global
+ scope</var> has a list of <dfn id="the-worker's-ports">the worker's ports</dfn>, which
+ consists of all the <code><a href=#messageport>MessagePort</a></code> objects that are
+ entangled with another port and that have one (but only one) port
+ owned by <var title="">worker global scope</var>. This list includes
+ <!--all the <code>MessagePort</code> objects that are in events
+ pending in the <span>event loop</span>, as well as (commented out
+ because in practice it makes no difference either way as far as I
+ can tell, and it would be hard to strictly implement since these
+ ports might not yet be across the thread boundary)--> the implicit
+ <code><a href=#messageport>MessagePort</a></code> in the case of <a href=#dedicatedworkerglobalscope title=DedicatedWorkerGlobalScope>dedicated workers</a>.</p>
+
+ <p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> also has a list of <dfn id="the-worker's-workers">the
+ worker's workers</dfn>. Initially this list is empty; it is
+ populated when the worker creates or obtains further workers.</p>
+
+ <p>Finally, each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> also has a list of
+ <dfn id="the-worker's-documents">the worker's <code>Document</code>s</dfn>. Initially this list
+ is empty; it is populated when the worker is created.</p>
+
+ <p>Whenever a <code><a href=#document>Document</a></code> <var title="">d</var> is <dfn id="add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">added to the
+ worker's <code>Document</code>s</dfn>, the user agent must, for each
+ worker in the list of <a href="#the-worker's-workers">the worker's workers</a> whose list
+ of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> does not contain
+ <var title="">d</var>, <a href="#add-a-document-to-the-worker's-documents" title="add a document to the worker's
+ documents">add <var title="">d</var> to <var title="">q</var>'s
+ <code>WorkerGlobalScope</code> owner's list of <span>the worker's
+ <code>Document</code>s</span></a>.</p> <!-- suggestions welcome
+ on making this sentence into understandable English -->
+
+ <p>Whenever a <code><a href=#document>Document</a></code> object is <a href=#discard-a-document title="discard a
+ Document">discarded</a>, it must be removed from the list of
+ <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> of each worker
+ whose list contains that <code><a href=#document>Document</a></code>.</p>
+
+ <p>Given a <a href="#script's-global-object">script's global object</a> <var title="">o</var>
+ when creating or obtaining a worker, the <dfn id=list-of-relevant-document-objects-to-add>list of relevant
+ <code>Document</code> objects to add</dfn> depends on the type of
+ <var title="">o</var>. If <var title="">o</var> is a
+ <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object (i.e. if we are creating a
+ nested worker), then the relevant <code><a href=#document>Document</a></code>s are the
+ <code><a href=#document>Document</a></code>s that are in <var title="">o</var>'s own list
+ of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a>. Otherwise, <var title="">o</var> is a <code><a href=#window>Window</a></code> object, and the relevant
+ <code><a href=#document>Document</a></code> is just the <code><a href=#document>Document</a></code> that is the
+ <a href=#active-document>active document</a> of the <code><a href=#window>Window</a></code> object <var title="">o</var>.</p>
+
+ <hr><p>A worker is said to be a <dfn id=permissible-worker>permissible worker</dfn> if its
+ list of <a href="#the-worker's-documents">the worker's <code>Document</code>s</a> is not
+ empty.</p>
+
+ <p>A worker is said to be a <dfn id=protected-worker>protected worker</dfn> if it is a
+ <a href=#permissible-worker>permissible worker</a> and either it has outstanding
+ timers, database transactions, or network connections, or its list
+ of <a href="#the-worker's-ports">the worker's ports</a> is not empty, or its
+ <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> is actually a
+ <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object (i.e. the worker is a
+ shared worker).</p>
+
+ <p>A worker is said to be an <dfn id=active-needed-worker>active needed worker</dfn> if any
+ of the <code><a href=#document>Document</a></code> objects in <a href="#the-worker's-documents">the worker's
+ <code>Document</code>s</a> are <a href=#fully-active>fully active</a>.</p>
+
+ <p>A worker is said to be a <dfn id=suspendable-worker>suspendable worker</dfn> if it is
+ not an <a href=#active-needed-worker>active needed worker</a> but it is a
+ <a href=#permissible-worker>permissible worker</a>.</p>
+
+
+ <h4 id=processing-model-4><span class=secno>10.2.5 </span>Processing model</h4>
+
+ <p>When a user agent is to <dfn id=run-a-worker>run a worker</dfn> for a script with
+ <a href=#url>URL</a> <var title="">url</var>, a <a href=#browsing-context>browsing
+ context</a> <var title="">owner browsing context</var>, a
+ <code><a href=#document>Document</a></code> <var title="">owner document</var>, an
+ <a href=#origin>origin</a> <var title="">owner origin</var>, and with
+ global scope <var title="">worker global scope</var>, it must run
+ the following steps:</p>
+
+ <ol><li>
+
+ <p>Create a separate parallel execution environment (i.e. a
+ separate thread or process or equivalent construct), and run the
+ rest of these steps asynchronously in that context.</p>
+
+ </li>
+
+ <li><p>If <var title="">worker global scope</var> is actually a
+ <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object (i.e. the worker is a
+ shared worker), and there are any <a href=#relevant-application-cache title="relevant application
+ cache">relevant application caches</a> that are identified by a
+ manifest URL with the <a href=#same-origin>same origin</a> as <var title="">url</var> and that have <var title="">url</var> as one of
+ their entries, <em>not</em> excluding entries marked as <a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>, then associate the
+ <var title="">worker global scope</var> with the <a href=#concept-appcache-selection title=concept-appcache-selection>most appropriate application
+ cache</a> of those that match.</li>
+
+ <li>
+
+ <p>Attempt to <a href=#fetch>fetch</a> the resource identified by <var title="">url</var>, from the <var title="">owner origin</var>,
+ with the <i>synchronous flag</i> set and the <i>force same-origin
+ flag</i> set.</p> <!-- not http-origin privacy sensitive (looking
+ forward to CORS) -->
+
+ <p>If the attempt fails, then for each <code><a href=#worker>Worker</a></code> or
+ <code><a href=#sharedworker>SharedWorker</a></code> object associated with <var title="">worker global scope</var>, <a href=#queue-a-task>queue a task</a> to
+ <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at that object. Abort these
+ steps.</p>
+
+ <p>If the attempt succeeds, then let <var title="">source</var> be
+ the script resource <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error
+ handling</a>.
+ </p>
+
+ <p>Let <var title="">language</var> be JavaScript.</p>
+
+ <p class=note>As with <code><a href=#the-script-element>script</a></code> elements, the MIME
+ type of the script is ignored. Unlike with <code><a href=#the-script-element>script</a></code>
+ elements, there is no way to override the type. It's always
+ assumed to be JavaScript.</p>
+
+ </li>
+
+ <li>
+
+ <p>A new <a href=#concept-script title=concept-script>script</a> is now
+ created, as follows.</p>
+
+ <p>Create a new <a href=#script-execution-environment>script execution environment</a>
+ set up as appropriate for the scripting language <var title="">language</var>.</p>
+
+ <p>Parse/compile/initialize <var title="">source</var> using that
+ <a href=#script-execution-environment>script execution environment</a>, as appropriate for <var title="">language</var>, and thus obtain a <a href=#list-of-code-entry-points>list of code
+ entry-points</a>; set the <i><a href=#initial-code-entry-point>initial code entry-point</a></i> to
+ the entry-point for any executable code to be immediately run.</p>
+
+ <p>Set the <a href="#script's-global-object">script's global object</a> to <var title="">worker global scope</var>.</p>
+
+ <p>Set the <a href="#script's-browsing-context">script's browsing context</a> to <var title="">owner browsing context</var>.</p>
+
+ <p>Set the <a href="#script's-document">script's document</a> to <var title="">owner
+ document</var>.</p>
+
+ <p>Set the <a href="#script's-url-character-encoding">script's URL character encoding</a> to
+ UTF-8. (This is just used for encoding non-ASCII characters in the
+ query component of URLs.)</p>
+
+ <p>Set the <a href="#script's-base-url">script's base URL</a> to <var title="">url</var>.</p>
+
+ </li>
+
+ <li>
+
+ <p><strong>Closing orphan workers</strong>: Start monitoring the
+ worker such that no sooner than it stops being either a
+ <a href=#protected-worker>protected worker</a> or a <a href=#suspendable-worker>suspendable
+ worker</a>, and no later than it stops being a
+ <a href=#permissible-worker>permissible worker</a>, <var title="">worker global
+ scope</var>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is set
+ to true<!-- v2-onclose and <span title="queue a task">a task is
+ queued</span> to <span>fire a simple event</span> named <code
+ title="event-close">close</code> at <var title="">worker global
+ scope</var>-->.</p>
+
+ </li>
+
+ <li>
+
+ <p><strong>Suspending workers</strong>: Start monitoring the
+ worker, such that whenever <var title="">worker global
+ scope</var>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is false
+ and the worker is a <a href=#suspendable-worker>suspendable worker</a>, the user
+ agent suspends execution of script in that worker until such time
+ as either the <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag switches
+ to true or the worker stops being a <a href=#suspendable-worker>suspendable
+ worker</a>.</p>
+
+ </li>
+
+ <li>
+
+ <p><a href=#jump-to-a-code-entry-point title="jump to a code entry-point">Jump</a> to the
+ <a href=#concept-script title=concept-script>script</a>'s <i><a href=#initial-code-entry-point>initial code
+ entry-point</a></i>, and let that run until it either returns, fails
+ to catch an exception, or gets prematurely aborted by the
+ "<a href=#kill-a-worker>kill a worker</a>" or "<a href=#terminate-a-worker>terminate a worker</a>"
+ algorithms defined below.</p>
+
+<!-- v2-onclose
+ <p class="note">If the script gets aborted by the "<span>kill a
+ worker</span>" algorithm, then that same algorithm will cause
+ there to only be a single <span title="concept-task">task</span>
+ in the <span>event loop</span> at the next step, namely the task
+ for the <code title="message-close">close</code> event. The
+ "<span>terminate a worker</span>" algorithm removes all the
+ events.</p>
+-->
+
+ </li>
+
+ <li><p>If <var title="">worker global scope</var> is actually a
+ <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object (i.e. the worker is
+ a dedicated worker), then enable the <a href=#port-message-queue>port message
+ queue</a> of the worker's implicit port.</li>
+
+ <li>
+
+ <p><i title="">Event loop</i>: Wait until either there is a <a href=#concept-task title=concept-task>task</a> in one of the <a href=#event-loop>event
+ loop</a>'s <a href=#task-queue title="task queue">task queues</a> or <var title="">worker global scope</var>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is set
+ to true.</p>
+
+ </li>
+
+ <li>
+
+ <p>Run the oldest task on one of the <a href=#event-loop>event loop</a>'s
+ <a href=#task-queue title="task queue">task queues</a>, if any. The user
+ agent may pick any <a href=#task-queue>task queue</a>.</p>
+
+ <p class=note>The handling of events or the execution of
+ callbacks might get prematurely aborted by the "<a href=#kill-a-worker>kill a
+ worker</a>" or "<a href=#terminate-a-worker>terminate a worker</a>" algorithms
+ defined below.</p>
+
+ </li>
+
+ <li>
+
+ <p>If the <a href=#storage-mutex>storage mutex</a> is now owned by the worker's
+ <a href=#event-loop>event loop</a>, release it so that it is once again
+ free.</p>
+
+ </li>
+
+ <li>
+
+ <p>Remove the task just run in the earlier step, if any, from its
+ <a href=#task-queue>task queue</a>.</p>
+
+ </li>
+
+ <li>
+
+ <p>If there are any more events in the <a href=#event-loop>event loop</a>'s
+ <a href=#task-queue title="task queue">task queues</a> or if <var title="">worker global scope</var>'s <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is set
+ to false, then jump back to the step above labeled <i><a href=#event-loop>event
+ loop</a></i>.</p>
+
+ </li>
+
+ <li>
+
+ <p>Empty the <var title="">worker global scope</var>'s <a href=#list-of-active-timeouts>list
+ of active timeouts</a> and its <a href=#list-of-active-intervals>list of active
+ intervals</a>.</p>
+
+ </li>
+
+ <li>
+
+ <p>Disentangle all the ports in the list of <a href="#the-worker's-ports">the worker's
+ ports</a>.</p>
+
+ </li>
+
+<!-- v2-onclose
+ <li>
+
+ <p>For each <code>Worker</code> or <code>SharedWorker</code>
+ object associated with <var title="">worker global scope</var>,
+ <span>queue a task</span> to <span>fire a simple event</span>
+ named <code title="event-close">close</code> at that object.</p>
+
+ </li>
+-->
+ </ol><hr><p>When a user agent is to <dfn id=kill-a-worker>kill a worker</dfn> it must
+ run the following steps in parallel with the worker's main loop (the
+ "<a href=#run-a-worker>run a worker</a>" processing model defined above):</p>
+
+ <ol><!-- v2-onclose
+ <li><p>If the worker's <code>WorkerGlobalScope</code> object's
+ <span title="dom-WorkerGlobalScope-closing">closing</span> flag is
+ false, <span>queue a task</span> to <span>fire a simple
+ event</span> named <code title="event-close">close</code> at the
+ worker's <code>WorkerGlobalScope</code> object.</p></li>
+--><li><p>Set the worker's <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag to
+ true.</li>
+
+<!-- v2-onclose
+ <li><p>Wait a user-agent-defined amount of time. If the "<span>run
+ a worker</span>" processing model defined above immediately starts
+ running event listeners registered for the <code
+ title="event-close">close</code> event, this time should not be
+ zero — the idea is that the <code
+ title="event-close">close</code> event can be used to clean up
+ when shutting down unexpectedly.</p></li>
+-->
+
+ <li><p>If there are any <a href=#concept-task title=concept-task>tasks</a>
+ queued in the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task
+ queue">task queues</a><!-- v2-onclose other than the <code
+ title="event-close">close</code> event that this algorithm just
+ added-->, discard them without processing them.</li>
+
+<!-- v2-onclose
+ <li><p>If the <code title="event-close">close</code> event that
+ this algorithm just queued hasn't yet been dispatched, then abort
+ the script currently running in the worker.</p></li>
+-->
+
+ <li><p>Wait a user-agent-defined amount of time.</li>
+
+ <li><p>Abort the script currently running in the worker<!--
+ v2-onclose (if any script is running, then it will be a handler for
+ the <code title="event-close">close</code> event)-->.</li>
+
+ </ol><p>User agents may invoke the "<a href=#kill-a-worker>kill a worker</a>"
+ processing model on a worker at any time, e.g. in response to user
+ requests, in response to CPU quota management, or when a worker
+ stops being an <a href=#active-needed-worker>active needed worker</a> if the worker
+ continues executing even after its <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag was
+ set to true.</p>
+
+ <hr><p>When a user agent is to <dfn id=terminate-a-worker>terminate a worker</dfn> it must run
+ the following steps in parallel with the worker's main loop (the
+ "<a href=#run-a-worker>run a worker</a>" processing model defined above):</p>
+
+ <ol><li><p>Set the worker's <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's
+ <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag to
+ true.</li>
+
+ <li><p>If there are any <a href=#concept-task title=concept-task>tasks</a>
+ queued in the <a href=#event-loop>event loop</a>'s <a href=#task-queue title="task
+ queue">task queues</a>, discard them without processing
+ them.</li>
+
+ <li><p>Abort the script currently running in the worker.</li>
+
+ <li><p>If the worker's <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object is
+ actually a <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object (i.e. the
+ worker is a dedicated worker), then empty the <a href=#port-message-queue>port message
+ queue</a> of the port that the worker's implicit port is
+ entangled with.</li>
+
+ </ol><hr><p>The <a href=#task-source>task source</a> for the tasks mentioned above is the
+ <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p>
+
+
+ <h4 id=runtime-script-errors-0><span class=secno>10.2.6 </span>Runtime script errors</h4>
+
+ <p>Whenever an uncaught runtime script error occurs in one of the
+ worker's scripts, if the error did not occur while handling a
+ previous script error, the user agent must <a href=#report-the-error>report the
+ error</a> using the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's <code title=handler-WorkerGlobalScope-onerror><a href=#handler-workerglobalscope-onerror>onerror</a></code>
+ attribute.
+ </p>
+
+ <p>For shared workers, if the error is still <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> afterwards, or if
+ the error occurred while handling a previous script error, the error
+ may be reported to the user.
+ </p>
+
+ <p>For dedicated workers, if the error is still <i title=concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> afterwards, or if
+ the error occurred while handling a previous script error, the user
+ agent must <a href=#queue-a-task>queue a task</a> to fire an event that uses the
+ <code><a href=#errorevent>ErrorEvent</a></code> interface, with the name <code title=event-error>error</code>, that doesn't bubble and is
+ cancelable, with its <code title=dom-ErrorEvent-message><a href=#dom-errorevent-message>message</a></code>, <code title=dom-ErrorEvent-filename><a href=#dom-errorevent-filename>filename</a></code>, and <code title=dom-ErrorEvent-lineno><a href=#dom-errorevent-lineno>lineno</a></code> attributes initialized
+ appropriately, at the <code><a href=#worker>Worker</a></code> object associated with the
+ worker. If the event is not canceled, the user agent must act as if
+ the uncaught runtime script error had occurred in the global scope
+ that the <code><a href=#worker>Worker</a></code> object is in, thus repeating the entire
+ runtime script error reporting process one level up.</p>
+
+ <p>If the implicit port connecting the worker to its
+ <code><a href=#worker>Worker</a></code> object has been disentangled (i.e. if the parent
+ worker has been terminated), then the user agent must act as if the
+ <code><a href=#worker>Worker</a></code> object had no <code title=event-error>error</code> event handler and as if that
+ worker's <code title=handler-WorkerGlobalScope-onerror><a href=#handler-workerglobalscope-onerror>onerror</a></code> attribute
+ was null, but must otherwise act as described above.</p>
+
+ <p class=note>Thus, error reports proagate up to the chain of
+ dedicated workers up to the original <code><a href=#document>Document</a></code>, even if
+ some of the workers along this chain have been terminated and
+ garbage collected.</p>
+
+ <p>The <a href=#task-source>task source</a> for the task mentioned above is the
+ <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p>
+
+ <hr><pre class=idl>[Constructor(DOMString type, optional <a href=#erroreventinit>ErrorEventInit</a> eventInitDict)]
+interface <dfn id=errorevent>ErrorEvent</dfn> : <a href=#event>Event</a> {
+ readonly attribute DOMString <a href=#dom-errorevent-message title=dom-ErrorEvent-message>message</a>;
+ readonly attribute DOMString <a href=#dom-errorevent-filename title=dom-ErrorEvent-filename>filename</a>;
+ readonly attribute unsigned long <a href=#dom-errorevent-lineno title=dom-ErrorEvent-lineno>lineno</a>;
+};
+
+dictionary <dfn id=erroreventinit>ErrorEventInit</dfn> : <a href=#eventinit>EventInit</a> {
+ DOMString message;
+ DOMString filename;
+ unsigned long lineno;
+};</pre>
+
+ <p>The <dfn id=dom-errorevent-message title=dom-ErrorEvent-message><code>message</code></dfn> attribute
+ must return the value it was initialized to. When the object is
+ created, this attribute must be initialized to the empty string. It
+ represents the error message.</p>
+
+ <p>The <dfn id=dom-errorevent-filename title=dom-ErrorEvent-filename><code>filename</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to the empty
+ string. It represents the <a href=#absolute-url>absolute URL</a> of the script in
+ which the error originally occurred.</p>
+
+ <p>The <dfn id=dom-errorevent-lineno title=dom-ErrorEvent-lineno><code>lineno</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to zero. It
+ represents the line number where the error occurred in the
+ script.</p>
+
+
+
+ <h4 id=creating-workers><span class=secno>10.2.7 </span>Creating workers</h4>
+
+ <h5 id=the-abstractworker-abstract-interface><span class=secno>10.2.7.1 </span>The <code><a href=#abstractworker>AbstractWorker</a></code> abstract interface</h5>
+
+ <pre class=idl>[Supplemental, NoInterfaceObject]
+interface <dfn id=abstractworker>AbstractWorker</dfn> : <a href=#eventtarget>EventTarget</a> {
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-abstractworker-onerror title=handler-AbstractWorker-onerror>onerror</a>;
+<!-- v2-onclose [TreatNonCallableAsNull] attribute <span>Function</span>? <span title="handler-AbstractWorker-onclose">onclose</span>; -->
+};</pre>
+
+ <p>The following are the <a href=#event-handlers>event handlers</a> (and their
+ corresponding <a href=#event-handler-event-type title="event handler event type">event handler
+ event types</a>) that must be supported, as IDL attributes, by
+ objects implementing the <code><a href=#abstractworker>AbstractWorker</a></code> interface:</p>
+
+ <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a>
+ <tbody><tr><td><dfn id=handler-abstractworker-onerror title=handler-AbstractWorker-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code>
+<!-- v2-onclose <tr><td><dfn title="handler-AbstractWorker-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code> -->
+ </table><h5 id=dedicated-workers-and-the-worker-interface><span class=secno>10.2.7.2 </span>Dedicated workers and the <code><a href=#worker>Worker</a></code> interface</h5>
+
+ <pre class=idl>[<a href=#dom-worker title=dom-Worker>Constructor</a>(DOMString scriptURL)]
+interface <dfn id=worker>Worker</dfn> : <a href=#abstractworker>AbstractWorker</a> {
+ void <a href=#dom-worker-terminate title=dom-Worker-terminate>terminate</a>();
+
+ void <a href=#dom-worker-postmessage title=dom-Worker-postMessage>postMessage</a>(any message, optional sequence<<a href=#transferable>Transferable</a>> transfer);<!--
+ <span>MessagePort</span> <span title="dom-Worker-startConversation">startConversation</span>(any message);-->
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-worker-onmessage title=handler-Worker-onmessage>onmessage</a>;
+};</pre>
+
+ <p>The <dfn id=dom-worker-terminate title=dom-Worker-terminate><code>terminate()</code></dfn> method,
+ when invoked, must cause the "<a href=#terminate-a-worker>terminate a worker</a>"
+ algorithm to be run on the worker with with the object is
+ associated.</p>
+
+ <p><code><a href=#worker>Worker</a></code> objects act as if they had an implicit
+ <code><a href=#messageport>MessagePort</a></code> associated with them. This port is part of
+ a channel that is set up when the worker is created, but it is not
+ exposed. This object must never be garbage collected before the
+ <code><a href=#worker>Worker</a></code> object.</p>
+
+ <p>All messages received by that port must immediately be retargeted
+ at the <code><a href=#worker>Worker</a></code> object.</p>
+
+ <p>The <dfn id=dom-worker-postmessage title=dom-Worker-postMessage><code>postMessage()</code></dfn><!--
+ and <dfn
+ title="dom-Worker-startConversation"><code>startConversation()</code></dfn>-->
+ method<!--s (startConversation)--> on <code><a href=#worker>Worker</a></code> objects
+ must act as if, when invoked, it<!--/they (startConversation)-->
+ immediately invoked the method of the same name on the port, with
+ the same arguments, and returned the same return value.</p>
+
+ <p>The following are the <a href=#event-handlers>event handlers</a> (and their
+ corresponding <a href=#event-handler-event-type title="event handler event type">event handler
+ event types</a>) that must be supported, as IDL attributes, by
+ objects implementing the <code><a href=#worker>Worker</a></code> interface:</p>
+
+ <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a>
+ <tbody><tr><td><dfn id=handler-worker-onmessage title=handler-Worker-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code>
+ </table><hr><p>When the <dfn id=dom-worker title=dom-Worker><code>Worker(<var title="">scriptURL</var>)</code></dfn> constructor is invoked, the
+ user agent must run the following steps:</p>
+
+ <ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">scriptURL</var> argument relative to the <a href=#entry-script>entry
+ script</a>'s <a href="#script's-base-url" title="script's base URL">base URL</a>,
+ when the method is invoked.</li>
+
+ <li><p>If this fails, throw a <code><a href=#syntaxerror>SyntaxError</a></code>
+ exception.</li>
+
+ <li>
+
+ <p>If the <a href=#origin>origin</a> of the resulting <a href=#absolute-url>absolute
+ URL</a> is not the <a href=#same-origin title="same origin">same</a> as the
+ origin of the <a href=#entry-script>entry script</a>, then throw a
+ <code><a href=#securityerror>SecurityError</a></code> exception.</p>
+
+ <p class=note>Thus, scripts must be external files with the same
+ scheme as the original page: you can't load a script from a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> or
+ <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a>, and an <code>https:</code>
+ page couldn't start workers using scripts with <code>http:</code>
+ URLs.</p>
+
+ </li>
+
+ <li><p>Create a new <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code>
+ object. Let <var title="">worker global scope</var> be this new
+ object.</li>
+
+ <li><p>Create a new <code><a href=#worker>Worker</a></code> object, associated with
+ <var title="">worker global scope</var>. Let <var title="">worker</var> be this new object.</li>
+
+ <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a>
+ owned by the <a href="#script's-global-object" title="script's global object">global
+ object</a> of the <a href=#concept-script title=concept-script>script</a> that
+ invoked the constructor. Let this be the <var title="">outside
+ port</var>.</li>
+
+ <li><p>Associate the <var title="">outside port</var> with <var title="">worker</var>.</li>
+
+ <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a>
+ owned by <var title="">worker global scope</var>. Let <var title="">inside port</var> be this new object.</li>
+
+ <li><p>Associate <var title="">inside port</var> with <var title="">worker global scope</var>.</li>
+
+ <li><p><a href=#entangle>Entangle</a> <var title="">outside port</var> and
+ <var title="">inside port</var>.</li>
+
+ <li><p>Return <var title="">worker</var>, and run the following
+ steps asynchronously.</li>
+
+<!-- (this is done by the "run a worker" algorithm)
+ <li><p>Enable <var title="">inside port</var>'s <span>port message
+ queue</span>.</p></li>
+-->
+
+ <li><p>Enable <var title="">outside port</var>'s <a href=#port-message-queue>port message
+ queue</a>.</li>
+
+ <li>
+
+ <p>Let <var title="">docs</var> be the <a href=#list-of-relevant-document-objects-to-add>list of relevant
+ <code>Document</code> objects to add</a> given the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the
+ constructor.</p>
+
+ </li>
+
+ <li>
+
+ <p><a href="#add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">Add to
+ <var title="">worker global scope</var>'s list of <span>the
+ worker's <code>Document</code>s</span></a> the
+ <code><a href=#document>Document</a></code> objects in <var title="">docs</var>.</p>
+
+ </li>
+
+ <li>
+
+ <p>If the <a href="#script's-global-object" title="script's global object">global object</a>
+ of the <a href=#concept-script title=concept-script>script</a> that invoked the
+ constructor is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object (i.e. we
+ are creating a nested worker), add <var title="">worker global
+ scope</var> to the list of <a href="#the-worker's-workers">the worker's workers</a> of the
+ <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object that is the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the
+ constructor.</p>
+
+ </li>
+
+ <li>
+
+ <p><a href=#run-a-worker>Run a worker</a> for the resulting <a href=#absolute-url>absolute
+ URL</a>, with the <a href="#script's-browsing-context">script's browsing context</a> of the
+ script that invoked the method as the <var title="">owner browsing
+ context</var>, with the <a href="#script's-document">script's document</a> of the
+ script that invoked the method as the <var title="">owner
+ document</var>, with the <a href=#origin>origin</a> of the <a href=#entry-script>entry
+ script</a> as the <var title="">owner origin</var>, and with
+ <var title="">worker global scope</var> as the global scope.</p>
+
+ </li>
+
+ </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global
+ object</a> is either a <code><a href=#window>Window</a></code> object or an object
+ implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p>
+
+
+ <h5 id=shared-workers-and-the-sharedworker-interface><span class=secno>10.2.7.3 </span>Shared workers and the <code><a href=#sharedworker>SharedWorker</a></code> interface</h5>
+
+ <pre class=idl>[<a href=#dom-sharedworker title=dom-SharedWorker>Constructor</a>(DOMString scriptURL, optional DOMString name)]
+interface <dfn id=sharedworker>SharedWorker</dfn> : <a href=#abstractworker>AbstractWorker</a> {
+ readonly attribute <a href=#messageport>MessagePort</a> <a href=#dom-sharedworker-port title=dom-SharedWorker-port>port</a>;
+};</pre>
+
+ <p>The <dfn id=dom-sharedworker-port title=dom-SharedWorker-port><code>port</code></dfn>
+ attribute must return the value it was assigned by the object's
+ constructor. It represents the <code><a href=#messageport>MessagePort</a></code> for
+ communicating with the shared worker.</p>
+
+ <p>When the <dfn id=dom-sharedworker title=dom-SharedWorker><code>SharedWorker(<var title="">scriptURL</var>, <var title="">name</var>)</code></dfn>
+ constructor is invoked, the user agent must run the following
+ steps:</p>
+
+ <ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the <var title="">scriptURL</var> argument.</li>
+
+ <li><p>If this fails, throw a <code><a href=#syntaxerror>SyntaxError</a></code>
+ exception.</li>
+
+ <li><p>Otherwise, let <var title="">scriptURL</var> be the
+ resulting <a href=#absolute-url>absolute URL</a>.</li>
+
+ <li><p>Let <var title="">name</var> be the value of the second
+ argument, or the empty string if the second argument was
+ omitted.</li>
+
+ <li>
+
+ <p>If the <a href=#origin>origin</a> of <var title="">scriptURL</var> is
+ not the <a href=#same-origin title="same origin">same</a> as the origin of the
+ <a href=#entry-script>entry script</a>, then throw a <code><a href=#securityerror>SecurityError</a></code>
+ exception.</p>
+
+ <p class=note>Thus, scripts must be external files with the same
+ scheme as the original page: you can't load a script from a <a href=#data-protocol title="data protocol"><code title="">data:</code> URL</a> or
+ <a href=#javascript-protocol title="javascript protocol"><code title="">javascript:</code> URL</a>, and a <code>https:</code>
+ page couldn't start workers using scripts with <code>http:</code>
+ URLs.</p>
+
+ </li>
+
+ <li>
+
+ <p>Let <var title="">docs</var> be the <a href=#list-of-relevant-document-objects-to-add>list of relevant
+ <code>Document</code> objects to add</a> given the <a href="#script's-global-object" title="script's global object">global object</a> of the <a href=#concept-script title=concept-script>script</a> that invoked the
+ constructor.</p>
+
+ </li>
+
+ <li>
+
+ <p>Execute the following substeps atomically:</p>
+
+ <ol><li><p>Create a new <code><a href=#sharedworker>SharedWorker</a></code> object, which will
+ shortly be associated with a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code>
+ object. Let this <code><a href=#sharedworker>SharedWorker</a></code> object be <var title="">worker</var>.</li>
+
+ <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a>
+ owned by the <a href="#script's-global-object" title="script's global object">global
+ object</a> of the script that invoked the method. Let this be
+ the <var title="">outside port</var>.</li>
+
+ <li><p>Assign <var title="">outside port</var> to the <code title=dom-SharedWorker-port><a href=#dom-sharedworker-port>port</a></code> attribute of <var title="">worker</var>.</li>
+
+ <li><p>Let <var title="">worker global scope</var> be
+ null.</li>
+
+ <li><p>If <var title="">name</var> is not the empty string and
+ there exists a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object whose
+ <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag
+ is false, whose <code title=dom-WorkerGlobalScope-name>name</code> attribute is
+ exactly equal to <var title="">name</var>, and whose <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code> attribute
+ represents an <a href=#absolute-url>absolute URL</a> with the <a href=#same-origin>same
+ origin</a> as <var title="">scriptURL</var>, then let <var title="">worker global scope</var> be that
+ <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object.</li>
+
+ <li><p>Otherwise, if <var title="">name</var> is the empty string
+ and there exists a <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object
+ whose <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a>
+ flag is false, whose <code title=dom-WorkerGlobalScope-name>name</code> attribute is the
+ empty string, and whose <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code> attribute
+ represents an <a href=#absolute-url>absolute URL</a> that is exactly equal to
+ <var title="">scriptURL</var>, then let <var title="">worker
+ global scope</var> be that <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code>
+ object.</li>
+
+ <li>
+
+ <p>If <var title="">worker global scope</var> is not null, then
+ run these steps:</p>
+
+ <ol><li><p>If <var title="">worker global scope</var>'s <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code>
+ attribute represents an <a href=#absolute-url>absolute URL</a> that is not
+ exactly equal to <var title="">scriptURL</var>, then throw a
+ <code><a href=#urlmismatcherror>URLMismatchError</a></code> exception and abort all these
+ steps.</li>
+
+ <li><p>Associate <var title="">worker</var> with <var title="">worker global scope</var>.</li>
+
+ <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code>
+ object</a> owned by <var title="">worker global
+ scope</var>. Let this be the <var title="">inside
+ port</var>.</li>
+
+ <li><p><a href=#entangle>Entangle</a> <var title="">outside port</var>
+ and <var title="">inside port</var>.</li>
+
+ <li><p>Return <var title="">worker</var> and perform the next
+ step asynchronously.</li>
+
+ <li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code>
+ interface, with the name <code title=event-connect>connect</code>, which does not bubble, is
+ not cancelable, has no default action, has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute whose value
+ is initialized to the empty string and has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose
+ value is initialized to a <a href=#dfn-read-only-array title=dfn-read-only-array>read only</a> array containing
+ only the newly created port, and <a href=#queue-a-task>queue a task</a> to
+ dispatch the event at <var title="">worker global
+ scope</var>.</li>
+
+ <li>
+
+ <p><a href="#add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">Add to
+ <var title="">worker global scope</var>'s list of <span>the
+ worker's <code>Document</code>s</span></a> the
+ <code><a href=#document>Document</a></code> objects in <var title="">docs</var>.</p>
+
+ </li>
+
+ <li>
+
+ <p>If the <a href="#script's-global-object" title="script's global object">global
+ object</a> of the <a href=#concept-script title=concept-script>script</a>
+ that invoked the constructor is a
+ <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, add <var title="">worker global scope</var> to the list of <a href="#the-worker's-workers">the
+ worker's workers</a> of the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code>
+ object that is the <a href="#script's-global-object" title="script's global object">global
+ object</a> of the <a href=#concept-script title=concept-script>script</a>
+ that invoked the constructor.</p>
+
+ </li>
+
+ <li><p>Abort all these steps.</li>
+
+ </ol></li>
+
+ <li><p>Create a new <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code>
+ object. Let <var title="">worker global scope</var> be this new
+ object.</li>
+
+ <li><p>Associate <var title="">worker</var> with <var title="">worker global scope</var>.</li>
+
+ <li><p>Set the <code title=dom-SharedWorkerGlobalScope-name><a href=#dom-sharedworkerglobalscope-name>name</a></code> attribute of
+ <var title="">worker global scope</var> to <var title="">name</var>.</li>
+
+ <li><p><a href=#create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a>
+ owned by <var title="">worker global scope</var>. Let <var title="">inside port</var> be this new object.</li>
+
+ <li><p><a href=#entangle>Entangle</a> <var title="">outside port</var> and
+ <var title="">inside port</var>.</li>
+
+ </ol></li>
+
+ <li><p>Return <var title="">worker</var> and perform the remaining
+ steps asynchronously.</li>
+
+ <li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code>
+ interface, with the name <code title=event-connect>connect</code>, which does not bubble, is not
+ cancelable, has no default action, has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute whose value is
+ initialized to the empty string and has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose value
+ is initialized to a <a href=#dfn-read-only-array title=dfn-read-only-array>read
+ only</a> array containing only the newly created port, and
+ <a href=#queue-a-task>queue a task</a> to dispatch the event at <var title="">worker global scope</var>.</li>
+
+ <li>
+
+ <p><a href="#add-a-document-to-the-worker's-documents" title="add a document to the worker's documents">Add to
+ <var title="">worker global scope</var>'s list of <span>the
+ worker's <code>Document</code>s</span></a> the
+ <code><a href=#document>Document</a></code> objects in <var title="">docs</var>.</p>
+
+ </li>
+
+ <li>
+
+ <p>If the <a href="#script's-global-object" title="script's global object">global object</a>
+ of the <a href=#concept-script title=concept-script>script</a> that invoked the
+ constructor is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, add <var title="">worker global scope</var> to the list of <a href="#the-worker's-workers">the
+ worker's workers</a> of the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code>
+ object that is the <a href="#script's-global-object" title="script's global object">global
+ object</a> of the <a href=#concept-script title=concept-script>script</a>
+ that invoked the constructor.</p>
+
+ </li>
+
+ <li>
+
+ <p><a href=#run-a-worker>Run a worker</a> for <var title="">scriptURL</var>,
+ with the <a href="#script's-browsing-context">script's browsing context</a> of the script that
+ invoked the method as the <var title="">owner browsing
+ context</var>, with the <a href="#script's-document">script's document</a> of the
+ script that invoked the method as the <var title="">owner
+ document</var>, with the <a href=#origin>origin</a> of the <a href=#entry-script>entry
+ script</a> as the <var title="">owner origin</var>, and with
+ <var title="">worker global scope</var> as the global scope.</p>
+
+ </li>
+
+ </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global
+ object</a> is either a <code><a href=#window>Window</a></code> object or an object
+ implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p>
+
+ <p>The <a href=#task-source>task source</a> for the tasks mentioned above is the
+ <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p>
+
+
+
+ <h3 id=apis-available-to-workers><span class=secno>10.3 </span>APIs available to workers</h3>
+
+ <pre class=idl>[NoInterfaceObject]
+interface <dfn id=workerutils>WorkerUtils</dfn> {
+ void <a href=#dom-workerglobalscope-importscripts title=dom-WorkerGlobalScope-importScripts>importScripts</a>(DOMString... urls);
+ readonly attribute <a href=#workernavigator>WorkerNavigator</a> <a href=#dom-worker-navigator title=dom-worker-navigator>navigator</a>;
+};
+<a href=#workerutils>WorkerUtils</a> implements <a href=#windowtimers>WindowTimers</a>;
+<a href=#workerutils>WorkerUtils</a> implements <a href=#windowbase64>WindowBase64</a>;</pre>
+
+
+ <p>The DOM APIs (<code><a href=#node>Node</a></code> objects, <code><a href=#document>Document</a></code>
+ objects, etc) are not available to workers in this version of this
+ specification.</p>
+
+
+ <h4 id=importing-scripts-and-libraries><span class=secno>10.3.1 </span>Importing scripts and libraries</h4>
+
+ <p>When a script invokes the <dfn id=dom-workerglobalscope-importscripts title=dom-WorkerGlobalScope-importScripts><code>importScripts(<var title="">urls</var>)</code></dfn> method on a
+ <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, the user agent must run the
+ following steps:</p>
+
+ <ol><li><p>If there are no arguments, return without doing
+ anything. Abort these steps.</li>
+
+ <li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> each
+ argument.</li>
+
+ <li><p>If any fail, throw a <code><a href=#syntaxerror>SyntaxError</a></code>
+ exception.</li>
+
+<!--
+ <li><p>If any of the resulting <span title="absolute URL">absolute
+ URLs</span> have an <span>origin</span> that is not the <span
+ title="same origin">same</span> as the origin of the script that
+ invoked the method, then throw a <code>SecurityError</code>
+ exception.</p></li>
+-->
+
+ <li>
+
+ <p>Attempt to <a href=#fetch>fetch</a> each resource identified by the
+ resulting <a href=#absolute-url title="absolute URL">absolute URLs</a>, from
+ the <a href=#entry-script>entry script</a>'s <a href=#origin>origin</a>, with the
+ <i>synchronous flag</i> set.</p> <!-- not http-origin privacy
+ sensitive -->
+
+ </li>
+
+ <li>
+
+ <p>For each argument in turn, in the order given, starting with
+ the first one, run these substeps:</p>
+
+ <ol><li>
+
+ <p>Wait for the fetching attempt for the corresponding resource
+ to complete.</p>
+
+ <p>If the fetching attempt failed, throw a
+ <code><a href=#networkerror>NetworkError</a></code> exception and abort all these
+ steps.</p>
+
+ <p>If the attempt succeeds, then let <var title="">source</var> be
+ the script resource <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error
+ handling</a>.
+ </p>
+
+ <p>Let <var title="">language</var> be JavaScript.</p>
+
+ <p class=note>As with the worker's script, the script here is
+ always assumed to be JavaScript, regardless of the MIME
+ type.</p>
+
+ </li>
+
+ <li>
+
+ <p><a href=#create-a-script>Create a script</a>, using <var title="">source</var> as the script source and <var title="">language</var> as the scripting language, using the
+ same global object, browsing context, URL character encoding,
+ base URL, and script group as the <a href=#concept-script title=concept-script>script</a> that was created by the
+ worker's <a href=#run-a-worker>run a worker</a> algorithm.</p>
+
+ <p>Let the newly created <a href=#concept-script title=concept-script>script</a> run until it either
+ returns, fails to parse, fails to catch an exception, or gets
+ prematurely aborted by the "<a href=#kill-a-worker>kill a worker</a>" or
+ "<a href=#terminate-a-worker>terminate a worker</a>" algorithms defined above.</p>
+
+ <p>If it failed to parse, then throw an ECMAScript
+ <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort all these
+ steps. <a href=#refsECMA262>[ECMA262]</a></p>
+
+ <p>If an exception was raised or if the script was prematurely
+ aborted, then abort all these steps, letting the exception or
+ aborting continue to be processed by the script that called the
+ <code title=dom-WorkerGlobalScope-importScripts><a href=#dom-workerglobalscope-importscripts>importScripts()</a></code>
+ method.</p>
+
+ <p>If the "<a href=#kill-a-worker>kill a worker</a>" or "<a href=#terminate-a-worker>terminate a
+ worker</a>" algorithms abort the script then abort all these
+ steps.</p>
+
+ </li>
+
+ </ol></li>
+
+ </ol><h4 id=the-workernavigator-object><span class=secno>10.3.2 </span>The <code><a href=#workernavigator>WorkerNavigator</a></code> object</h4>
+
+ <p>The <dfn id=dom-worker-navigator title=dom-worker-navigator><code>navigator</code></dfn> attribute
+ of the <code><a href=#workerutils>WorkerUtils</a></code> interface must return an instance of
+ the <code><a href=#workernavigator>WorkerNavigator</a></code> interface, which represents the
+ identity and state of the user agent (the client):</p>
+
+ <pre class=idl>interface <dfn id=workernavigator>WorkerNavigator</dfn> {};
+<a href=#workernavigator>WorkerNavigator</a> implements <a href=#navigatorid>NavigatorID</a>;
+<a href=#workernavigator>WorkerNavigator</a> implements <a href=#navigatoronline>NavigatorOnLine</a>;</pre>
+
+ <p>Objects implementing the <code><a href=#workernavigator>WorkerNavigator</a></code> interface
+ also implement the <code><a href=#navigatorid>NavigatorID</a></code> and
+ <code><a href=#navigatoronline>NavigatorOnLine</a></code> interfaces.
+ </p>
+
+ <p>This <code><a href=#workernavigator>WorkerNavigator</a></code> interface must not exist if the
+ interface's <span>relevant namespace object</span> is a
+ <code><a href=#window>Window</a></code> object. <a href=#refsWEBIDL>[WEBIDL]</a></p>
+
+
+
+
+ <h4 id=interface-objects-and-constructors><span class=secno>10.3.3 </span>Interface objects and constructors</h4>
+
+ <p>There must be no interface objects and constructors available in
+ the global scope of scripts whose <a href="#script's-global-object">script's global
+ object</a> is a <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object except for
+ the following:</p>
+
+ <ul><li><p><code>XMLHttpRequest</code> and all interface objects and
+ constructors defined by the XMLHttpRequest specifications, except
+ that the <span>document response entity body</span> must always be
+ null. The <span><code>XMLHttpRequest</code> base URL</span> is the
+ <a href="#script's-base-url">script's base URL</a>; the
+ <span><code>XMLHttpRequest</code> origin</span> is the script's
+ <a href=#origin>origin</a>. <a href=#refsXHR>[XHR]</a></li>
+
+ <li><p>The interface objects and constructors defined by this
+ specification.</li>
+
+ <li><p>Constructors defined by specifications that explicitly say
+ that they should be visible when the <a href="#script's-global-object">script's global
+ object</a> is a <code><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code>, a
+ <code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code>, or an object implementing the
+ <code><a href=#workerutils>WorkerUtils</a></code> interface; the interfaces of any objects
+ with such constructors; and the interfaces of any objects made
+ accessible through APIs exposed by those constructors or made
+ accessible through interfaces to be implemented by any objects that
+ are themselves accessible to scripts whose <a href="#script's-global-object">script's global
+ object</a> implements the <code><a href=#workerutils>WorkerUtils</a></code>
+ interface.</li>
+
+ </ul><p class=note>These requirements do not override the requirements
+ defined by the Web IDL specification, in particular concerning the
+ visibility of interfaces annotated with the <code title="">[NoInterfaceObject]</code> extended attribute.</p>
+
+
+ <h4 id=worker-locations><span class=secno>10.3.4 </span>Worker locations</h4>
+
+ <pre class=idl>interface <dfn id=workerlocation>WorkerLocation</dfn> {
+ // <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>
+ stringifier readonly attribute DOMString <a href=#dom-workerlocation-href title=dom-WorkerLocation-href>href</a>;
+ readonly attribute DOMString <a href=#dom-workerlocation-protocol title=dom-WorkerLocation-protocol>protocol</a>;
+ readonly attribute DOMString <a href=#dom-workerlocation-host title=dom-WorkerLocation-host>host</a>;
+ readonly attribute DOMString <a href=#dom-workerlocation-hostname title=dom-WorkerLocation-hostname>hostname</a>;
+ readonly attribute DOMString <a href=#dom-workerlocation-port title=dom-WorkerLocation-port>port</a>;
+ readonly attribute DOMString <a href=#dom-workerlocation-pathname title=dom-WorkerLocation-pathname>pathname</a>;
+ readonly attribute DOMString <a href=#dom-workerlocation-search title=dom-WorkerLocation-search>search</a>;
+ readonly attribute DOMString <a href=#dom-workerlocation-hash title=dom-WorkerLocation-hash>hash</a>;
+};</pre>
+
+ <p>A <code><a href=#workerlocation>WorkerLocation</a></code> object represents an <a href=#absolute-url>absolute
+ URL</a> set at its creation.</p>
+
+ <p>The <dfn id=dom-workerlocation-href title=dom-WorkerLocation-href><code>href</code></dfn>
+ attribute must return the <a href=#absolute-url>absolute URL</a> that the object
+ represents.</p>
+
+ <p>The <code><a href=#workerlocation>WorkerLocation</a></code> interface also has the complement
+ of <a href=#url-decomposition-idl-attributes>URL decomposition IDL attributes</a>, <dfn id=dom-workerlocation-protocol title=dom-WorkerLocation-protocol><code>protocol</code></dfn>,
+ <dfn id=dom-workerlocation-host title=dom-WorkerLocation-host><code>host</code></dfn>, <dfn id=dom-workerlocation-port title=dom-WorkerLocation-port><code>port</code></dfn>, <dfn id=dom-workerlocation-hostname title=dom-WorkerLocation-hostname><code>hostname</code></dfn>,
+ <dfn id=dom-workerlocation-pathname title=dom-WorkerLocation-pathname><code>pathname</code></dfn>,
+ <dfn id=dom-workerlocation-search title=dom-WorkerLocation-search><code>search</code></dfn>,
+ and <dfn id=dom-workerlocation-hash title=dom-WorkerLocation-hash><code>hash</code></dfn>.
+ These must follow the rules given for <a href=#url-decomposition-idl-attributes>URL decomposition IDL
+ attributes</a>, with the <a href=#concept-uda-input title=concept-uda-input>input</a> being the <a href=#absolute-url>absolute
+ URL</a> that the object represents (same as the <code title=dom-WorkerLocation-href><a href=#dom-workerlocation-href>href</a></code> attribute), and the
+ <a href=#concept-uda-setter title=concept-uda-setter>common setter action</a> being a
+ no-op, since the attributes are defined to be readonly.
+ </p>
+
+ <p>The <code><a href=#workerlocation>WorkerLocation</a></code> interface must not exist if the
+ interface's <span>relevant namespace object</span> is a
+ <code><a href=#window>Window</a></code> object. <a href=#refsWEBIDL>[WEBIDL]</a></p>
+
+
+
+
+
+
+ </div><!--data-component-->
+
+
+
<!--POSTMSG-->
- <h2 id=comms><span class=secno>10 </span>Communication</h2>
+ <h2 id=comms><span class=secno>11 </span>Communication</h2>
<div data-component="Web Messaging (editor: Ian Hickson)">
- <h3 id=event-definitions-2><span class=secno>10.1 </span>Event definitions</h3>
+ <h3 id=event-definitions-2><span class=secno>11.1 </span>Event definitions</h3>
- <p>Messages in <span>server-sent events</span>, <span>Web
- sockets</span>, <a href=#web-messaging>cross-document messaging</a>, and
+ <p>Messages in <a href=#server-sent-events>server-sent events</a>, <a href=#network>Web
+ sockets</a>, <a href=#web-messaging>cross-document messaging</a>, and
<a href=#channel-messaging>channel messaging</a> use the <dfn id=event-message title=event-message><code>message</code></dfn> event.
-
- <a href=#refsEVENTSOURCE>[EVENTSOURCE]</a>
- <a href=#refsWEBSOCKET>[WEBSOCKET]</a>
-
</p>
<p>The following interface is defined for this event:</p>
@@ -77074,8 +79490,8 @@
<dd>
- <p>Returns the origin of the message, for <span>server-sent
- events</span> and <a href=#web-messaging>cross-document messaging</a>.</p>
+ <p>Returns the origin of the message, for <a href=#server-sent-events>server-sent
+ events</a> and <a href=#web-messaging>cross-document messaging</a>.</p>
</dd>
@@ -77083,8 +79499,8 @@
<dd>
- <p>Returns the <span title=concept-event-stream-last-event-id>last event ID
- string</span>, for <span>server-sent events</span>.</p>
+ <p>Returns the <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID
+ string</a>, for <a href=#server-sent-events>server-sent events</a>.</p>
</dd>
@@ -77117,7 +79533,7 @@
<p>The <dfn id=dom-messageevent-origin title=dom-MessageEvent-origin><code>origin</code></dfn> attribute
must return the value it was initialized to. When the object is
created, this attribute must be initialized to the empty string. It
- represents, in <span>server-sent events</span> and
+ represents, in <a href=#server-sent-events>server-sent events</a> and
<a href=#web-messaging>cross-document messaging</a>, the <a href=#origin>origin</a> of
the document that sent the message (typically the scheme, hostname,
and port of the document, but not its path or fragment
@@ -77126,8 +79542,8 @@
<p>The <dfn id=dom-messageevent-lasteventid title=dom-MessageEvent-lastEventId><code>lastEventId</code></dfn>
attribute must return the value it was initialized to. When the
object is created, this attribute must be initialized to the empty
- string. It represents, in <span>server-sent events</span>, the <span title=concept-event-stream-last-event-id>last event ID
- string</span> of the event source.</p>
+ string. It represents, in <a href=#server-sent-events>server-sent events</a>, the <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID
+ string</a> of the event source.</p>
<p>The <dfn id=dom-messageevent-source title=dom-MessageEvent-source><code>source</code></dfn> attribute
must return the value it was initialized to. When the object is
@@ -77151,6 +79567,1472 @@
</div><!--data-component-->
<!--POSTMSG-->
+
+
+
+ <h3 id=server-sent-events><span class=secno>11.2 </span><dfn>Server-sent events</dfn></h3>
+
+ <div data-component="Server-Sent Events (editor: Ian Hickson)">
+
+
+
+ <h4 id=server-sent-events-intro><span class=secno>11.2.1 </span>Introduction</h4>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>To enable servers to push data to Web pages over HTTP or using
+ dedicated server-push protocols, this specification introduces the
+ <code><a href=#eventsource>EventSource</a></code> interface.</p>
+
+ <p>Using this API consists of creating an <code><a href=#eventsource>EventSource</a></code>
+ object and registering an event listener.</p>
+
+ <pre>var source = new EventSource('updates.cgi');
+source.onmessage = function (event) {
+ alert(event.data);
+};</pre>
+
+ <p>On the server-side, the script ("<code title="">updates.cgi</code>" in this case) sends messages in the
+ following form, with the <code><a href=#text/event-stream>text/event-stream</a></code> MIME
+ type:</p>
+
+ <pre>data: This is the first message.
+
+data: This is the second message, it
+data: has two lines.
+
+data: This is the third message.</pre>
+
+ <p>Using this API rather than emulating it using
+ <code>XMLHttpRequest</code> or an <code><a href=#the-iframe-element>iframe</a></code> allows the
+ user agent to make better use of network resources in cases where
+ the user agent implementor and the network operator are able to
+ coordinate in advance. Amongst other benefits, this can result in
+ significant savings in battery life on portable devices. This is
+ discussed further in the section below on <a href=#eventsource-push>connectionless push</a>.</p>
+
+
+ <h4 id=the-eventsource-interface><span class=secno>11.2.2 </span>The <code><a href=#eventsource>EventSource</a></code> interface</h4>
+
+ <pre class=idl>[<a href=#dom-eventsource title=dom-EventSource>Constructor</a>(DOMString url)]
+interface <dfn id=eventsource>EventSource</dfn> : <a href=#eventtarget>EventTarget</a> {
+ readonly attribute DOMString <a href=#dom-eventsource-url title=dom-EventSource-url>url</a>;
+
+ // ready state
+ const unsigned short <a href=#dom-eventsource-connecting title=dom-EventSource-CONNECTING>CONNECTING</a> = 0;
+ const unsigned short <a href=#dom-eventsource-open title=dom-EventSource-OPEN>OPEN</a> = 1;
+ const unsigned short <a href=#dom-eventsource-closed title=dom-EventSource-CLOSED>CLOSED</a> = 2;
+ readonly attribute unsigned short <a href=#dom-eventsource-readystate title=dom-EventSource-readyState>readyState</a>;
+
+ // networking
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onopen title=handler-EventSource-onopen>onopen</a>;
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onmessage title=handler-EventSource-onmessage>onmessage</a>;
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onerror title=handler-EventSource-onerror>onerror</a>;
+ void <a href=#dom-eventsource-close title=dom-EventSource-close>close</a>();
+};</pre>
+
+ <p>The <dfn id=dom-eventsource title=dom-EventSource><code>EventSource(<var title="">url</var>)</code></dfn> constructor takes one argument,
+ <var title="">url</var>, which specifies the <a href=#url>URL</a> to
+ which to connect. When the <code>EventSource()</code> constructor is
+ invoked, the UA must run these steps:</p>
+
+ <ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the
+ <a href=#url>URL</a> specified in <var title="">url</var>, relative to
+ the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base
+ URL">base URL</a>.</li>
+
+ <li><p>If the previous step failed, then throw a
+ <code><a href=#syntaxerror>SyntaxError</a></code> exception.</li>
+
+ <li><p>Return a new <code><a href=#eventsource>EventSource</a></code> object, and continue
+ these steps in the background (without blocking scripts).</li>
+
+ <li>
+
+ <p>Do a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the
+ resulting <a href=#absolute-url>absolute URL</a>, with the <i>mode</i> being
+ <a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use
+ Credentials</a>, and the <i><a href=#origin>origin</a></i> being the <a href=#entry-script>entry
+ script</a>'s <a href=#origin>origin</a><!--, and the <i>default origin
+ behaviour</i> set to <i>fail</i> (though it has no effect in the
+ "Use Credentials" mode)-->, and process the resource obtained in
+ this fashion, if any, as described below.</p>
+
+ <p class=note>The definition of the <a href=#fetch title=fetch>fetching</a> algorithm (which is used by CORS) is
+ such that if the browser is already fetching the resource
+ identified by the given <a href=#absolute-url>absolute URL</a>, that connection
+ can be reused, instead of a new connection being established. All
+ messages received up to this point are dispatched immediately, in
+ this case.</p>
+
+ </li>
+
+ </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global
+ object</a> is either a <code><a href=#window>Window</a></code> object or an object
+ implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p>
+
+ <hr><p>The <dfn id=dom-eventsource-url title=dom-EventSource-url><code>url</code></dfn>
+ attribute must return the <a href=#absolute-url>absolute URL</a> that resulted
+ from <a href=#resolve-a-url title="resolve a url">resolving</a> the value that was
+ passed to the constructor.</p> <!-- not the result of redirects,
+ since that would introduce race conditions -->
+
+ <p>The <dfn id=dom-eventsource-readystate title=dom-EventSource-readyState><code>readyState</code></dfn>
+ attribute represents the state of the connection. It can have the
+ following values:</p>
+
+ <dl><dt><dfn id=dom-eventsource-connecting title=dom-EventSource-CONNECTING><code>CONNECTING</code></dfn> (numeric value 0)</dt>
+
+ <dd>The connection has not yet been established, or it was closed
+ and the user agent is reconnecting.</dd>
+
+ <dt><dfn id=dom-eventsource-open title=dom-EventSource-OPEN><code>OPEN</code></dfn> (numeric value 1)</dt>
+
+ <dd>The user agent has an open connection and is dispatching events
+ as it receives them.</dd>
+
+ <dt><dfn id=dom-eventsource-closed title=dom-EventSource-CLOSED><code>CLOSED</code></dfn> (numeric value 2)</dt>
+
+ <dd>The connection is not open, and the user agent is not trying to
+ reconnect. Either there was a fatal error or the <code title=dom-EventSource-close><a href=#dom-eventsource-close>close()</a></code> method was
+ invoked.</dd>
+
+ </dl><p>When the object is created its <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> must be set to
+ <code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code> (0). The
+ rules given below for handling the connection define when the value
+ changes.</p>
+
+ <p>The <dfn id=dom-eventsource-close title=dom-EventSource-close><code>close()</code></dfn>
+ method must close the connection, if any; must abort any instances
+ of the <a href=#fetch>fetch</a> algorithm started for this
+ <code><a href=#eventsource>EventSource</a></code> object; and must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
+ <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>.</p>
+
+ <p>The following are the <a href=#event-handlers>event handlers</a> (and their
+ corresponding <a href=#event-handler-event-type title="event handler event type">event handler
+ event types</a>) that must be supported, as IDL attributes, by
+ all objects implementing the <code><a href=#eventsource>EventSource</a></code> interface:</p>
+
+ <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a>
+ <tbody><tr><td><dfn id=handler-eventsource-onopen title=handler-EventSource-onopen><code>onopen</code></dfn> <td> <code title=event-open>open</code>
+ <tr><td><dfn id=handler-eventsource-onmessage title=handler-EventSource-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code>
+ <tr><td><dfn id=handler-eventsource-onerror title=handler-EventSource-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code>
+ </table><hr><p>In addition to the above, each <code><a href=#eventsource>EventSource</a></code> object
+ has the following associated with it:</p>
+
+ <ul><li>A <dfn id=concept-event-stream-reconnection-time title=concept-event-stream-reconnection-time>reconnection
+ time</dfn>, in milliseconds. This must initially be a
+ user-agent-defined value, probably in the region of a few
+ seconds.</li>
+
+ <li>A <dfn id=concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event
+ ID string</dfn>. This must initially be the empty string.</li>
+
+ </ul><p>These values are not currently exposed on the interface.</p>
+
+
+ <h4 id=processing-model-5><span class=secno>11.2.3 </span>Processing model</h4>
+
+ <p>The resource indicated in the argument to the <code title=dom-EventSource><a href=#dom-eventsource>EventSource</a></code> constructor is <a href=#fetch title=fetch>fetched</a> when the constructor is run.</p>
+
+ <p>For HTTP connections, the <code title="">Accept</code> header may
+ be included; if included, it must contain only formats of event
+ framing that are supported by the user agent (one of which must be
+ <code><a href=#text/event-stream>text/event-stream</a></code>, as described below).</p>
+
+ <p>If the event source's <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID
+ string</a> is not the empty string, then a <code title=http-last-event-id><a href=#last-event-id>Last-Event-ID</a></code> HTTP header must be
+ included with the request, whose value is the value of the event
+ source's <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event
+ ID string</a>, encoded as UTF-8.</p>
+
+ <p>User agents should use the <code>Cache-Control: no-cache</code>
+ header in requests to bypass any caches for requests of event
+ sources. (This header is not a <a href=#custom-request-headers title="custom request
+ headers">custom request header</a>, so the user agent will still
+ use the CORS <a href=#simple-cross-origin-request>simple cross-origin request</a> mechanism.)
+ User agents should ignore HTTP cache headers in the response, never
+ caching event sources.</p>
+
+ <hr><p>As data is received, the <a href=#concept-task title=concept-task>tasks</a>
+ queued by the <a href=#networking-task-source>networking task source</a> to handle the data
+ must act as follows.</p>
+
+ <p>HTTP 200 OK responses with a <a href=#content-type>Content-Type</a> header
+ specifying the type <code><a href=#text/event-stream>text/event-stream</a></code>, either with no
+ parameters or with a single parameter with the name "<code title="">charset</code>" whose value is an <a href=#ascii-case-insensitive>ASCII
+ case-insensitive</a> match for the string "<code title="">utf-8</code>", must be processed line by line <a href=#event-stream-interpretation>as described below</a>.</p>
+
+ <p>When a successful response with a supported <a href=#mime-type>MIME
+ type</a> is received, such that the user agent begins parsing the
+ contents of the stream, the user agent must <a href=#announce-the-connection>announce the
+ connection</a>.</p>
+
+ <p>The <a href=#concept-task title=concept-task>task</a> that the
+ <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
+ queue</a> once the <a href=#fetch title=fetch>fetching algorithm</a>
+ for such a resource (with the correct <a href=#mime-type>MIME type</a>) has
+ completed must <a href=#reestablish-the-connection>reestablish the connection</a>. This applies
+ whether the connection is closed gracefully or unexpectedly. It
+ doesn't apply for the error conditions listed below.</p>
+
+ <p>HTTP 200 OK responses that have a <a href=#content-type>Content-Type</a>
+ specifying an unsupported type (including the
+ <code><a href=#text/event-stream>text/event-stream</a></code> type with unsupported parameters or
+ parameters with unsupported values), or that have no
+ <a href=#content-type>Content-Type</a> at all, must cause the user agent to
+ <a href=#fail-the-connection>fail the connection</a>.</p> <!-- about:blank is defined as
+ having no MIME type; javascript: as having the type text/html -->
+
+ <p>HTTP 305 Use Proxy, HTTP 401 Unauthorized, and 407 Proxy
+ Authentication Required should be treated transparently as for any
+ other subresource.</p>
+
+ <p>HTTP 301 Moved Permanently, HTTP 302 Found, 303 See Other, and
+ 307 Temporary Redirect responses are handled by the <a href=#fetch title=fetch>fetching</a> and CORS algorithms. In the case of
+ 301 redirects, the user agent must also remember the new URL so that
+ subsequent requests for this resource for this
+ <code><a href=#eventsource>EventSource</a></code> object start with the URL given for the
+ last 301 seen for requests for this object.</p>
+
+ <p>Any other HTTP response code not listed here, and any network
+ error that prevents the HTTP connection from being established in
+ the first place (e.g. DNS errors), must cause the user agent to
+ <a href=#fail-the-connection>fail the connection</a>.</p> <!-- including: HTTP 201
+ Created, HTTP 202 Accepted, HTTP 203 Non-Authoritative Information,
+ HTTP 204 No Content, HTTP 205 Reset Content, HTTP 206 Partial
+ Content, HTTP 300 Multiple Choices, HTTP 304 Not Modified, HTTP 400
+ Bad Request, 403 Forbidden, 404 Not Found, 405 Method Not Allowed,
+ 406 Not Acceptable, 408 Request Timeout, 409 Conflict, 410 Gone, 411
+ Length Required, 412 Precondition Failed, 413 Request Entity Too
+ Large, 414 Request-URI Too Long, 415 Unsupported Media Type, 416
+ Requested Range Not Satisfiable, 417 Expectation Failed, 500
+ Internal Server Error, 501 Not Implemented, 502 Bad Gateway, 503
+ Service Unavailable, 504 Gateway Timeout, and 505 HTTP Version Not
+ Supported responses --> <!-- mailto: is defined as equivalent to
+ HTTP 204 -->
+
+ <p>For non-HTTP protocols, UAs should act in equivalent ways.</p>
+
+ <hr><p>When a user agent is to <dfn id=announce-the-connection>announce the connection</dfn>, the
+ user agent must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
+ <code title=dom-EventSource-OPEN><a href=#dom-eventsource-open>OPEN</a></code> and <a href=#queue-a-task>queue a
+ task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-open>open</code> at the
+ <code><a href=#eventsource>EventSource</a></code> object.</p>
+
+ <p>When a user agent is to <dfn id=reestablish-the-connection>reestablish the connection</dfn>,
+ the user agent must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
+ <code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code>,
+ <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named
+ <code title=event-error>error</code> at the
+ <code><a href=#eventsource>EventSource</a></code> object, and then, after a delay equal to
+ the reconnection time of the event source, if the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute is
+ still set to <code title=dom-EventSource-CONNECTING><a href=#dom-eventsource-connecting>CONNECTING</a></code>, once again do
+ a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the <a href=#absolute-url>absolute
+ URL</a> of the event source resource, with the <i>mode</i> being
+ <a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use
+ Credentials</a>, and the <i><a href=#origin>origin</a></i> being the same as the
+ <a href=#origin>origin</a> used in the original request triggered by the
+ <code title=dom-EventSource><a href=#dom-eventsource>EventSource()</a></code> constructor<!--,
+ and the <i>default origin behaviour</i> set to <i>fail</i> (though
+ it has no effect in the "Use Credentials" mode)-->, and process the
+ resource obtained in this fashion, if any, as described in this
+ section.</p>
+
+ <p>When a user agent is to <dfn id=fail-the-connection>fail the connection</dfn>, the user
+ agent must set the <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> attribute to
+ <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code> and <a href=#queue-a-task>queue a
+ task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#eventsource>EventSource</a></code>
+ object. <strong>Once the user agent has <a href=#fail-the-connection title="fail the
+ connection">failed the connection</a>, it does <em>not</em>
+ attempt to reconnect!</strong></p>
+
+ <hr><p>The <a href=#task-source>task source</a> for any <a href=#concept-task title=concept-task>tasks</a> that are <a href=#queue-a-task title="queue a
+ task">queued</a> by <code><a href=#eventsource>EventSource</a></code> objects is the
+ <dfn id=remote-event-task-source>remote event task source</dfn>.</p>
+
+
+ <h4 id=parsing-an-event-stream><span class=secno>11.2.4 </span>Parsing an event stream</h4>
+
+ <p>This event stream format's <a href=#mime-type>MIME type</a> is
+ <code><a href=#text/event-stream>text/event-stream</a></code>.</p>
+
+ <p>The event stream format is as described by the <code title="">stream</code> production of the following ABNF, the
+ character set for which is Unicode. <a href=#refsABNF>[ABNF]</a></p>
+
+ <pre>stream = [ bom ] *event
+event = *( comment / field ) end-of-line
+comment = colon *any-char end-of-line
+field = 1*name-char [ colon [ space ] *any-char ] end-of-line
+end-of-line = ( cr lf / cr / lf )
+
+; characters
+lf = %x000A ; U+000A LINE FEED (LF)
+cr = %x000D ; U+000D CARRIAGE RETURN (CR)
+space = %x0020 ; U+0020 SPACE
+colon = %x003A ; U+003A COLON (:)
+bom = %xFEFF ; U+FEFF BYTE ORDER MARK
+name-char = %x0000-0009 / %x000B-000C / %x000E-0039 / %x003B-10FFFF
+ ; a <a href=#unicode-character>Unicode character</a> other than U+000A LINE FEED (LF), U+000D CARRIAGE RETURN (CR), or U+003A COLON (:)
+any-char = %x0000-0009 / %x000B-000C / %x000E-10FFFF
+ ; a <a href=#unicode-character>Unicode character</a> other than U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)</pre>
+
+ <p>Event streams in this format must always be encoded as
+ UTF-8. <a href=#refsRFC3629>[RFC3629]</a></p>
+
+ <p>Lines must be separated by either a U+000D CARRIAGE RETURN U+000A
+ LINE FEED (CRLF) character pair, a single U+000A LINE FEED (LF)
+ character, or a single U+000D CARRIAGE RETURN (CR) character.</p>
+
+ <p>Since connections established to remote servers for such
+ resources are expected to be long-lived, UAs should ensure that
+ appropriate buffering is used. In particular, while line buffering
+ with lines are defined to end with a single U+000A LINE FEED (LF)
+ character is safe, block buffering or line buffering with different
+ expected line endings can cause delays in event dispatch.</p>
+
+
+ <h4 id=event-stream-interpretation><span class=secno>11.2.5 </span>Interpreting an event stream</h4>
+
+ <p>Streams must be <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error
+ handling</a>.
+ </p>
+
+ <p>One leading U+FEFF BYTE ORDER MARK character must be ignored if
+ any are present.</p>
+
+ <p>The stream must then be parsed by reading everything line by
+ line, with a U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF)
+ character pair, a single U+000A LINE FEED (LF) character not
+ preceded by a U+000D CARRIAGE RETURN (CR) character, a single U+000D
+ CARRIAGE RETURN (CR) character not followed by a U+000A LINE FEED
+ (LF) character, and the end of the file being the four ways in which
+ a line can end.</p>
+
+ <p>When a stream is parsed, a <var title="">data</var> buffer and an
+ <var title="">event name</var> buffer must be associated with
+ it. They must be initialized to the empty string</p>
+
+ <p>Lines must be processed, in the order they are received, as
+ follows:</p>
+
+ <dl class=switch><dt>If the line is empty (a blank line)</dt>
+
+ <dd><p><a href=#dispatchMessage>Dispatch the event</a>, as
+ defined below.</dd>
+
+
+ <dt>If the line starts with a U+003A COLON character (:)</dt>
+
+ <dd><p>Ignore the line.</dd>
+
+
+ <dt>If the line contains a U+003A COLON character (:)</dt>
+
+ <dd>
+
+ <p>Collect the characters on the line before the first U+003A
+ COLON character (:), and let <var title="">field</var> be that
+ string.</p>
+
+ <p>Collect the characters on the line after the first U+003A COLON
+ character (:), and let <var title="">value</var> be that
+ string. If <var title="">value</var> starts with a U+0020
+ SPACE character, remove it from <var title="">value</var>.</p>
+
+ <p><a href=#processField>Process the field</a> using the steps
+ described below, using <var title="">field</var> as the field name
+ and <var title="">value</var> as the field value.</p>
+
+ </dd>
+
+
+ <dt>Otherwise, the string is not empty but does not contain a U+003A COLON character (:)</dt>
+
+ <dd>
+
+ <p><a href=#processField>Process the field</a> using the steps
+ described below, using the whole line as the field name, and
+ the empty string as the field value.</p>
+
+ </dd>
+
+ </dl><p>Once the end of the file is reached, any pending data must be
+ discarded. (If the file ends in the middle of an event, before the
+ final empty line, the incomplete event is not dispatched.)</p>
+
+ <hr><p id=processField>The steps to <dfn title="">process the
+ field</dfn> given a field name and a field value depend on the field
+ name, as given in the following list. Field names must be compared
+ literally, with no case folding performed.</p>
+
+ <dl class=switch><dt>If the field name is "event"</dt>
+
+ <dd><p>Set the <var title="">event name</var> buffer to field
+ value.</dd>
+
+
+ <dt>If the field name is "data"</dt>
+
+ <dd><p>Append the field value to the <var title="">data</var>
+ buffer, then append a single U+000A LINE FEED (LF) character to the
+ <var title="">data</var> buffer.</dd>
+
+
+ <dt>If the field name is "id"</dt>
+
+ <dd><p>Set the event stream's <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID</a> to
+ the field value.</dd>
+
+
+ <dt>If the field name is "retry"</dt>
+
+ <dd><p>If the field value consists of only characters in the range
+ U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then interpret the
+ field value as an integer in base ten, and set the event stream's
+ <a href=#concept-event-stream-reconnection-time title=concept-event-stream-reconnection-time>reconnection
+ time</a> to that integer. Otherwise, ignore the field.</dd>
+
+ <!-- v2 feature request from Per-Erik Brodin:
+ > > > Finally, it could be useful to be able to reset the reconnection
+ > > > time to the user agent default value by sending the retry field only
+ > > > and leave out the value similar to how you reset the last event id.
+ > >
+ > > What's the use case?
+ >
+ > Take the stock ticker as an example. When the stock market closes the
+ > server logic knows that there won't be any new events for a number of
+ > hours and so it can send the corresponding reconnection time and close
+ > the connection. If the client is still running by the time the market
+ > opens, it will reconnect, and the server can now reset the reconnection
+ > time to a time that is convenient for the user agent (which is the user
+ > agent default value, unknown to the server).
+ -->
+
+<!-- v2 feature request from John Fallows - http://www.w3.org/mid/c5b3a7130810271238h11e40a4fybfcd5983ed5dc08d@mail.gmail.com
+
+ <dt>If the field name is "reconnect"</dt>
+
+ <dd><p>If the field value is the empty string, then: <a
+ href="#dispatchMessage">dispatch the event</a> as defined below,
+ and then drop the connection and immediately reconnect as if the
+ <span title="concept-event-stream-reconnection-time">reconnection
+ time</span> was zero for this one time.</p></dd>
+
+ -->
+
+ <dt>Otherwise</dt>
+
+ <dd><p>The field is ignored.</dd>
+
+ </dl><p id=dispatchMessage>When the user agent is required to <dfn title="">dispatch the event</dfn>, then the user agent must act as
+ follows:
+
+ <ol><li><p>If the <var title="">data</var> buffer is an empty string,
+ set the <var title="">data</var> buffer and the <var title="">event
+ name</var> buffer to the empty string and abort these
+ steps.</li>
+
+ <li><p>If the <var title="">data</var> buffer's last character is a
+ U+000A LINE FEED (LF) character, then remove the last character
+ from the <var title="">data</var> buffer.</li>
+
+ <li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code>
+ interface, with the event name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is not
+ cancelable, and has no default action. The <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute must be
+ initialized to the value of the <var title="">data</var> buffer,
+ the <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> attribute
+ must be initialized to the <a href=#unicode-serialization-of-an-origin title="Unicode serialization of an
+ origin">Unicode serialization</a> of the <a href=#origin>origin</a> of
+ the event stream's URL, and the <code title=dom-MessageEvent-lastEventId><a href=#dom-messageevent-lasteventid>lastEventId</a></code> attribute
+ must be initialized to the <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID
+ string</a> of the event source.</li>
+
+ <li><p>If the <var title="">event name</var> buffer has a value
+ other than the empty string, change the <a href=#concept-event-type title=concept-event-type>type</a> of the newly created event
+ to equal the value of the <var title="">event name</var>
+ buffer.</li>
+
+ <li><p>Set the <var title="">data</var> buffer and the <var title="">event name</var> buffer to the empty string.</li>
+
+ <li><p><a href=#queue-a-task>Queue a task</a> to dispatch the newly created
+ event at the <code><a href=#eventsource>EventSource</a></code> object.</li>
+
+ </ol><p class=note>If an event doesn't have an "id" field, but an
+ earlier event did set the event source's <a href=#concept-event-stream-last-event-id title=concept-event-stream-last-event-id>last event ID
+ string</a>, then the event's <code title=dom-MessageEvent-lastEventId><a href=#dom-messageevent-lasteventid>lastEventId</a></code> field will
+ be set to the value of whatever the last seen "id" field was.</p>
+
+
+ <div class=example>
+
+ <p>The following event stream, once followed by a blank line:</p>
+ <pre>data: YHOO
+data: +2
+data: 10</pre>
+
+ <p>...would cause an event <code title=event-message><a href=#event-message>message</a></code> with the interface
+ <code><a href=#messageevent>MessageEvent</a></code> to be dispatched on the
+ <code><a href=#eventsource>EventSource</a></code> object. The event's <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute would contain
+ the string <code>YHOO\n+2\n10</code> (where <code>\n</code>
+ represents a newline).</p>
+
+ <p>This could be used as follows:
+ <pre>var stocks = new EventSource("http://stocks.example.com/ticker.php");
+stocks.onmessage = function (event) {
+ var data = event.data.split('\n');
+ updateStocks(data[0], data[1], data[2]);
+};</pre>
+
+ <p>...where <code title="">updateStocks()</code> is a function defined as:</p>
+
+ <pre>function updateStocks(symbol, delta, value) { ... }</pre>
+
+ <p>...or some such.</p>
+
+ </div>
+
+ <div class=example>
+
+ <p>The following stream contains four blocks. The first block has
+ just a comment, and will fire nothing. The second block has two
+ fields with names "data" and "id" respectively; an event will be
+ fired for this block, with the data "first event", and will then
+ set the last event ID to "1" so that if the connection died between
+ this block and the next, the server would be sent a <code title=http-last-event-id><a href=#last-event-id>Last-Event-ID</a></code> header with the
+ value "1". The third block fires an event with data "second event",
+ and also has an "id" field, this time with no value, which resets
+ the last event ID to the empty string (meaning no <code title=http-last-event-id><a href=#last-event-id>Last-Event-ID</a></code> header will now be
+ sent in the event of a reconnection being attempted). Finally, the
+ last block just fires an event with the data
+ " third event" (with a single leading space character).
+ Note that the last still has to end with a blank line, the end of
+ the stream is not enough to trigger the dispatch of the last
+ event.</p>
+
+ <pre>: test stream
+
+data: first event
+id: 1
+
+data:second event
+id
+
+data: third event
+</pre>
+ </div>
+
+ <div class=example>
+
+ <p>The following stream fires two events:</p>
+
+ <pre>data
+
+data
+data
+
+data:</pre>
+
+ <p>The first block fires events with the data set to the empty
+ string, as would the last block if it was followed by a blank line.
+ The middle block fires an event with the data set to a single
+ newline character. The last block is discarded because it is not
+ followed by a blank line.</p>
+
+ </div>
+
+ <div class=example>
+
+ <p>The following stream fires two identical events:</p>
+
+ <pre>data:test
+
+data: test
+</pre>
+
+ <p>This is because the space after the colon is ignored if
+ present.</p>
+
+ </div>
+
+
+ <h4 id=notes><span class=secno>11.2.6 </span>Notes</h4>
+
+ <p>Legacy proxy servers are known to, in certain cases, drop HTTP
+ connections after a short timeout. To protect against such proxy
+ servers, authors can include a comment line (one starting with a ':'
+ character) every 15 seconds or so.</p>
+
+ <p>Authors wishing to relate event source connections to each other
+ or to specific documents previously served might find that relying
+ on IP addresses doesn't work, as individual clients can have
+ multiple IP addresses (due to having multiple proxy servers) and
+ individual IP addresses can have multiple clients (due to sharing a
+ proxy server). It is better to include a unique identifier in the
+ document when it is served and then pass that identifier as part of
+ the URL when the connection is established.</p>
+
+ <p>Authors are also cautioned that HTTP chunking can have unexpected
+ negative effects on the reliability of this protocol. Where
+ possible, chunking should be disabled for serving event streams
+ unless the rate of messages is high enough for this not to
+ matter.</p> <!-- v2 can we get a better solution? -->
+
+ <p>Clients that support HTTP's per-server connection limitation
+ might run into trouble when opening multiple pages from a site if
+ each page has an <code><a href=#eventsource>EventSource</a></code> to the same
+ domain. Authors can avoid this using the relatively complex
+ mechanism of using unique domain names per connection, or by
+ allowing the user to enable or disable the <code><a href=#eventsource>EventSource</a></code>
+ functionality on a per-page basis, or by sharing a single
+ <code><a href=#eventsource>EventSource</a></code> object using a <a href=#sharedworkerglobalscope title=SharedWorkerGlobalScope>shared worker</a>.
+ </p>
+
+
+ <h4 id=eventsource-push><span class=secno>11.2.7 </span>Connectionless push and other features</h4>
+
+ <p>User agents running in controlled environments, e.g. browsers on
+ mobile handsets tied to specific carriers, may offload the
+ management of the connection to a proxy on the network. In such a
+ situation, the user agent for the purposes of conformance is
+ considered to include both the handset software and the network
+ proxy.</p>
+
+ <div class=example>
+
+ <p>For example, a browser on a mobile device, after having
+ established a connection, might detect that it is on a supporting
+ network and request that a proxy server on the network take over
+ the management of the connection. The timeline for such a situation
+ might be as follows:</p>
+
+ <ol><li>Browser connects to a remote HTTP server and requests the
+ resource specified by the author in the <code title=dom-EventSource><a href=#dom-eventsource>EventSource</a></code> constructor.</li>
+
+ <li>The server sends occasional messages.</li>
+
+ <li>In between two messages, the browser detects that it is idle
+ except for the network activity involved in keeping the TCP
+ connection alive, and decides to switch to sleep mode to save power.</li>
+
+ <li>The browser disconnects from the server.</li>
+
+ <li>The browser contacts a service on the network, and requests
+ that that service, a "push proxy", maintain the connection instead.</li>
+
+ <li>The "push proxy" service contacts the remote HTTP server and
+ requests the resource specified by the author in the <code title=dom-EventSource><a href=#dom-eventsource>EventSource</a></code> constructor (possibly
+ including a <code title=http-last-event-id><a href=#last-event-id>Last-Event-ID</a></code>
+ HTTP header, etc).</li>
+
+ <li>The browser allows the mobile device to go to sleep.</li>
+
+ <li>The server sends another message.</li>
+
+ <li>The "push proxy" service uses a technology such as OMA push to
+ convey the event to the mobile device, which wakes only
+ enough to process the event and then returns to sleep.</li>
+
+ </ol></div>
+
+ <p>This can reduce the total data usage, and can therefore result in
+ considerable power savings.</p>
+
+ <p>As well as implementing the existing API and
+ <code><a href=#text/event-stream>text/event-stream</a></code> wire format as defined by this
+ specification and in more distributed ways as described above,
+ formats of event framing defined by <a href=#other-applicable-specifications>other applicable
+ specifications</a> may be supported. This specification does not
+ define how they are to be parsed or processed.</p>
+
+
+ <h4 id=garbage-collection-1><span class=secno>11.2.8 </span>Garbage collection</h4>
+
+ <p>While an <code><a href=#eventsource>EventSource</a></code> object's <code title=dom-EventSource-readyState><a href=#dom-eventsource-readystate>readyState</a></code> is not <code title=dom-EventSource-CLOSED><a href=#dom-eventsource-closed>CLOSED</a></code>, and the object has one
+ or more event listeners registered for <code title=event-message><a href=#event-message>message</a></code> events, there must be a strong
+ reference from the <code><a href=#window>Window</a></code> or <code><a href=#workerutils>WorkerUtils</a></code>
+ object that the <code><a href=#eventsource>EventSource</a></code> object's constructor was
+ invoked from to the <code><a href=#eventsource>EventSource</a></code> object itself.</p>
+
+ <p>If an <code><a href=#eventsource>EventSource</a></code> object is garbage collected while
+ its connection is still open, the user agent must cancel any
+ instance of the <a href=#fetch title=fetch>fetch</a> algorithm opened by
+ this <code><a href=#eventsource>EventSource</a></code>, discarding any <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a
+ task">queued</a> for them, and discarding any further data
+ received from the network for them.</p>
+
+ <p class=note>It's possible for one active network connection to
+ be shared by multiple <code><a href=#eventsource>EventSource</a></code> objects and their
+ <a href=#fetch>fetch</a> algorithms, which is why the above is phrased in
+ terms of canceling the <a href=#fetch>fetch</a> algorithm and not the
+ actual underlying download.</p>
+
+
+ <h4 id=iana-considerations><span class=secno>11.2.9 </span>IANA considerations</h4>
+
+ <h5 id=text/event-stream><span class=secno>11.2.9.1 </span><dfn><code>text/event-stream</code></dfn></h5>
+
+ <p>This registration is for community review and will be submitted
+ to the IESG for review, approval, and registration with IANA.</p>
+
+ <!--
+ To: ietf-types at iana.org
+ Subject: Registration of media type text/event-stream
+ -->
+
+ <dl><dt>Type name:</dt>
+ <dd>text</dd>
+ <dt>Subtype name:</dt>
+ <dd>event-stream</dd>
+ <dt>Required parameters:</dt>
+ <dd>No parameters</dd>
+ <dt>Optional parameters:</dt>
+ <dd>
+ <dl><dt><code title="">charset</code></dt>
+ <dd>
+
+ <p>The <code title="">charset</code> parameter may be provided.
+ The parameter's value must be "<code title="">utf-8</code>".
+ This parameter serves no purpose; it is only allowed for
+ compatibility with legacy servers.</p>
+
+ </dd>
+ </dl></dd>
+ <dt>Encoding considerations:</dt>
+ <dd>8bit (always UTF-8)</dd>
+ <dt>Security considerations:</dt>
+ <dd>
+
+ <p>An event stream from an origin distinct from the origin of the
+ content consuming the event stream can result in information
+ leakage. To avoid this, user agents are required to apply CORS
+ semantics. <a href=#refsCORS>[CORS]</a></p>
+
+ <p>Event streams can overwhelm a user agent; a user agent is
+ expected to apply suitable restrictions to avoid depleting local
+ resources because of an overabundance of information from an event
+ stream.</p>
+
+ <p>Servers can be overwhelmed if a situation develops in which the
+ server is causing clients to reconnect rapidly. Servers should use
+ a 5xx status code to indicate capacity problems, as this will
+ prevent conforming clients from reconnecting automatically.</p>
+
+ </dd>
+ <dt>Interoperability considerations:</dt>
+ <dd>
+ Rules for processing both conforming and non-conforming content
+ are defined in this specification.
+ </dd>
+ <dt>Published specification:</dt>
+ <dd>
+ This document is the relevant specification.
+ </dd>
+ <dt>Applications that use this media type:</dt>
+ <dd>
+ Web browsers and tools using Web services.
+ </dd>
+ <dt>Additional information:</dt>
+ <dd>
+ <dl><dt>Magic number(s):</dt>
+ <dd>No sequence of bytes can uniquely identify an event stream.</dd>
+ <dt>File extension(s):</dt>
+ <dd>No specific file extensions are recommended for this type.</dd>
+ <dt>Macintosh file type code(s):</dt>
+ <dd>No specific Macintosh file type codes are recommended for this type.</dd>
+ </dl></dd>
+ <dt>Person & email address to contact for further information:</dt>
+ <dd>Ian Hickson <ian at hixie.ch></dd>
+ <dt>Intended usage:</dt>
+ <dd>Common</dd>
+ <dt>Restrictions on usage:</dt>
+ <dd>This format is only expected to be used by dynamic open-ended
+ streams served using HTTP or a similar protocol. Finite resources
+ are not expected to be labeled with this type.</dd>
+ <dt>Author:</dt>
+ <dd>Ian Hickson <ian at hixie.ch></dd>
+ <dt>Change controller:</dt>
+ <dd>W3C</dd>
+ </dl><p>Fragment identifiers have no meaning with
+ <code><a href=#text/event-stream>text/event-stream</a></code> resources.</p>
+
+
+ <h5 id=last-event-id><span class=secno>11.2.9.2 </span><dfn title=http-last-event-id><code>Last-Event-ID</code></dfn></h5>
+
+ <p>This section describes a header field for registration in the
+ Permanent Message Header Field Registry. <a href=#refsRFC3864>[RFC3864]</a></p>
+
+ <dl><dt>Header field name</dt>
+ <dd>Last-Event-ID</dd>
+ <dt>Applicable protocol</dt>
+ <dd>http</dd>
+ <dt>Status</dt>
+ <dd>standard</dd>
+ <dt>Author/Change controller</dt>
+ <dd>W3C</dd>
+ <dt>Specification document(s)</dt>
+ <dd>
+ This document is the relevant specification.
+ </dd>
+ <dt>Related information</dt>
+ <dd>None.</dd>
+ </dl></div><!--data-component-->
+
+
+ <h3 id=network><span class=secno>11.3 </span><dfn>Web sockets</dfn></h3>
+
+ <div data-component="WebSocket API (editor: Ian Hickson)">
+
+
+
+ <h4 id=network-intro><span class=secno>11.3.1 </span>Introduction</h4>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>To enable Web applications to maintain bidirectional
+ communications with server-side processes, this specification
+ introduces the <code><a href=#websocket>WebSocket</a></code> interface.</p>
+
+ <p class=note>This interface does not allow for raw access to the
+ underlying network. For example, this interface could not be used to
+ implement an IRC client without proxying messages through a custom
+ server.</p>
+
+
+ <h4 id=the-websocket-interface><span class=secno>11.3.2 </span>The <code><a href=#websocket>WebSocket</a></code> interface</h4>
+
+ <pre class=idl>[<a href=#dom-websocket title=dom-WebSocket>Constructor</a>(DOMString url, optional DOMString protocols),
+ <a href=#dom-websocket title=dom-WebSocket>Constructor</a>(DOMString url, optional DOMString[] protocols)]
+interface <dfn id=websocket>WebSocket</dfn> : <a href=#eventtarget>EventTarget</a> {
+ readonly attribute DOMString <a href=#dom-websocket-url title=dom-WebSocket-url>url</a>;
+
+ // ready state
+ const unsigned short <a href=#dom-websocket-connecting title=dom-WebSocket-CONNECTING>CONNECTING</a> = 0;
+ const unsigned short <a href=#dom-websocket-open title=dom-WebSocket-OPEN>OPEN</a> = 1;
+ const unsigned short <a href=#dom-websocket-closing title=dom-WebSocket-CLOSING>CLOSING</a> = 2;
+ const unsigned short <a href=#dom-websocket-closed title=dom-WebSocket-CLOSED>CLOSED</a> = 3;
+ readonly attribute unsigned short <a href=#dom-websocket-readystate title=dom-WebSocket-readyState>readyState</a>;
+ readonly attribute unsigned long <a href=#dom-websocket-bufferedamount title=dom-WebSocket-bufferedAmount>bufferedAmount</a>;
+
+ // networking
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-websocket-onopen title=handler-WebSocket-onopen>onopen</a>;
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-websocket-onerror title=handler-WebSocket-onerror>onerror</a>;
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-websocket-onclose title=handler-WebSocket-onclose>onclose</a>;
+ readonly attribute DOMString <a href=#dom-websocket-extensions title=dom-WebSocket-extensions>extensions</a>;
+ readonly attribute DOMString <a href=#dom-websocket-protocol title=dom-WebSocket-protocol>protocol</a>;
+ void <a href=#dom-websocket-close title=dom-WebSocket-close>close</a>([Clamp] optional unsigned short code, optional DOMString reason);
+
+ // messaging
+ [TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-websocket-onmessage title=handler-WebSocket-onmessage>onmessage</a>;
+ attribute DOMString <a href=#dom-websocket-binarytype title=dom-WebSocket-binaryType>binaryType</a>;
+ void <a href=#dom-websocket-send title=dom-WebSocket-send>send</a>(DOMString data);
+ void <a href=#dom-websocket-send title=dom-WebSocket-send>send</a>(<a href=#arraybuffer>ArrayBuffer</a> data);
+ void <a href=#dom-websocket-send title=dom-WebSocket-send>send</a>(<a href=#blob>Blob</a> data);
+};</pre>
+
+ <p>The <dfn id=dom-websocket title=dom-WebSocket><code>WebSocket(<var title="">url</var>, <var title="">protocols</var>)</code></dfn>
+ constructor takes one or two arguments. The first argument, <var title="">url</var>, specifies the <a href=#url>URL</a> to which to
+ connect. The second, <var title="">protocols</var>, if present, is
+ either a string or an array of strings. If it is a string, it is
+ equivalent to an array consisting of just that string; if it is
+ omitted, it is equivalent to the empty array. Each string in the
+ array is a subprotocol name. The connection will only be established
+ if the server reports that it has selected one of these
+ subprotocols. The subprotocol names must all be strings that match
+ the requirements for elements that comprise the value of <code title=http-sec-websocket-protocol>Sec-WebSocket-Protocol</code>
+ header fields as defined by the WebSocket protocol specification. <a href=#refsWSP>[WSP]</a></p>
+
+ <p>When the <code>WebSocket()</code> constructor is invoked, the UA
+ must run these steps:</p>
+
+ <ol><li><p><i><a href="#parse-a-websocket-url's-components">Parse a WebSocket URL's components</a></i> from the <var title="">url</var> argument, to obtain <var title="">host</var>,
+ <var title="">port</var>, <var title="">resource name</var>, and
+ <var title="">secure</var>. If this fails, throw a
+ <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps. <a href=#refsWSP>[WSP]</a></li>
+
+ <li><p>If <var title="">secure</var> is false but the
+ <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a> has a scheme
+ component that is itself a secure protocol, e.g. HTTPS, then throw
+ a <code><a href=#securityerror>SecurityError</a></code> exception.</li>
+
+ <li>
+
+ <p>If <var title="">port</var> is a port to which the user agent
+ is configured to block access, then throw a
+ <code><a href=#securityerror>SecurityError</a></code> exception. (User agents typically block
+ access to well-known ports like SMTP.)</p>
+
+ <!-- e.g. http://www.mozilla.org/projects/netlib/PortBanning.html -->
+
+ <p>Access to ports 80 and 443 should not be blocked, including the
+ unlikely cases when <var title="">secure</var> is false but <var title="">port</var> is 443 or <var title="">secure</var> is true
+ but <var title="">port</var> is 80.</p>
+ <!-- paragraph requested by zcorpan -->
+
+ </li>
+
+ <li>
+
+ <p>If <var title="">protocols</var> is absent, let <var title="">protocols</var> be an empty array.</p>
+
+ <p>Otherwise, if <var title="">protocols</var> is present and a
+ string, let <var title="">protocols</var> instead be an array
+ consisting of just that string.</p>
+
+ </li>
+
+ <li><p>If any of the values in <var title="">protocols</var> occur
+ more than once or otherwise fail to match the requirements for
+ elements that comprise the value of <code title=http-sec-websocket-protocol>Sec-WebSocket-Protocol</code>
+ header fields as defined by the WebSocket protocol specification,
+ then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these
+ steps. <a href=#refsWSP>[WSP]</a></li>
+
+ <li><p>Let <var title="">origin</var> be the <a href=#ascii-serialization-of-an-origin title="ASCII
+ serialization of an origin">ASCII serialization</a> of the
+ <a href=#origin>origin</a> of the <a href=#entry-script>entry script</a>,
+ <a href=#converted-to-ascii-lowercase>converted to ASCII lowercase</a>.</li>
+
+ <li><p>Return a new <code><a href=#websocket>WebSocket</a></code> object, and continue
+ these steps in the background (without blocking scripts).</li>
+
+ <li>
+
+ <p><i><a href=#establish-a-websocket-connection>Establish a WebSocket connection</a></i> given the set (<var title="">host</var>, <var title="">port</var>, <var title="">resource name</var>, <var title="">secure</var>), along
+ with the <var title="">protocols</var> list, an empty list for the
+ extensions, and <var title="">origin</var>. The <i><a href=#headers-to-send-appropriate-cookies>headers to send
+ appropriate cookies</a></i> must be a <code title=http-Cookie>Cookie</code> header whose value is the
+ <i><a href=#cookie-string>cookie-string</a></i> computed from the user's cookie store and the
+ URL <var title="">url</var>; for these purposes this is
+ <em>not</em> a "non-HTTP" API. <a href=#refsWSP>[WSP]</a> <a href=#refsCOOKIES>[COOKIES]</a></p>
+
+ <p>When the user agent <i title="validate the server's
+ response"><a href="#validate-the-server's-response">validates the server's response</a></i> during the
+ "<i><a href=#establish-a-websocket-connection>establish a WebSocket connection</a></i>" algorithm, if the status
+ code received from the server is not 101 (e.g. it is a redirect),
+ the user agent must <i><a href=#fail-the-websocket-connection>fail the websocket connection</a></i>.</p>
+
+ <p class=warning>Following HTTP procedures here could introduce
+ serious security problems in a Web browser context. For example,
+ consider a host with a WebSocket server at one path and an open
+ HTTP redirector at another. Suddenly, any script that can be given
+ a particular WebSocket URL can be tricked into communicating to
+ (and potentially sharing secrets with) any host on the Internet,
+ even if the script checks that the URL has the right hostname.</p>
+ <!-- http://www.ietf.org/mail-archive/web/hybi/current/msg06951.html -->
+
+ <p class=note>If the <i><a href=#establish-a-websocket-connection>establish a WebSocket connection</a></i>
+ algorithm fails, it triggers the <i><a href=#fail-the-websocket-connection>fail the WebSocket
+ connection</a></i> algorithm, which then invokes the <i><a href=#close-the-websocket-connection>close the
+ WebSocket connection</a></i> algorithm, which then establishes that
+ <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i>, which fires the <code title=event-close>close</code> event <a href=#closeWebSocket>as described below</a>.</p>
+
+ </li>
+
+ </ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global
+ object</a> is either a <code><a href=#window>Window</a></code> object or an object
+ implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p>
+
+ <hr><p>The <dfn id=dom-websocket-url title=dom-WebSocket-url><code>url</code></dfn>
+ attribute must return the result of <a href=#resolve-a-url title="resolve a
+ url">resolving</a> the <a href=#url>URL</a> that was passed to the
+ constructor. (It doesn't matter what it is resolved relative to,
+ since we already know it is an <a href=#absolute-url>absolute URL</a>.)</p>
+
+ <p>The <dfn id=dom-websocket-readystate title=dom-WebSocket-readyState><code>readyState</code></dfn>
+ attribute represents the state of the connection. It can have the
+ following values:</p>
+
+ <dl><dt><dfn id=dom-websocket-connecting title=dom-WebSocket-CONNECTING><code>CONNECTING</code></dfn> (numeric value 0)</dt>
+
+ <dd>The connection has not yet been established.</dd>
+
+ <dt><dfn id=dom-websocket-open title=dom-WebSocket-OPEN><code>OPEN</code></dfn> (numeric value 1)</dt>
+
+ <dd><i><a href=#the-websocket-connection-is-established>The WebSocket connection is established</a></i> and communication is possible.</dd>
+
+ <dt><dfn id=dom-websocket-closing title=dom-WebSocket-CLOSING><code>CLOSING</code></dfn> (numeric value 2)</dt>
+
+ <dd>The connection is going through the closing handshake.</dd>
+
+ <dt><dfn id=dom-websocket-closed title=dom-WebSocket-CLOSED><code>CLOSED</code></dfn> (numeric value 3)</dt>
+
+ <dd>The connection has been closed or could not be opened.</dd>
+
+ </dl><p>When the object is created its <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> must be set to
+ <code title=dom-WebSocket-CONNECTING><a href=#dom-websocket-connecting>CONNECTING</a></code> (0).</p>
+
+ <p>The <dfn id=dom-websocket-extensions title=dom-WebSocket-extensions><code>extensions</code></dfn>
+ attribute must initially return the empty string. After <i><a href=#the-websocket-connection-is-established>the
+ WebSocket connection is established</a></i>, its value might change, as
+ defined below.</p>
+
+ <p class=note>The <code title=dom-WebSocket-extensions><a href=#dom-websocket-extensions>extensions</a></code> attribute returns
+ the extensions selected by the server, if any. (Currently this will
+ only ever be the empty string.)</p>
+
+ <p>The <dfn id=dom-websocket-protocol title=dom-WebSocket-protocol><code>protocol</code></dfn> attribute
+ must initially return the empty string. After <i><a href=#the-websocket-connection-is-established>the WebSocket
+ connection is established</a></i>, its value might change, as defined
+ below.</p>
+
+ <p class=note>The <code title=dom-WebSocket-protocol><a href=#dom-websocket-protocol>protocol</a></code> attribute returns the
+ subprotocol selected by the server, if any. It can be used in
+ conjunction with the array form of the constructor's second argument
+ to perform subprotocol negotiation.</p>
+
+ <p>The <dfn id=dom-websocket-close title=dom-WebSocket-close><code>close()</code></dfn>
+ method must run the following steps:</p>
+
+ <ol><li><p>If the method's first argument is present but is not an
+ integer equal to 1000 or in the range 3000 to 4999, throw an
+ <code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception and abort these
+ steps.</li>
+
+ <li><p>If the method's second argument has any unpaired surrogates,
+ then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these
+ steps.</li>
+
+ <li><p>If the method's second argument is present, then let <var title="">reason</var> be the result of encoding that argument as
+ UTF-8. If <var title="">reason</var> is longer than 123 bytes, then
+ throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception and abort these steps.
+ <a href=#refsRFC3629>[RFC3629]</a></li>
+
+ <li><p>Run the first matching steps from the following list:</p>
+
+ <dl class=switch><dt>If the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code>
+ attribute is in the <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2) or <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (3) state</dt>
+
+ <dd>
+
+ <p>Do nothing.</p>
+
+ <p class=note>The connection is already closing or is already
+ closed. If it has not already, a <code title=event-close>close</code> event will eventually fire <a href=#closeWebSocket>as described below</a>.</p>
+
+ </dd>
+
+
+ <dt>If the WebSocket connection is not yet <i title="the
+ WebSocket connection is established"><a href=#the-websocket-connection-is-established>established</a></i> <a href=#refsWSP>[WSP]</a></dt>
+
+ <dd>
+
+ <p><i><a href=#fail-the-websocket-connection>Fail the WebSocket connection</a></i> and set the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's
+ value to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2).
+ <a href=#refsWSP>[WSP]</a></p>
+
+ <p class=note>The <i><a href=#fail-the-websocket-connection>fail the WebSocket connection</a></i>
+ algorithm invokes the <i><a href=#close-the-websocket-connection>close the WebSocket
+ connection</a></i> algorithm, which then establishes that
+ <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i>, which fires the
+ <code title=event-close>close</code> event <a href=#closeWebSocket>as described below</a>.</p>
+
+ </dd>
+
+
+ <dt>If the WebSocket closing handshake has not yet been <i title="the WebSocket closing handshake is
+ started"><a href=#the-websocket-closing-handshake-is-started>started</a></i> <a href=#refsWSP>[WSP]</a></dt>
+
+ <dd>
+
+ <p><i><a href=#start-the-websocket-closing-handshake>Start the WebSocket closing handshake</a></i> and set the
+ <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code>
+ attribute's value to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2). <a href=#refsWSP>[WSP]</a></p>
+
+ <p>If the first argument is present, then the status
+ code<!--CLOSE CODE--> to use in the WebSocket Close message must
+ be the integer given by the first argument. <a href=#refsWSP>[WSP]</a></p>
+
+ <p>If the second argument is also present, then <var title="">reason</var> must be provided in the Close message
+ after the status code<!--CLOSE CODE-->. <a href=#refsRFC3629>[RFC3629]</a> <a href=#refsWSP>[WSP]</a></p>
+
+ <p class=note>The <i><a href=#start-the-websocket-closing-handshake>start the WebSocket closing handshake</a></i>
+ algorithm eventually invokes the <i><a href=#close-the-websocket-connection>close the WebSocket
+ connection</a></i> algorithm, which then establishes that <i><a href=#the-websocket-connection-is-closed>the
+ WebSocket connection is closed</a></i>, which fires the <code title=event-close>close</code> event <a href=#closeWebSocket>as described below</a>.</p>
+
+ </dd>
+
+
+ <dt>Otherwise</dt>
+
+ <dd>
+
+ <p>Set the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's
+ value to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code>
+ (2).</p>
+
+ <p class=note><i><a href=#the-websocket-closing-handshake-is-started>The WebSocket closing handshake is
+ started</a></i>, and will eventually invoke the <i><a href=#close-the-websocket-connection>close the
+ WebSocket connection</a></i> algorithm, which will establish that
+ <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i>, and thus the <code title=event-close>close</code> event will fire, <a href=#closeWebSocket>as described below</a>.</p>
+
+ </dd>
+
+ </dl></li>
+
+ </ol><hr><p>The <dfn id=dom-websocket-bufferedamount title=dom-WebSocket-bufferedAmount><code>bufferedAmount</code></dfn>
+ attribute must return the number of bytes of application data (UTF-8
+ text and binary data) that have been queued using <code title=dom-WebSocket-send><a href=#dom-websocket-send>send()</a></code> but that, as of the last
+ time the <a href=#event-loop>event loop</a> started executing a <a href=#concept-task title=concept-task>task</a>, had not yet been transmitted to
+ the network. (This thus includes any text sent during the execution
+ of the current task, regardless of whether the user agent is able to
+ transmit text asynchronously with script execution.) This does not
+ include framing overhead incurred by the protocol, or buffering done
+ by the operating system or network hardware. If the connection is
+ closed, this attribute's value will only increase with each call to
+ the <code title=dom-WebSocket-send><a href=#dom-websocket-send>send()</a></code> method (the
+ number does not reset to zero once the connection closes).</p>
+
+ <div class=example>
+
+ <p>In this simple example, the <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
+ attribute is used to ensure that updates are sent either at the
+ rate of one update every 50ms, if the network can handle that rate,
+ or at whatever rate the network <em>can</em> handle, if that is too
+ fast.</p>
+
+ <pre>var socket = new WebSocket('ws://game.example.com:12010/updates');
+socket.onopen = function () {
+ setInterval(function() {
+ if (socket.bufferedAmount == 0)
+ socket.send(getUpdateData());
+ }, 50);
+};</pre>
+
+ <p>The <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
+ attribute can also be used to saturate the network without sending
+ the data at a higher rate than the network can handle, though this
+ requires more careful monitoring of the value of the attribute over
+ time.</p>
+
+ </div>
+
+ <hr><p>When a <code><a href=#websocket>WebSocket</a></code> object is created, its <dfn id=dom-websocket-binarytype title=dom-WebSocket-binaryType><code>binaryType</code></dfn> IDL
+ attribute must be set to the string "<code title="">blob</code>". On
+ getting, it must return the last value it was set to. On setting, if
+ the new value is either the string "<code title="">blob</code>" or
+ the string "<code title="">arraybuffer</code>", then set the IDL
+ attribute to this new value. Otherwise, throw a
+ <code><a href=#syntaxerror>SyntaxError</a></code> exception.</p>
+
+ <p class=note>This attribute allows authors to control how binary
+ data is exposed to scripts. By setting the attribute to "<code title="">blob</code>", binary data is returned in <code><a href=#blob>Blob</a></code>
+ form; by setting it to "<code title="">arraybuffer</code>", it is
+ returned in <code><a href=#arraybuffer>ArrayBuffer</a></code> form. User agents can use this
+ as a hint for how to handle incoming binary data: if the attribute
+ is set to "<code title="">blob</code>", it is safe to spool it to
+ disk, and if it is set to "<code title="">arraybuffer</code>", it is
+ likely more efficient to keep the data in memory. Naturally, user
+ agents are encouraged to use more subtle heuristics to decide
+ whether to keep incoming data in memory or not, e.g. based on how
+ big the data is or how common it is for a script to change the
+ attribute at the last minute. This latter aspect is important in
+ particular because it is quite possible for the attribute to be
+ changed after the user agent has received the data but before the
+ user agent as fired the event for it.</p>
+
+ <p>The <dfn id=dom-websocket-send title=dom-WebSocket-send><code>send(<var title="">data</var>)</code></dfn> method transmits data using the
+ connection. If the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute is
+ <code title=dom-WebSocket-CONNECTING><a href=#dom-websocket-connecting>CONNECTING</a></code>, it must
+ throw an <code><a href=#invalidstateerror>InvalidStateError</a></code> exception. Otherwise, the
+ user agent must run the appropriate set of steps from the following
+ list:</p>
+
+ <dl><dt>If the argument is a string</dt>
+
+ <dd>
+
+ <p>If the <var title="">data</var> argument has any unpaired
+ surrogates, then throw a <code><a href=#syntaxerror>SyntaxError</a></code> exception. If
+ <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, and the string has
+ no unpaired surrogates, and <i title="the WebSocket closing
+ handshake is started"><a href=#the-websocket-closing-handshake-is-started>the WebSocket closing handshake has not yet
+ started</a></i>, then the user agent must <i>send a WebSocket
+ Message</i> comprised of <var title="">data</var> using a text
+ frame opcode; if the data cannot be sent, e.g. because it would
+ need to be buffered but the buffer is full, the user agent must
+ <i><a href=#close-the-websocket-connection>close the WebSocket connection</a></i> <a href=#concept-websocket-close-fail title=concept-websocket-close-fail>with prejudice</a>. Any
+ invokation of this method with a string argument that does not
+ throw an exception must increase the <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
+ attribute by the number of bytes needed to express the argument as
+ UTF-8. <a href=#refsRFC3629>[RFC3629]</a> <a href=#refsWSP>[WSP]</a></p>
+
+ </dd>
+
+
+ <dt>If the argument is a <code><a href=#blob>Blob</a></code> object</dt>
+
+ <dd>
+
+ <p>If <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, and <i title="the WebSocket closing handshake is started"><a href=#the-websocket-closing-handshake-is-started>the WebSocket
+ closing handshake has not yet started</a></i>, then the user agent
+ must <i>send a WebSocket Message</i> comprised of <var title="">data</var> using a binary frame opcode; if the data
+ cannot be sent, e.g. because it would need to be buffered but the
+ buffer is full, the user agent must <i><a href=#close-the-websocket-connection>close the WebSocket
+ connection</a></i> <a href=#concept-websocket-close-fail title=concept-websocket-close-fail>with
+ prejudice</a>. The data to be sent is the raw data represented
+ by the <code><a href=#blob>Blob</a></code> object. <!-- that sentence is meant to
+ invoke "This interface represents immutable raw data." --> Any
+ invokation of this method with a <code><a href=#blob>Blob</a></code> argument that
+ does not throw an exception must increase the <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
+ attribute by the size of the <code><a href=#blob>Blob</a></code> object's raw data,
+ in bytes. <!-- that sentence is meant to invoke the same as
+ Blob.size --> <a href=#refsWSP>[WSP]</a> <a href=#refsFILEAPI>[FILEAPI]</a></p>
+
+ </dd>
+
+
+ <dt>If the argument is an <code><a href=#arraybuffer>ArrayBuffer</a></code> object</dt>
+
+ <dd>
+
+ <p>If <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, and <i title="the WebSocket closing handshake is started"><a href=#the-websocket-closing-handshake-is-started>the WebSocket
+ closing handshake has not yet started</a></i>, then the user agent
+ must <i>send a WebSocket Message</i> comprised of <var title="">data</var> using a binary frame opcode; if the data
+ cannot be sent, e.g. because it would need to be buffered but the
+ buffer is full, the user agent must <i><a href=#close-the-websocket-connection>close the WebSocket
+ connection</a></i> <a href=#concept-websocket-close-fail title=concept-websocket-close-fail>with
+ prejudice</a>. The data to be sent is the data stored in the
+ buffer described by the <code><a href=#arraybuffer>ArrayBuffer</a></code> object. <!-- that
+ sentence is meant to invoke "The ArrayBuffer type describes a
+ buffer used to store data for the array buffer views." at the top
+ of the Typed Array spec --> Any invokation of this method with an
+ <code><a href=#arraybuffer>ArrayBuffer</a></code> argument that does not throw an exception
+ must increase the <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
+ attribute by the length of the <code><a href=#arraybuffer>ArrayBuffer</a></code> in bytes.
+ <!-- that sentence is meant to invoke the same as
+ ArrayBuffer.byteLength --> <a href=#refsWSP>[WSP]</a> <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p>
+
+ </dd>
+
+ </dl><hr><p>The following are the <a href=#event-handlers>event handlers</a> (and their
+ corresponding <a href=#event-handler-event-type title="event handler event type">event handler
+ event types</a>) that must be supported, as IDL attributes, by
+ all objects implementing the <code><a href=#websocket>WebSocket</a></code> interface:</p>
+
+ <table><thead><tr><th><a href=#event-handlers title="event handlers">Event handler</a> <th><a href=#event-handler-event-type>Event handler event type</a>
+ <tbody><tr><td><dfn id=handler-websocket-onopen title=handler-WebSocket-onopen><code>onopen</code></dfn> <td> <code title=event-open>open</code>
+ <tr><td><dfn id=handler-websocket-onmessage title=handler-WebSocket-onmessage><code>onmessage</code></dfn> <td> <code title=event-message><a href=#event-message>message</a></code>
+ <tr><td><dfn id=handler-websocket-onerror title=handler-WebSocket-onerror><code>onerror</code></dfn> <td> <code title=event-error>error</code>
+ <tr><td><dfn id=handler-websocket-onclose title=handler-WebSocket-onclose><code>onclose</code></dfn> <td> <code title=event-close>close</code>
+ </table><h4 id=feedback-from-the-protocol><span class=secno>11.3.3 </span>Feedback from the protocol</h4>
+
+ <p>When <i><a href=#the-websocket-connection-is-established>the WebSocket connection is established</a></i>, the user
+ agent must <a href=#queue-a-task>queue a task</a> to run these steps:</p>
+
+ <ol><li><p>Change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's
+ value to <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1).</li>
+
+ <li><p>Change the <code title=dom-WebSocket-extensions><a href=#dom-websocket-extensions>extensions</a></code> attribute's
+ value to the <i><a href=#extensions-in-use>extensions in use</a></i>, if is not the null value. <a href=#refsWSP>[WSP]</a></li>
+
+ <li><p>Change the <code title=dom-WebSocket-protocol><a href=#dom-websocket-protocol>protocol</a></code> attribute's value to
+ the <i><a href=#subprotocol-in-use>subprotocol in use</a></i>, if is not the null value. <a href=#refsWSP>[WSP]</a></li>
+
+ <li><p>Act as if the user agent had <a href=#receives-a-set-cookie-string title="receives a
+ set-cookie-string">received a set-cookie-string</a> consisting
+ of the <i><a href="#cookies-set-during-the-server's-opening-handshake">cookies set during the server's opening handshake</a></i>,
+ for the URL <var title="">url</var> given to the <code title=dom-WebSocket><a href=#dom-websocket>WebSocket()</a></code> constructor. <a href=#refsCOOKIES>[COOKIES]</a> <a href=#refsRFC3629>[RFC3629]</a> <a href=#refsWSP>[WSP]</a></li>
+
+ <li><p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-open>open</code> at the <code><a href=#websocket>WebSocket</a></code>
+ object.</p>
+
+ </ol><hr><p>When <i><a href=#a-websocket-message-has-been-received>a WebSocket message has been received</a></i> with type <var title="">type</var> and data <var title="">data</var>, the user
+ agent must <a href=#queue-a-task>queue a task</a> to follow these steps: <a href=#refsWSP>[WSP]</a></p>
+
+ <ol><li>
+
+ <p>If the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code>
+ attribute's value is not <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1) or <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2), then abort these
+ steps.</p>
+
+ </li>
+
+ <li>
+
+ <p>Let <var title="">event</var> be an event that uses the
+ <code><a href=#messageevent>MessageEvent</a></code> interface, with the event name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is
+ not cancelable, and has no default action.</p>
+
+ </li>
+
+ <li><p>Initialize <var title="">event</var>'s <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> attribute to the
+ <a href=#unicode-serialization-of-an-origin title="Unicode serialization of an origin">Unicode
+ serialization</a> of the <a href=#origin>origin</a> of the
+ <a href=#url>URL</a> that was passed to the <code><a href=#websocket>WebSocket</a></code>
+ object's constructor.</li>
+
+ <li>
+
+ <p>If <var title="">type</var> indicates that the data is Text,
+ then initialize <var title="">event</var>'s <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute to <var title="">data</var>.
+
+ <p>If <var title="">type</var> indicates that the data is Binary,
+ and <code title=dom-WebSocket-binaryType><a href=#dom-websocket-binarytype>binaryType</a></code> is
+ set to "<code title="">blob</code>", then initialize <var title="">event</var>'s <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute to a new
+ <code><a href=#blob>Blob</a></code> object that represents <var title="">data</var>
+ as its raw data. <a href=#refsFILEAPI>[FILEAPI]</a></p>
+
+ <p>If <var title="">type</var> indicates that the data is Binary,
+ and <code title=dom-WebSocket-binaryType><a href=#dom-websocket-binarytype>binaryType</a></code> is
+ set to "<code title="">arraybuffer</code>", then initialize <var title="">event</var>'s <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute to a new
+ read-only <code><a href=#arraybuffer>ArrayBuffer</a></code> object whose contents are <var title="">data</var>. <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p>
+
+ </li>
+
+ <li>
+
+ <p>Dispatch <var title="">event</var> at the
+ <code><a href=#websocket>WebSocket</a></code> object.</p>
+
+ </li>
+
+ </ol><p class=note>User agents are encouraged to check if they can
+ perform the above steps efficiently before they run the task,
+ picking tasks from other <a href=#task-queue title="task queue">task queues</a>
+ while they prepare the buffers if not. For example, if the <code title=dom-WebSocket-binaryType><a href=#dom-websocket-binarytype>binaryType</a></code> attribute was set
+ to "<code title="">blob</code>" when the data arrived, and the user
+ agent spooled all the data to disk, but just before running the
+ above <a href=#concept-task title=concept-task>task</a> for this particular
+ message the script switched <code title=dom-WebSocket-binaryType><a href=#dom-websocket-binarytype>binaryType</a></code> to "<code title="">arraybuffer</code>", the user agent would want to page the
+ data back to RAM before running this <a href=#concept-task title=concept-task>task</a> so as to avoid stalling the main
+ thread while it created the <code><a href=#arraybuffer>ArrayBuffer</a></code> object.</p>
+
+ <hr><p>When <i><a href=#the-websocket-closing-handshake-is-started>the WebSocket closing handshake is started</a></i>, the user
+ agent must <a href=#queue-a-task>queue a task</a> to change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
+ to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2). (If the
+ <code title=dom-WebSocket-close><a href=#dom-websocket-close>close()</a></code> method was called,
+ the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code>
+ attribute's value will already be set to <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2) when this task
+ runs.) <a href=#refsWSP>[WSP]</a></p>
+
+ <hr><p id=closeWebSocket>When <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is
+ closed</a></i>, possibly <i title="">cleanly</i>, the user agent must
+ <a href=#queue-a-task>queue a task</a> to run the following substeps:</p>
+
+ <ol><li><p>Change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's
+ value to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code>
+ (3).</li>
+
+ <li><p>If the user agent was required to <i><a href=#fail-the-websocket-connection>fail the websocket
+ connection</a></i> or <i><a href=#the-websocket-connection-is-closed>the WebSocket connection is closed</a></i> <dfn id=concept-websocket-close-fail title=concept-websocket-close-fail>with prejudice</dfn>,
+ <a href=#fire-a-simple-event>fire a simple event</a> named <code title="">error</code>
+ at the <code><a href=#websocket>WebSocket</a></code> object. <a href=#refsWSP>[WSP]</a></li>
+
+ <li><p>Create an event that uses the <code><a href=#closeevent>CloseEvent</a></code>
+ interface, with the event name <code title=event-close>close</code>, which does not bubble, is not
+ cancelable, has no default action, whose <code title=dom-CloseEvent-wasClean><a href=#dom-closeevent-wasclean>wasClean</a></code> attribute is initialized to
+ true if the connection closed <i title="">cleanly</i> and false
+ otherwise, whose <code title=dom-CloseEvent-code><a href=#dom-closeevent-code>code</a></code>
+ attribute is initialized to <i><a href=#the-websocket-connection-close-code>the WebSocket connection close code</a></i>, and
+ whose <code title=dom-CloseEvent-reason><a href=#dom-closeevent-reason>reason</a></code> attribute
+ is initialized to <i><a href=#the-websocket-connection-close-reason>the WebSocket connection close reason</a></i>
+ <a href=#decoded-as-utf-8,-with-error-handling>decoded as UTF-8, with error handling</a>, and dispatch
+ the event at the <code><a href=#websocket>WebSocket</a></code> object. <a href=#refsWSP>[WSP]</a></li>
+
+ </ol><p>The <a href=#task-source>task source</a> for all <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a
+ task">queued</a> in this section is the <dfn id=websocket-task-source>WebSocket task
+ source</dfn>.</p>
+
+
+ <h5 id=event-definitions-3><span class=secno>11.3.3.1 </span>Event definitions</h5>
+
+ <pre class=idl>[Constructor(DOMString type, optional <a href=#closeeventinit>CloseEventInit</a> eventInitDict)]
+interface <dfn id=closeevent>CloseEvent</dfn> : <a href=#event>Event</a> {
+ readonly attribute boolean <a href=#dom-closeevent-wasclean title=dom-CloseEvent-wasClean>wasClean</a>;
+ readonly attribute unsigned short <a href=#dom-closeevent-code title=dom-CloseEvent-code>code</a>;
+ readonly attribute DOMString <span title=dom-WebSocket-reason>reason</span>;
+};
+
+dictionary <dfn id=closeeventinit>CloseEventInit</dfn> : <a href=#eventinit>EventInit</a> {
+ boolean wasClean;
+ unsigned short code;
+ DOMString reason;
+};</pre>
+
+ <p>The <dfn id=dom-closeevent-wasclean title=dom-CloseEvent-wasClean><code>wasClean</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to false. It
+ represents whether the connection closed cleanly or not.</p>
+
+ <p>The <dfn id=dom-closeevent-code title=dom-CloseEvent-code><code>code</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to zero. It
+ represents the WebSocket connection close code provided by the
+ server.</p>
+
+ <p>The <dfn id=dom-closeevent-reason title=dom-CloseEvent-reason><code>reason</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to empty
+ string. It represents the WebSocket connection close reason provided
+ by the server.</p>
+
+
+
+ <h5 id=garbage-collection-2><span class=secno>11.3.3.2 </span>Garbage collection</h5>
+
+ <p>A <code><a href=#websocket>WebSocket</a></code> object whose <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
+ was set to <code title=dom-WebSocket-CONNECTING><a href=#dom-websocket-connecting>CONNECTING</a></code>
+ (0) as of the last time the <a href=#event-loop>event loop</a> started
+ executing a <a href=#concept-task title=concept-task>task</a> must not be
+ garbage collected if there are any event listeners registered for
+ <code title=event-open>open</code> events, <code title=event-message><a href=#event-message>message</a></code> events, <code title=event-error>error</code> events, or <code title=event-close>close</code> events.</p>
+
+ <p>A <code><a href=#websocket>WebSocket</a></code> object whose <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
+ was set to <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1) or <code title=dom-WebSocket-CLOSING><a href=#dom-websocket-closing>CLOSING</a></code> (2) as of the last time
+ the <a href=#event-loop>event loop</a> started executing a <a href=#concept-task title=concept-task>task</a> must not be garbage collected if
+ there are any event listeners registered for <code title=event-message><a href=#event-message>message</a></code> events, <code title=event-error>error</code>, or <code title=event-close>close</code> events.</p>
+
+ <p>A <code><a href=#websocket>WebSocket</a></code> object with <i title="the WebSocket
+ connection is established"><a href=#the-websocket-connection-is-established>an established connection</a></i> that has
+ data queued to be transmitted to the network must not be garbage
+ collected. <a href=#refsWSP>[WSP]</a></p>
+
+ <p>If a <code><a href=#websocket>WebSocket</a></code> object is garbage collected while its
+ connection is still open, the user agent must <i><a href=#start-the-websocket-closing-handshake>start the
+ WebSocket closing handshake</a></i>, with no status code<!--CLOSE
+ CODE--> for the Close message. <a href=#refsWSP>[WSP]</a></p>
+
+ <hr><p>If a user agent is to <dfn id=make-disappear>make disappear</dfn> a
+ <code><a href=#websocket>WebSocket</a></code> object (this happens when a
+ <code><a href=#document>Document</a></code> object goes away), the user agent must follow
+ the first appropriate set of steps from the following list:</p>
+
+ <dl class=switch><dt>If the WebSocket connection is not yet <i title="the WebSocket
+ connection is established"><a href=#the-websocket-connection-is-established>established</a></i> <a href=#refsWSP>[WSP]</a></dt>
+
+ <dd>
+
+ <p><i><a href=#fail-the-websocket-connection>Fail the WebSocket connection</a></i>. <a href=#refsWSP>[WSP]</a></p>
+
+ </dd>
+
+
+ <dt>If the WebSocket closing handshake has not yet been <i title="the WebSocket closing handshake is started"><a href=#the-websocket-closing-handshake-is-started>started</a></i>
+ <a href=#refsWSP>[WSP]</a></dt>
+
+ <dd>
+
+ <p><i><a href=#start-the-websocket-closing-handshake>Start the WebSocket closing handshake</a></i>, with the
+ status code<!--CLOSE CODE--> to use in the WebSocket Close message
+ being 1001. <a href=#refsWSP>[WSP]</a></p>
+
+ </dd>
+
+
+ <dt>Otherwise</dt>
+
+ <dd>
+
+ <p>Do nothing.</p>
+
+ </dd>
+
+ </dl></div><!--data-component-->
+
+
<!--POSTMSG-->
@@ -77159,7 +81041,7 @@
- <h3 id=web-messaging><span class=secno>10.2 </span><dfn id=crossDocumentMessages>Cross-document messaging</dfn></h3>
+ <h3 id=web-messaging><span class=secno>11.4 </span><dfn id=crossDocumentMessages>Cross-document messaging</dfn></h3>
<p>Web browsers, for security and privacy reasons, prevent documents
in different domains from affecting each other; that is, cross-site
@@ -77180,7 +81062,7 @@
</div>
- <h4 id=introduction-13><span class=secno>10.2.1 </span>Introduction</h4>
+ <h4 id=introduction-14><span class=secno>11.4.1 </span>Introduction</h4>
<p><i>This section is non-normative.</i></p>
@@ -77221,11 +81103,11 @@
</div>
- <h4 id=security-postmsg><span class=secno>10.2.2 </span>Security</h4>
+ <h4 id=security-postmsg><span class=secno>11.4.2 </span>Security</h4>
<div class=impl>
- <h5 id=authors><span class=secno>10.2.2.1 </span>Authors</h5>
+ <h5 id=authors><span class=secno>11.4.2.1 </span>Authors</h5>
</div>
@@ -77253,7 +81135,7 @@
<div class=impl>
- <h5 id=user-agents><span class=secno>10.2.2.2 </span>User agents</h5>
+ <h5 id=user-agents><span class=secno>11.4.2.2 </span>User agents</h5>
<p>The integrity of this API is based on the inability for scripts
of one <a href=#origin>origin</a> to post arbitrary events (using <code title="">dispatchEvent()</code> or otherwise) to objects in other
@@ -77269,7 +81151,7 @@
</div>
- <h4 id=posting-messages><span class=secno>10.2.3 </span>Posting messages</h4>
+ <h4 id=posting-messages><span class=secno>11.4.3 </span>Posting messages</h4>
<dl class=domintro><dt><var title="">window</var> . <code title=dom-window-postMessage><a href=#dom-window-postmessage>postMessage</a></code>(<var title="">message</var>, <var title="">targetOrigin</var> [, <var title="">transfer</var> ])</dt>
@@ -77435,9 +81317,9 @@
- <h3 id=channel-messaging><span class=secno>10.3 </span><dfn>Channel messaging</dfn></h3>
+ <h3 id=channel-messaging><span class=secno>11.5 </span><dfn>Channel messaging</dfn></h3>
- <h4 id=introduction-14><span class=secno>10.3.1 </span>Introduction</h4>
+ <h4 id=introduction-15><span class=secno>11.5.1 </span>Introduction</h4>
<p><i>This section is non-normative.</i></p>
@@ -77474,7 +81356,7 @@
}</pre>
- <h4 id=message-channels><span class=secno>10.3.2 </span>Message channels</h4>
+ <h4 id=message-channels><span class=secno>11.5.2 </span>Message channels</h4>
<pre class=idl>[<a href=#dom-messagechannel title=dom-MessageChannel>Constructor</a>]
interface <dfn id=messagechannel>MessageChannel</dfn> {
@@ -77532,7 +81414,7 @@
</ol><p>This constructor must be visible when the <a href="#script's-global-object">script's global
object</a> is either a <code><a href=#window>Window</a></code> object or an object
- implementing the <code>WorkerUtils</code> interface.</p>
+ implementing the <code><a href=#workerutils>WorkerUtils</a></code> interface.</p>
<p>The <dfn id=dom-channel-port1 title=dom-channel-port1><code>port1</code></dfn> and
<dfn id=dom-channel-port2 title=dom-channel-port2><code>port2</code></dfn> attributes
@@ -77543,7 +81425,7 @@
- <h4 id=message-ports><span class=secno>10.3.3 </span>Message ports</h4>
+ <h4 id=message-ports><span class=secno>11.5.3 </span>Message ports</h4>
<p>Each channel has two message ports. Data sent through one port is
received by the other port, and vice versa.</p>
@@ -77877,7 +81759,7 @@
</div>
- <h5 id=ports-and-garbage-collection><span class=secno>10.3.3.1 </span>Ports and garbage collection</h5>
+ <h5 id=ports-and-garbage-collection><span class=secno>11.5.3.1 </span>Ports and garbage collection</h5>
<div class=impl>
@@ -77927,15 +81809,713 @@
<!--POSTMSG-->
- <h2 id=syntax><span class=secno>11 </span><dfn>The HTML syntax</dfn></h2>
+
+
+
+ <div data-component="Web Storage (editor: Ian Hickson)">
+
+ <h2 id=webstorage><span class=secno>12 </span>Web storage</h2>
+
+
+
+ <h3 id=introduction-16><span class=secno>12.1 </span>Introduction</h3>
+
+ <p><i>This section is non-normative.</i></p>
+
+ <p>This specification introduces two related mechanisms, similar to
+ HTTP session cookies, for storing structured data on the client
+ side. <a href=#refsCOOKIES>[COOKIES]</a></p>
+
+ <p>The first is designed for scenarios where the user is carrying
+ out a single transaction, but could be carrying out multiple
+ transactions in different windows at the same time.</p>
+
+ <p>Cookies don't really handle this case well. For example, a user
+ could be buying plane tickets in two different windows, using the
+ same site. If the site used cookies to keep track of which ticket
+ the user was buying, then as the user clicked from page to page in
+ both windows, the ticket currently being purchased would "leak" from
+ one window to the other, potentially causing the user to buy two
+ tickets for the same flight without really noticing.</p>
+
+ <p>To address this, this specification introduces the <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> IDL attribute.
+ Sites can add data to the session storage, and it will be accessible
+ to any page from the same site opened in that window.</p> <!-- we're
+ not using xrefs here because this is just an intro -->
+
+ <div class=example>
+
+ <p>For example, a page could have a checkbox that the user ticks to
+ indicate that he wants insurance:</p>
+
+ <pre><label>
+ <input type="checkbox" onchange="sessionStorage.insurance = checked ? 'true' : ''">
+ I want insurance on this trip.
+</label></pre>
+
+ <p>A later page could then check, from script, whether the user had
+ checked the checkbox or not:</p>
+
+ <pre>if (sessionStorage.insurance) { ... }</pre>
+
+ <p>If the user had multiple windows opened on the site, each one
+ would have its own individual copy of the session storage object.</p>
+
+ </div>
+
+ <!--
+
+ sessionStorage.flightDeparture = 'OSL';
+ sessionStorage.flightArrival = 'NYC';
+
+ for (var i in forms[0].elements)
+ sessionStorage["data_" + i.name] = i.value;
+
+ // if we add storage of non-strings
+ if (!sessionStorage[documents])
+ sessionStorage[documents] = {};
+ sessionStorage[documents][filename] = <document/>;
+
+ -->
+
+ <p>The second storage mechanism is designed for storage that spans
+ multiple windows, and lasts beyond the current session. In
+ particular, Web applications may wish to store megabytes of user
+ data, such as entire user-authored documents or a user's mailbox, on
+ the client side for performance reasons.</p>
+
+ <p>Again, cookies do not handle this case well, because they are
+ transmitted with every request.</p>
+
+ <p>The <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> IDL
+ attribute is used to access a page's local storage area.</p>
+
+ <div class=example>
+
+ <p>The site at example.com can display a count of how many times
+ the user has loaded its page by putting the following at the bottom
+ of its page:</p>
+
+ <pre><p>
+ You have viewed this page
+ <span id="count">an untold number of</span>
+ time(s).
+</p>
+<script>
+ if (!localStorage.pageLoadCount)
+ localStorage.pageLoadCount = 0;
+ localStorage.pageLoadCount = parseInt(localStorage.pageLoadCount) + 1;
+ document.getElementById('count').textContent = localStorage.pageLoadCount;
+</script></pre>
+
+ </div>
+
+ <p>Each site has its own separate storage area.</p>
+
+
+
+
+ <h3 id=storage><span class=secno>12.2 </span>The API</h3>
+
+ <h4 id=the-storage-interface><span class=secno>12.2.1 </span>The <code><a href=#storage-0>Storage</a></code> interface</h4>
+
+ <pre class=idl>interface <dfn id=storage-0>Storage</dfn> {
+ readonly attribute unsigned long <a href=#dom-storage-length title=dom-Storage-length>length</a>;
+ DOMString? <a href=#dom-storage-key title=dom-Storage-key>key</a>(unsigned long index);
+ getter DOMString <a href=#dom-storage-getitem title=dom-Storage-getItem>getItem</a>(DOMString key);
+ setter creator void <a href=#dom-storage-setitem title=dom-Storage-setItem>setItem</a>(DOMString key, DOMString value);
+ deleter void <a href=#dom-storage-removeitem title=dom-Storage-removeItem>removeItem</a>(DOMString key);
+ void <a href=#dom-storage-clear title=dom-Storage-clear>clear</a>();
+};</pre>
+
+ <!-- v2 ideas:
+ a getInfo() method that returns an object that tells you:
+ - when the key was added
+ - when the key was last modified
+ - which page was the last to modify the key
+ [-Mihai Sucan]
+
+ support non-string values
+ -->
+
+ <p>Each <code><a href=#storage-0>Storage</a></code> object provides access to a list of
+ key/value pairs, which are sometimes called items. Keys are
+ strings. Any string (including the empty string) is a valid
+ key. Values are similarly strings.</p>
+
+ <p>Each <code><a href=#storage-0>Storage</a></code> object is associated with a list of
+ key/value pairs when it is created, as defined in the sections on
+ the <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> and <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attributes. Multiple
+ separate objects implementing the <code><a href=#storage-0>Storage</a></code> interface can
+ all be associated with the same list of key/value pairs
+ simultaneously.</p>
+
+ <p>The <dfn id=dom-storage-length title=dom-Storage-length><code>length</code></dfn>
+ attribute must return the number of key/value pairs currently
+ present in the list associated with the object.</p>
+
+ <p>The <dfn id=dom-storage-key title=dom-Storage-key><code>key(<var title="">n</var>)</code></dfn> method must return the name of the
+ <var title="">n</var>th key in the list. The order of keys is
+ user-agent defined, but must be consistent within an object so long
+ as the number of keys doesn't change. (Thus, <a href=#dom-storage-setitem title=dom-Storage-setItem>adding</a> or <a href=#dom-storage-removeitem title=dom-Storage-removeItem>removing</a> a key may change the
+ order of the keys, but merely changing the value of an existing key
+ must not.) <!--The order of keys may differ between instances of the
+ <code>Storage</code> interface accessing the same list. [removed for
+ now for clarity, but if people ask, put it back. this is part of the
+ spec.]--> If <var title="">n</var> is <!--less than zero or [can't,
+ unsigned]--> greater than or equal to the number of key/value pairs
+ in the object, then this method must return null.</p>
+
+ <p>The <a href=#supported-property-names>supported property names</a> on a
+ <code><a href=#storage-0>Storage</a></code> object are the keys of each key/value pair
+ currently present in the list associated with the object.</p>
+
+ <p>The <dfn id=dom-storage-getitem title=dom-Storage-getItem><code>getItem(<var title="">key</var>)</code></dfn> method must return
+ the current value associated with
+ the given <var title="">key</var>. If the given <var title="">key</var> does not exist in the list associated with the
+ object then this method must return null.
+ </p>
+
+ <p>The <dfn id=dom-storage-setitem title=dom-Storage-setItem><code>setItem(<var title="">key</var>, <var title="">value</var>)</code></dfn> method
+ must first check if a key/value pair
+ with the given <var title="">key</var> already exists in the list
+ associated with the object.</p>
+
+ <p>If it does not, then a new key/value pair must be added to the
+ list, with the given <var title="">key</var> and with its value set
+ to <var title="">value</var>.</p>
+
+ <p>If the given <var title="">key</var> <em>does</em> exist in the
+ list, then it must have its value updated to <var title="">value</var>.</p>
+
+ <p>If it couldn't set the new value, the method must throw an
+ <code><a href=#quotaexceedederror>QuotaExceededError</a></code> exception. (Setting could fail if,
+ e.g., the user has disabled storage for the site, or if the quota
+ has been exceeded.)</p>
+
+ <p>The <dfn id=dom-storage-removeitem title=dom-Storage-removeItem><code>removeItem(<var title="">key</var>)</code></dfn> method must cause the key/value
+ pair with the given <var title="">key</var> to be removed from the
+ list associated with the object, if it exists. If no item with that
+ key exists, the method must do nothing.</p>
+
+ <p>The <code title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code> and <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code> methods must be
+ atomic with respect to failure. In the case of failure, the method
+ does nothing. That is, changes to the data storage area must either
+ be successful, or the data storage area must not be changed at
+ all.</p>
+
+ <p>The <dfn id=dom-storage-clear title=dom-Storage-clear><code>clear()</code></dfn>
+ method must atomically cause the list associated with the object to
+ be emptied of all key/value pairs, if there are any. If there are
+ none, then the method must do nothing.</p>
+
+ <p class=note>When the <code title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code>, <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code title=dom-Storage-clear><a href=#dom-storage-clear>clear()</a></code> methods are invoked, events
+ are fired on other <code><a href=#document>Document</a></code> objects that can access the
+ newly stored or removed data, as defined in the sections on the
+ <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> and <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attributes.</p> <!--
+ not normative, see the sections below for the normative statement
+ -->
+
+ <p class=note>This specification does not require that the above
+ methods wait until the data has been physically written to
+ disk. Only consistency in what different scripts accessing the same
+ underlying list of key/value pairs see is required.</p>
+
+
+ <h4 id=the-sessionstorage-attribute><span class=secno>12.2.2 </span>The <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> attribute</h4>
+
+ <pre class=idl>[NoInterfaceObject]
+interface <dfn id=windowsessionstorage>WindowSessionStorage</dfn> {
+ readonly attribute <a href=#storage-0>Storage</a> <a href=#dom-sessionstorage title=dom-sessionStorage>sessionStorage</a>;
+};
+<a href=#window>Window</a> implements <a href=#windowsessionstorage>WindowSessionStorage</a>;</pre>
+
+ <p>The <dfn id=dom-sessionstorage title=dom-sessionStorage><code>sessionStorage</code></dfn>
+ attribute represents the set of storage areas specific to the
+ current <a href=#top-level-browsing-context>top-level browsing context</a>.</p>
+
+ <p>Each <a href=#top-level-browsing-context>top-level browsing context</a> has a unique set of
+ session storage areas, one for each <a href=#origin>origin</a>.</p>
+
+ <p>User agents should not expire data from a browsing context's
+ session storage areas, but may do so when the user requests that
+ such data be deleted, or when the UA detects that it has limited
+ storage space, or for security reasons. User agents should always
+ avoid deleting data while a script that could access that data is
+ running. When a top-level browsing context is destroyed (and
+ therefore permanently inaccessible to the user) the data stored in
+ its session storage areas can be discarded with it, as the API
+ described in this specification provides no way for that data to
+ ever be subsequently retrieved.</p>
+
+ <p class=note>The lifetime of a browsing context can be unrelated
+ to the lifetime of the actual user agent process itself, as the user
+ agent may support resuming sessions after a restart.</p>
+
+ <p>When a new <code><a href=#document>Document</a></code> is created in a <a href=#browsing-context>browsing
+ context</a> which has a <a href=#top-level-browsing-context>top-level browsing context</a>,
+ the user agent must check to see if that <a href=#top-level-browsing-context>top-level browsing
+ context</a> has a session storage area for that document's
+ <a href=#origin>origin</a>. If it does, then that is the
+ <code><a href=#document>Document</a></code>'s assigned session storage area. If it does
+ not, a new storage area for that document's <a href=#origin>origin</a> must
+ be created, and then <em>that</em> is the <code><a href=#document>Document</a></code>'s
+ assigned session storage area. A <code><a href=#document>Document</a></code>'s assigned
+ storage area does not change during the lifetime of a
+ <code><a href=#document>Document</a></code>, even in the case of a <a href=#nested-browsing-context>nested browsing
+ context</a> (e.g. in an <code><a href=#the-iframe-element>iframe</a></code>) being moved to
+ another <a href=#parent-browsing-context>parent browsing context</a>.</p>
+
+ <p>The <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code>
+ attribute must return a <code><a href=#storage-0>Storage</a></code> object associated with
+ the <code><a href=#document>Document</a></code>'s assigned session storage area, if any,
+ or null if there isn't one. Each <code><a href=#document>Document</a></code> object must
+ have a separate object for its <code><a href=#window>Window</a></code>'s <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code> attribute.</p>
+
+ <p>When a new <a href=#top-level-browsing-context>top-level browsing context</a> is created by
+ cloning an existing <a href=#browsing-context>browsing context</a>, the new browsing
+ context must start with the same session storage areas as the
+ original, but the two sets must from that point on be considered
+ separate, not affecting each other in any way.</p>
+
+ <p>When a new <a href=#top-level-browsing-context>top-level browsing context</a> is created by
+ a <a href=#concept-script title=concept-script>script</a> in an existing
+ <a href=#browsing-context>browsing context</a>, or by the user following a link in an
+ existing browsing context, or in some other way related to a
+ specific <code><a href=#document>Document</a></code>, then the session storage area of the
+ <a href=#origin>origin</a> of that <code><a href=#document>Document</a></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><a href=#dom-storage-setitem>setItem()</a></code>, <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code title=dom-Storage-clear><a href=#dom-storage-clear>clear()</a></code> methods are called on a
+ <code><a href=#storage-0>Storage</a></code> object <var title="">x</var> that is associated
+ with a session storage area, if the methods did something, then in
+ every <code><a href=#document>Document</a></code> object whose <code><a href=#window>Window</a></code>
+ object's <code title=dom-sessionStorage><a href=#dom-sessionstorage>sessionStorage</a></code>
+ attribute's <code><a href=#storage-0>Storage</a></code> object is associated with the same
+ storage area, other than <var title="">x</var>, a <code title=event-storage><a href=#event-storage>storage</a></code> event must be fired, as <a href=#event-storage title=event-storage>described below</a>.</p>
+
+
+ <h4 id=the-localstorage-attribute><span class=secno>12.2.3 </span>The <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute</h4>
+
+ <pre class=idl>[NoInterfaceObject]
+interface <dfn id=windowlocalstorage>WindowLocalStorage</dfn> {
+ readonly attribute <a href=#storage-0>Storage</a> <a href=#dom-localstorage title=dom-localStorage>localStorage</a>;
+};
+<a href=#window>Window</a> implements <a href=#windowlocalstorage>WindowLocalStorage</a>;</pre>
+
+ <p>The <dfn id=dom-localstorage title=dom-localStorage><code>localStorage</code></dfn>
+ object provides a <code><a href=#storage-0>Storage</a></code> object for an
+ <a href=#origin>origin</a>.</p>
+
+ <p>User agents must have a set of local storage areas, one for each
+ <a href=#origin>origin</a>.</p>
+
+ <p>User agents should expire data from the local storage areas only
+ for security reasons or when requested to do so by the user. User
+ agents should always avoid deleting data while a script that could
+ access that data is running.</p>
+
+ <p>When the <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code>
+ attribute is accessed, the user agent must run the following steps,
+ which are known as the <dfn id=storage-object-initialization-steps><code>Storage</code> object
+ initialization steps</dfn>:</p> <!-- these steps are named because
+ marcos uses them from another spec -->
+
+ <ol><li><p>The user agent may throw a <code><a href=#securityerror>SecurityError</a></code>
+ exception instead of returning a <code><a href=#storage-0>Storage</a></code> object if the
+ request violates a policy decision (e.g. if the user agent is
+ configured to not allow the page to persist data).</li>
+
+ <li><p>If the <code><a href=#document>Document</a></code>'s <a href=#origin>origin</a> is not a
+ scheme/host/port tuple, then throw a <code><a href=#securityerror>SecurityError</a></code>
+ exception and abort these steps.</li>
+
+ <li><p>Check to see if the user agent has allocated a local storage
+ area for the <a href=#origin>origin</a> of the <code><a href=#document>Document</a></code> of
+ the <code><a href=#window>Window</a></code> object on which the attribute was accessed.
+ If it has not, create a new storage area for that
+ <a href=#origin>origin</a>.</li>
+
+ <li><p>Return the <code><a href=#storage-0>Storage</a></code> object associated with that
+ origin's local storage area. Each <code><a href=#document>Document</a></code> object must
+ have a separate object for its <code><a href=#window>Window</a></code>'s <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute.</p>
+
+ </ol><p id=localStorageEvent>When the <code title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code>, <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code title=dom-Storage-clear><a href=#dom-storage-clear>clear()</a></code> methods are called on a
+ <code><a href=#storage-0>Storage</a></code> object <var title="">x</var> that is associated
+ with a local storage area, if the methods did something, then in
+ every <code><a href=#document>Document</a></code> object whose <code><a href=#window>Window</a></code>
+ object's <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code>
+ attribute's <code><a href=#storage-0>Storage</a></code> object is associated with the same
+ storage area, other than <var title="">x</var>, a <code title=event-storage><a href=#event-storage>storage</a></code> event must be fired, as <a href=#event-storage title=event-storage>described below</a>.</p>
+
+ <p id=localStorageMutex>Whenever the properties of a <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute's
+ <code><a href=#storage-0>Storage</a></code> object are to be examined, returned, set, or
+ deleted, whether as part of a direct property access, when checking
+ for the presence of a property, during property enumeration, when
+ determining the number of properties present, or as part of the
+ execution of any of the methods or attributes defined on the
+ <code><a href=#storage-0>Storage</a></code> interface, the user agent must first
+ <a href=#obtain-the-storage-mutex>obtain the storage mutex</a>.</p>
+
+
+ <h5 id=security-localStorage><span class=secno>12.2.3.1 </span>Security</h5>
+
+ <p>User agents must throw a <code><a href=#securityerror>SecurityError</a></code> exception
+ whenever any of the members of a <code><a href=#storage-0>Storage</a></code> object
+ originally returned by the <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute are accessed
+ by scripts whose <a href=#effective-script-origin>effective script origin</a> is not the
+ <a href=#same-origin title="same origin">same</a> as the <a href=#origin>origin</a> of
+ the <code><a href=#document>Document</a></code> of the <code><a href=#window>Window</a></code> object on which
+ the <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> attribute was
+ accessed.</p>
+
+ <p class=note>This means <code><a href=#storage-0>Storage</a></code> objects are neutered
+ when the <code title=dom-document-domain><a href=#dom-document-domain>document.domain</a></code>
+ attribute is used.</p>
+
+
+
+ <h4 id=the-storage-event><span class=secno>12.2.4 </span>The <code title=event-storage><a href=#event-storage>storage</a></code> event</h4>
+
+ <p>The <dfn id=event-storage title=event-storage><code>storage</code></dfn> event
+ is fired when a storage area changes, as described in the previous
+ two sections (<a href=#sessionStorageEvent>for session
+ storage</a>, <a href=#localStorageEvent>for local
+ storage</a>).</p>
+
+ <p>When this happens, the user agent must <a href=#queue-a-task>queue a task</a>
+ to fire an event with the name <code><a href=#storage-0>storage</a></code>, which does not
+ bubble and is not cancelable, and which uses the
+ <code><a href=#storageevent>StorageEvent</a></code> interface, at each <code><a href=#window>Window</a></code>
+ object whose <code><a href=#document>Document</a></code> object has a <code><a href=#storage-0>Storage</a></code>
+ object that is affected.</p>
+
+ <p class=note>This includes <code><a href=#document>Document</a></code> objects that are
+ not <a href=#fully-active>fully active</a>, but events fired on those are ignored
+ by the <a href=#event-loop>event loop</a> until the <code><a href=#document>Document</a></code>
+ becomes <a href=#fully-active>fully active</a> again.</p>
+
+ <p>The <a href=#task-source>task source</a> for this task is the <a href=#dom-manipulation-task-source>DOM
+ manipulation task source</a>.</p>
+
+ <p>If the event is being fired due to an invocation of the <code title=dom-Storage-setItem><a href=#dom-storage-setitem>setItem()</a></code> or <code title=dom-Storage-removeItem><a href=#dom-storage-removeitem>removeItem()</a></code> methods, the
+ event must have its <code title=dom-StorageEvent-key><a href=#dom-storageevent-key>key</a></code>
+ attribute initialized to the name of the key in question, its <code title=dom-StorageEvent-oldValue><a href=#dom-storageevent-oldvalue>oldValue</a></code> attribute initialized to
+ the old value of the key in question, or null if the key is newly
+ added, and its <code title=dom-StorageEvent-newValue><a href=#dom-storageevent-newvalue>newValue</a></code> attribute initialized to
+ the new value of the key in question, or null if the key was
+ removed.</p>
+
+ <p>Otherwise, if the event is being fired due to an invocation of
+ the <code title=dom-Storage-clear><a href=#dom-storage-clear>clear()</a></code> method, the event
+ must have its <code title=dom-StorageEvent-key><a href=#dom-storageevent-key>key</a></code>, <code title=dom-StorageEvent-oldValue><a href=#dom-storageevent-oldvalue>oldValue</a></code>, and <code title=dom-StorageEvent-newValue><a href=#dom-storageevent-newvalue>newValue</a></code> attributes
+ initialized to null.</p>
+
+ <p>In addition, the event must have its <code title=dom-StorageEvent-url><a href=#dom-storageevent-url>url</a></code> attribute initialized to
+ <a href="#the-document's-address" title="the document's address">the address of the
+ document</a> whose <code><a href=#storage-0>Storage</a></code> object was affected; and
+ its <code title=dom-StorageEvent-storageArea><a href=#dom-storageevent-storagearea>storageArea</a></code>
+ attribute initialized to the <code><a href=#storage-0>Storage</a></code> object from the
+ <code><a href=#window>Window</a></code> object of the target <code><a href=#document>Document</a></code> that
+ represents the same kind of <code><a href=#storage-0>Storage</a></code> area as was
+ affected (i.e. session or local).</p>
+
+
+ <h5 id=event-definition-0><span class=secno>12.2.4.1 </span>Event definition</h5>
+
+ <pre class=idl>[Constructor(DOMString type, optional <a href=#storageeventinit>StorageEventInit</a> eventInitDict)]
+interface <dfn id=storageevent>StorageEvent</dfn> : <a href=#event>Event</a> {
+ readonly attribute DOMString <a href=#dom-storageevent-key title=dom-StorageEvent-key>key</a>;
+ readonly attribute DOMString? <a href=#dom-storageevent-oldvalue title=dom-StorageEvent-oldValue>oldValue</a>;
+ readonly attribute DOMString? <a href=#dom-storageevent-newvalue title=dom-StorageEvent-newValue>newValue</a>;
+ readonly attribute DOMString <a href=#dom-storageevent-url title=dom-StorageEvent-url>url</a>;
+ readonly attribute <a href=#storage-0>Storage</a>? <a href=#dom-storageevent-storagearea title=dom-StorageEvent-storageArea>storageArea</a>;
+};
+
+dictionary <dfn id=storageeventinit>StorageEventInit</dfn> : <a href=#eventinit>EventInit</a> {
+ DOMString key;
+ DOMString? oldValue;
+ DOMString? newValue;
+ DOMString url;
+ <a href=#storage-0>Storage</a>? storageArea;
+};</pre>
+
+ <p>The <dfn id=dom-storageevent-key title=dom-StorageEvent-key><code>key</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to the empty
+ string. It represents the key being changed.</p>
+
+ <p>The <dfn id=dom-storageevent-oldvalue title=dom-StorageEvent-oldValue><code>oldValue</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to null. It
+ represents the old value of the key being changed.</p>
+
+ <p>The <dfn id=dom-storageevent-newvalue title=dom-StorageEvent-newValue><code>newValue</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to null. It
+ represents the new value of the key being changed.</p>
+
+ <p>The <dfn id=dom-storageevent-url title=dom-StorageEvent-url><code>url</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to the empty
+ string. It represents the address of the document whose key
+ changed.</p>
+
+ <p>The <dfn id=dom-storageevent-storagearea title=dom-StorageEvent-storageArea><code>storageArea</code></dfn>
+ attribute must return the value it was initialized to. When the
+ object is created, this attribute must be initialized to null. It
+ represents the <code><a href=#storage-0>Storage</a></code> object that was affected.</p>
+
+
+
+ <h4 id=threads><span class=secno>12.2.5 </span>Threads</h4>
+
+ <p>Because of <a href=#localStorageMutex>the use</a> of the
+ <a href=#storage-mutex>storage mutex</a>, multiple browsing contexts will be able
+ to access the local storage areas simultaneously in such a manner
+ that scripts cannot detect any concurrent script execution.</p>
+
+ <p>Thus, the <code title=dom-Storage-length><a href=#dom-storage-length>length</a></code>
+ attribute of a <code><a href=#storage-0>Storage</a></code> object, and the value of the
+ various properties of that object, cannot change while a script is
+ executing, other than in a way that is predictable by the script
+ itself.</p>
+
+
+ <h3 id=disk-space-0><span class=secno>12.3 </span>Disk space</h3>
+
+ <p>User agents should limit the total amount of space allowed for
+ storage areas.</p>
+
+ <p>User agents should guard against sites storing data under the
+ origins other affiliated sites, e.g. storing up to the limit in
+ a1.example.com, a2.example.com, a3.example.com, etc, circumventing
+ the main example.com storage limit.</p>
+
+ <p>User agents may prompt the user when quotas are reached, allowing
+ the user to grant a site more space. This enables sites to store
+ many user-created documents on the user's computer, for
+ instance.</p>
+
+ <p>User agents should allow users to see how much space each domain
+ is using.</p>
+
+ <!--<p>If the storage area space limit is reached during a <code
+ title="dom-Storage-setItem">setItem()</code> call, the method will
+ throw an exception.</p>-->
+
+ <p>A mostly arbitrary limit of five megabytes per
+ <a href=#origin>origin</a> is recommended. Implementation feedback is
+ welcome and will be used to update this suggestion in the
+ future.</p>
+
+
+ <h3 id=privacy><span class=secno>12.4 </span>Privacy</h3>
+
+ <h4 id=user-tracking><span class=secno>12.4.1 </span>User tracking</h4>
+
+ <p>A third-party advertiser (or any entity capable of getting
+ content distributed to multiple sites) could use a unique identifier
+ stored in its local storage area to track a user across multiple
+ sessions, building a profile of the user's interests to allow for
+ highly targeted advertising. In conjunction with a site that is
+ aware of the user's real identity (for example an e-commerce site
+ that requires authenticated credentials), this could allow
+ oppressive groups to target individuals with greater accuracy than
+ in a world with purely anonymous Web usage.</p>
+
+ <p>There are a number of techniques that can be used to mitigate the
+ risk of user tracking:</p>
+
+ <dl><dt>Blocking third-party storage</dt>
+ <dd>
+
+ <p>User agents may restrict access to the <code title=dom-localStorage><a href=#dom-localstorage>localStorage</a></code> objects to scripts
+ originating at the domain of the top-level document of the
+ <a href=#browsing-context>browsing context</a>, for instance denying access to the
+ API for pages from other domains running in
+ <code><a href=#the-iframe-element>iframe</a></code>s.</p>
+
+ </dd>
+
+ <dt>Expiring stored data</dt>
+ <dd>
+
+ <p>User agents may, if so configured by the user, automatically
+ delete stored data after a period of time.</p>
+
+ <p>For example, a user agent could be configured to treat
+ third-party local storage areas as session-only storage, deleting
+ the data once the user had closed all the <a href=#browsing-context title="browsing
+ context">browsing contexts</a> that could access it.</p>
+
+ <p>This can restrict the ability of a site to track a user, as the
+ site would then only be able to track the user across multiple
+ sessions when he authenticates with the site itself (e.g. by
+ making a purchase or logging in to a service).</p>
+
+ <p>However, this also reduces the usefulness of the API as a
+ long-term storage mechanism. It can also put the user's data at
+ risk, if the user does not fully understand the implications of
+ data expiration.</p>
+
+ <!--v2 consider adding an explicit way for sites to state when
+ data should expire, as in localStorage.expireData(365); -->
+
+ </dd>
+
+ <dt>Treating persistent storage as cookies</dt>
+ <dd>
+
+ <p>If users attempt to protect their privacy by clearing cookies
+ without also clearing data stored in the local storage area, sites
+ can defeat those attempts by using the two features as redundant
+ backup for each other. User agents should present the interfaces
+ for clearing these in a way that helps users to understand this
+ possibility and enables them to delete data in all persistent
+ storage features simultaneously. <a href=#refsCOOKIES>[COOKIES]</a></p>
+
+ </dd>
+
+ <dt>Site-specific white-listing of access to local storage
+ areas</dt>
+ <dd>
+
+ <p>User agents may allow sites to access session storage areas in
+ an unrestricted manner, but require the user to authorize access
+ to local storage areas.</p>
+
+ </dd>
+
+ <dt>Origin-tracking of stored data</dt>
+ <dd>
+
+ <p>User agents may record the <a href=#origin title=origin>origins</a>
+ of sites that contained content from third-party origins that
+ caused data to be stored.</p>
+
+ <p>If this information is then used to present the view of data
+ currently in persistent storage, it would allow the user to make
+ informed decisions about which parts of the persistent storage to
+ prune. Combined with a blacklist ("delete this data and prevent
+ this domain from ever storing data again"), the user can restrict
+ the use of persistent storage to sites that he trusts.</p>
+
+ </dd>
+
+ <dt>Shared blacklists</dt>
+ <dd>
+
+ <p>User agents may allow users to share their persistent storage
+ domain blacklists.</p>
+
+ <p>This would allow communities to act together to protect their
+ privacy.</p>
+
+ </dd>
+
+ </dl><p>While these suggestions prevent trivial use of this API for user
+ tracking, they do not block it altogether. Within a single domain, a
+ site can continue to track the user during a session, and can then
+ pass all this information to the third party along with any
+ identifying information (names, credit card numbers, addresses)
+ obtained by the site. If a third party cooperates with multiple
+ sites to obtain such information, a profile can still be
+ created.</p>
+
+ <p>However, user tracking is to some extent possible even with no
+ cooperation from the user agent whatsoever, for instance by using
+ session identifiers in URLs, a technique already commonly used for
+ innocuous purposes but easily repurposed for user tracking (even
+ retroactively). This information can then be shared with other
+ sites, using using visitors' IP addresses and other user-specific
+ data (e.g. user-agent headers and configuration settings) to combine
+ separate sessions into coherent user profiles.</p>
+
+
+ <h4 id=sensitivity-of-data><span class=secno>12.4.2 </span>Sensitivity of data</h4>
+
+ <p>User agents should treat persistently stored data as potentially
+ sensitive; it's quite possible for e-mails, calendar appointments,
+ health records, or other confidential documents to be stored in this
+ mechanism.</p>
+
+ <p>To this end, user agents should ensure that when deleting data,
+ it is promptly deleted from the underlying storage.</p>
+
+
+ <h3 id=security-storage><span class=secno>12.5 </span>Security</h3>
+
+ <h4 id=dns-spoofing-attacks><span class=secno>12.5.1 </span>DNS spoofing attacks</h4>
+
+ <p>Because of the potential for DNS spoofing attacks, one cannot
+ guarantee that a host claiming to be in a certain domain really is
+ from that domain. To mitigate this, pages can use TLS. Pages using
+ TLS can be sure that only the user, software working on behalf of
+ the user, and other pages using TLS that have certificates
+ identifying them as being from the same domain, can access their
+ storage areas.</p>
+
+
+ <h4 id=cross-directory-attacks><span class=secno>12.5.2 </span>Cross-directory attacks</h4>
+
+ <p>Different authors sharing one host name, for example users
+ hosting content on <code>geocities.com</code>, all share one local
+ storage object. There is no feature to restrict the access by
+ pathname. Authors on shared hosts are therefore recommended to avoid
+ using these features, as it would be trivial for other authors to
+ read the data and overwrite it.</p>
+
+ <p class=note>Even if a path-restriction feature was made
+ available, the usual DOM scripting security model would make it
+ trivial to bypass this protection and access the data from any
+ path.</p>
+
+
+ <h4 id=implementation-risks><span class=secno>12.5.3 </span>Implementation risks</h4>
+
+ <p>The two primary risks when implementing these persistent storage
+ features are letting hostile sites read information from other
+ domains, and letting hostile sites write information that is then
+ read from other domains.</p>
+
+ <p>Letting third-party sites read data that is not supposed to be
+ read from their domain causes <em>information leakage</em>, For
+ example, a user's shopping wishlist on one domain could be used by
+ another domain for targeted advertising; or a user's
+ work-in-progress confidential documents stored by a word-processing
+ site could be examined by the site of a competing company.</p>
+
+ <p>Letting third-party sites write data to the persistent storage of
+ other domains can result in <em>information spoofing</em>, which is
+ equally dangerous. For example, a hostile site could add items to a
+ user's wishlist; or a hostile site could set a user's session
+ identifier to a known ID that the hostile site can then use to track
+ the user's actions on the victim site.</p>
+
+ <p>Thus, strictly following the <a href=#origin>origin</a> model described
+ in this specification is important for user security.</p>
+
+
+
+ </div><!--data-component-->
+
+
+
+
+
+ <h2 id=syntax><span class=secno>13 </span><dfn>The HTML syntax</dfn></h2>
+
<p class=note>This section only describes the rules for resources
labeled with an <a href=#html-mime-type>HTML MIME type</a>. Rules for XML resources
are discussed in the section below entitled "<a href=#the-xhtml-syntax>The XHTML
syntax</a>".</p>
- <h3 id=writing><span class=secno>11.1 </span>Writing HTML documents</h3>
+ <h3 id=writing><span class=secno>13.1 </span>Writing HTML documents</h3>
<div class=impl>
@@ -77997,7 +82577,7 @@
as "case-insensitive".</p>
- <h4 id=the-doctype><span class=secno>11.1.1 </span>The DOCTYPE</h4>
+ <h4 id=the-doctype><span class=secno>13.1.1 </span>The DOCTYPE</h4>
<p>A <dfn id=syntax-doctype title=syntax-doctype>DOCTYPE</dfn> is a <!-- mostly
useless but nonetheless --> required preamble.</p>
@@ -78081,7 +82661,7 @@
- <h4 id=elements-0><span class=secno>11.1.2 </span>Elements</h4>
+ <h4 id=elements-0><span class=secno>13.1.2 </span>Elements</h4>
<p>There are five different kinds of <dfn id=syntax-elements title=syntax-elements>elements</dfn>: <a href=#void-elements>void elements</a>,
<a href=#raw-text-elements>raw text elements</a>, <a href=#rcdata-elements>RCDATA elements</a>,
@@ -78203,7 +82783,7 @@
tag name; tag names are case-insensitive.</p>
- <h5 id=start-tags><span class=secno>11.1.2.1 </span>Start tags</h5>
+ <h5 id=start-tags><span class=secno>13.1.2.1 </span>Start tags</h5>
<p><dfn id=syntax-start-tag title=syntax-start-tag>Start tags</dfn> must have the
following format:</p>
@@ -78238,7 +82818,7 @@
<li>Finally, start tags must be closed by a U+003E GREATER-THAN
SIGN character (>).</li>
- </ol><h5 id=end-tags><span class=secno>11.1.2.2 </span>End tags</h5>
+ </ol><h5 id=end-tags><span class=secno>13.1.2.2 </span>End tags</h5>
<p><dfn id=syntax-end-tag title=syntax-end-tag>End tags</dfn> must have the
following format:</p>
@@ -78258,7 +82838,7 @@
<li>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN
character (>).</li>
- </ol><h5 id=attributes-0><span class=secno>11.1.2.3 </span>Attributes</h5>
+ </ol><h5 id=attributes-0><span class=secno>13.1.2.3 </span>Attributes</h5>
<p><dfn id=syntax-attributes title=syntax-attributes>Attributes</dfn> for an element
are expressed inside the element's start tag.</p>
@@ -78452,7 +83032,7 @@
HTML syntax</a>.</p>
- <h5 id=optional-tags><span class=secno>11.1.2.4 </span>Optional tags</h5>
+ <h5 id=optional-tags><span class=secno>13.1.2.4 </span>Optional tags</h5>
<p>Certain tags can be <dfn id=syntax-tag-omission title=syntax-tag-omission>omitted</dfn>.</p>
@@ -78628,7 +83208,7 @@
tag</a> must never be omitted if it has any attributes.</p>
- <h5 id=element-restrictions><span class=secno>11.1.2.5 </span>Restrictions on content models</h5>
+ <h5 id=element-restrictions><span class=secno>13.1.2.5 </span>Restrictions on content models</h5>
<p>For historical reasons, certain elements have extra restrictions
beyond even the restrictions given by their content model.</p>
@@ -78657,7 +83237,7 @@
</div>
- <h5 id=cdata-rcdata-restrictions><span class=secno>11.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</h5>
+ <h5 id=cdata-rcdata-restrictions><span class=secno>13.1.2.6 </span>Restrictions on the contents of raw text and RCDATA elements</h5>
<p>The text in <a href=#raw-text-elements title="raw text elements">raw text</a> and
<a href=#rcdata-elements>RCDATA elements</a> must not contain any occurrences of the
@@ -78669,7 +83249,7 @@
U+002F SOLIDUS (/).</p>
- <h4 id=text-1><span class=secno>11.1.3 </span>Text</h4>
+ <h4 id=text-1><span class=secno>13.1.3 </span>Text</h4>
<p><dfn id=syntax-text title=syntax-text>Text</dfn> is allowed inside elements,
attribute values, and comments. Text must consist of <a href=#unicode-character title="Unicode character">Unicode characters</a>. Text must not
@@ -78681,7 +83261,7 @@
described in the other sections.</p>
- <h5 id=newlines><span class=secno>11.1.3.1 </span>Newlines</h5>
+ <h5 id=newlines><span class=secno>13.1.3.1 </span>Newlines</h5>
<p><dfn id=syntax-newlines title=syntax-newlines>Newlines</dfn> in HTML may be
represented either as U+000D CARRIAGE RETURN (CR) characters, U+000A
@@ -78694,7 +83274,7 @@
represents a <a href=#syntax-newlines title=syntax-newlines>newline</a>.</p>
- <h4 id=character-references><span class=secno>11.1.4 </span>Character references</h4>
+ <h4 id=character-references><span class=secno>13.1.4 </span>Character references</h4>
<p>In certain cases described in other sections, <a href=#syntax-text title=syntax-text>text</a> may be mixed with <dfn id=syntax-charref title=syntax-charref>character references</dfn>. These can be used
to escape characters that couldn't otherwise legally be included in
@@ -78752,7 +83332,7 @@
the <a href=#named-character-references>named character references</a> section.</p>
- <h4 id=cdata-sections><span class=secno>11.1.5 </span>CDATA sections</h4>
+ <h4 id=cdata-sections><span class=secno>13.1.5 </span>CDATA sections</h4>
<p><dfn id=syntax-cdata title=syntax-cdata>CDATA sections</dfn> must consist of
the following components, in this order:</p>
@@ -78783,7 +83363,7 @@
</div>
- <h4 id=comments><span class=secno>11.1.6 </span>Comments</h4>
+ <h4 id=comments><span class=secno>13.1.6 </span>Comments</h4>
<p><dfn id=syntax-comments title=syntax-comments>Comments</dfn> must start with the
four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION
@@ -78801,7 +83381,7 @@
<div class=impl>
- <h3 id=parsing><span class=secno>11.2 </span>Parsing HTML documents</h3>
+ <h3 id=parsing><span class=secno>13.2 </span>Parsing HTML documents</h3>
<p><i>This section only applies to user agents, data mining tools,
and conformance checkers.</i></p>
@@ -78870,7 +83450,7 @@
<div class=impl>
- <h4 id=overview-of-the-parsing-model><span class=secno>11.2.1 </span>Overview of the parsing model</h4>
+ <h4 id=overview-of-the-parsing-model><span class=secno>13.2.1 </span>Overview of the parsing model</h4>
<p class=overview><object data=images/parsing-model-overview.svg height=450 width=345><img alt="" height=450 src=http://images.whatwg.org/parsing-model-overview.png width=345></object></p>
@@ -78920,7 +83500,7 @@
<div class=impl>
- <h4 id=the-input-stream><span class=secno>11.2.2 </span>The <dfn>input stream</dfn></h4>
+ <h4 id=the-input-stream><span class=secno>13.2.2 </span>The <dfn>input stream</dfn></h4>
<p>The stream of Unicode code points that comprises the input to the
tokenization stage will be initially seen by the user agent as a
@@ -78934,7 +83514,7 @@
specification. This section does not apply to XML documents. <a href=#refsXML>[XML]</a></p>
- <h5 id=determining-the-character-encoding><span class=secno>11.2.2.1 </span>Determining the character encoding</h5>
+ <h5 id=determining-the-character-encoding><span class=secno>13.2.2.1 </span>Determining the character encoding</h5>
<p>In some cases, it might be impractical to unambiguously determine
the encoding before parsing the document. Because of this, this
@@ -79491,7 +84071,7 @@
href="#refsHTTP">[HTTP]</a> <a href="#refsRFC2046">[RFC2046]</a></p>
-->
- <h5 id=character-encodings-0><span class=secno>11.2.2.2 </span>Character encodings</h5>
+ <h5 id=character-encodings-0><span class=secno>13.2.2.2 </span>Character encodings</h5>
<p>User agents must at a minimum support the UTF-8 and Windows-1252
encodings, but may support more. <a href=#refsRFC3629>[RFC3629]</a> <a href=#refsWIN1252>[WIN1252]</a></p>
@@ -79583,7 +84163,7 @@
- <h5 id=preprocessing-the-input-stream><span class=secno>11.2.2.3 </span>Preprocessing the input stream</h5>
+ <h5 id=preprocessing-the-input-stream><span class=secno>13.2.2.3 </span>Preprocessing the input stream</h5>
<p>Given an encoding, the bytes in the input stream must be
converted to Unicode code points for the tokenizer, as described by
@@ -79662,7 +84242,7 @@
the stream, but rather the lack of any further characters.</p>
- <h5 id=changing-the-encoding-while-parsing><span class=secno>11.2.2.4 </span>Changing the encoding while parsing</h5>
+ <h5 id=changing-the-encoding-while-parsing><span class=secno>13.2.2.4 </span>Changing the encoding while parsing</h5>
<p>When the parser requires the user agent to <dfn id=change-the-encoding>change the
encoding</dfn>, it must run the following steps. This might happen
@@ -79719,9 +84299,9 @@
<div class=impl>
- <h4 id=parse-state><span class=secno>11.2.3 </span>Parse state</h4>
+ <h4 id=parse-state><span class=secno>13.2.3 </span>Parse state</h4>
- <h5 id=the-insertion-mode><span class=secno>11.2.3.1 </span>The insertion mode</h5>
+ <h5 id=the-insertion-mode><span class=secno>13.2.3.1 </span>The insertion mode</h5>
<p>The <dfn id=insertion-mode>insertion mode</dfn> is a state variable that controls
the primary operation of the tree construction stage.</p>
@@ -79855,7 +84435,7 @@
<li>Return to the step labeled <i>loop</i>.</li>
- </ol><h5 id=the-stack-of-open-elements><span class=secno>11.2.3.2 </span>The stack of open elements</h5>
+ </ol><h5 id=the-stack-of-open-elements><span class=secno>13.2.3.2 </span>The stack of open elements</h5>
<p>Initially, the <dfn id=stack-of-open-elements>stack of open elements</dfn> is empty. The
stack grows downwards; the topmost node on the stack is the first
@@ -80018,7 +84598,7 @@
the stack is manipulated in a random-access fashion.</p>
- <h5 id=the-list-of-active-formatting-elements><span class=secno>11.2.3.3 </span>The list of active formatting elements</h5>
+ <h5 id=the-list-of-active-formatting-elements><span class=secno>13.2.3.3 </span>The list of active formatting elements</h5>
<p>Initially, the <dfn id=list-of-active-formatting-elements>list of active formatting elements</dfn> is
empty. It is used to handle mis-nested <a href=#formatting title=formatting>formatting element tags</a>.</p>
@@ -80136,7 +84716,7 @@
<li>Go to step 1.</li>
- </ol><h5 id=the-element-pointers><span class=secno>11.2.3.4 </span>The element pointers</h5>
+ </ol><h5 id=the-element-pointers><span class=secno>13.2.3.4 </span>The element pointers</h5>
<p>Initially, the <dfn id=head-element-pointer><code title="">head</code> element
pointer</dfn> and the <dfn id=form-element-pointer><code title="">form</code> element
@@ -80153,7 +84733,7 @@
markup, for historical reasons.</p>
- <h5 id=other-parsing-state-flags><span class=secno>11.2.3.5 </span>Other parsing state flags</h5>
+ <h5 id=other-parsing-state-flags><span class=secno>13.2.3.5 </span>Other parsing state flags</h5>
<p>The <dfn id=scripting-flag>scripting flag</dfn> is set to "enabled" if <a href=#concept-n-script title=concept-n-script>scripting was enabled</a> for the
<code><a href=#document>Document</a></code> with which the parser is associated when the
@@ -80172,7 +84752,7 @@
<div class=impl>
- <h4 id=tokenization><span class=secno>11.2.4 </span><dfn>Tokenization</dfn></h4>
+ <h4 id=tokenization><span class=secno>13.2.4 </span><dfn>Tokenization</dfn></h4>
<p>Implementations must act as if they used the following state
machine to tokenize HTML. The state machine must start in the
@@ -80243,7 +84823,7 @@
error, by unicode, then EOF, ending with "anything else" -->
- <h5 id=data-state><span class=secno>11.2.4.1 </span><dfn>Data state</dfn></h5>
+ <h5 id=data-state><span class=secno>13.2.4.1 </span><dfn>Data state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80265,7 +84845,7 @@
<dd>Emit the <a href=#current-input-character>current input character</a> as a character
token.</dd>
- </dl><h5 id=character-reference-in-data-state><span class=secno>11.2.4.2 </span><dfn>Character reference in data state</dfn></h5>
+ </dl><h5 id=character-reference-in-data-state><span class=secno>13.2.4.2 </span><dfn>Character reference in data state</dfn></h5>
<p>Attempt to <a href=#consume-a-character-reference>consume a character reference</a>, with no
<a href=#additional-allowed-character>additional allowed character</a>.</p>
@@ -80278,7 +84858,7 @@
<p>Finally, switch to the <a href=#data-state>data state</a>.</p>
- <h5 id=rcdata-state><span class=secno>11.2.4.3 </span><dfn>RCDATA state</dfn></h5>
+ <h5 id=rcdata-state><span class=secno>13.2.4.3 </span><dfn>RCDATA state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80300,7 +84880,7 @@
<dd>Emit the <a href=#current-input-character>current input character</a> as a character
token.</dd>
- </dl><h5 id=character-reference-in-rcdata-state><span class=secno>11.2.4.4 </span><dfn>Character reference in RCDATA state</dfn></h5>
+ </dl><h5 id=character-reference-in-rcdata-state><span class=secno>13.2.4.4 </span><dfn>Character reference in RCDATA state</dfn></h5>
<p>Attempt to <a href=#consume-a-character-reference>consume a character reference</a>, with no
<a href=#additional-allowed-character>additional allowed character</a>.</p>
@@ -80313,7 +84893,7 @@
<p>Finally, switch to the <a href=#rcdata-state>RCDATA state</a>.</p>
- <h5 id=rawtext-state><span class=secno>11.2.4.5 </span><dfn>RAWTEXT state</dfn></h5>
+ <h5 id=rawtext-state><span class=secno>13.2.4.5 </span><dfn>RAWTEXT state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80331,7 +84911,7 @@
<dd>Emit the <a href=#current-input-character>current input character</a> as a character
token.</dd>
- </dl><h5 id=script-data-state><span class=secno>11.2.4.6 </span><dfn>Script data state</dfn></h5>
+ </dl><h5 id=script-data-state><span class=secno>13.2.4.6 </span><dfn>Script data state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80349,7 +84929,7 @@
<dd>Emit the <a href=#current-input-character>current input character</a> as a character
token.</dd>
- </dl><h5 id=plaintext-state><span class=secno>11.2.4.7 </span><dfn>PLAINTEXT state</dfn></h5>
+ </dl><h5 id=plaintext-state><span class=secno>13.2.4.7 </span><dfn>PLAINTEXT state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80364,7 +84944,7 @@
<dd>Emit the <a href=#current-input-character>current input character</a> as a character
token.</dd>
- </dl><h5 id=tag-open-state><span class=secno>11.2.4.8 </span><dfn>Tag open state</dfn></h5>
+ </dl><h5 id=tag-open-state><span class=secno>13.2.4.8 </span><dfn>Tag open state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80396,7 +84976,7 @@
character token and reconsume the <a href=#current-input-character>current input
character</a> in the <a href=#data-state>data state</a>.</dd>
- </dl><h5 id=end-tag-open-state><span class=secno>11.2.4.9 </span><dfn>End tag open state</dfn></h5>
+ </dl><h5 id=end-tag-open-state><span class=secno>13.2.4.9 </span><dfn>End tag open state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80426,7 +85006,7 @@
<dd><a href=#parse-error>Parse error</a>. Switch to the <a href=#bogus-comment-state>bogus
comment state</a>.</dd>
- </dl><h5 id=tag-name-state><span class=secno>11.2.4.10 </span><dfn>Tag name state</dfn></h5>
+ </dl><h5 id=tag-name-state><span class=secno>13.2.4.10 </span><dfn>Tag name state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80461,7 +85041,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
tag token's tag name.</dd>
- </dl><h5 id=rcdata-less-than-sign-state><span class=secno>11.2.4.11 </span><dfn>RCDATA less-than sign state</dfn></h5>
+ </dl><h5 id=rcdata-less-than-sign-state><span class=secno>13.2.4.11 </span><dfn>RCDATA less-than sign state</dfn></h5>
<!-- identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g -->
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80475,7 +85055,7 @@
<a href=#current-input-character>current input character</a> in the <a href=#rcdata-state>RCDATA
state</a>.</dd>
- </dl><h5 id=rcdata-end-tag-open-state><span class=secno>11.2.4.12 </span><dfn>RCDATA end tag open state</dfn></h5>
+ </dl><h5 id=rcdata-end-tag-open-state><span class=secno>13.2.4.12 </span><dfn>RCDATA end tag open state</dfn></h5>
<!-- identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g -->
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80502,7 +85082,7 @@
character token, and reconsume the <a href=#current-input-character>current input
character</a> in the <a href=#rcdata-state>RCDATA state</a>.</dd>
- </dl><h5 id=rcdata-end-tag-name-state><span class=secno>11.2.4.13 </span><dfn>RCDATA end tag name state</dfn></h5>
+ </dl><h5 id=rcdata-end-tag-name-state><span class=secno>13.2.4.13 </span><dfn>RCDATA end tag name state</dfn></h5>
<!-- identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g -->
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80547,7 +85127,7 @@
the buffer), and reconsume the <a href=#current-input-character>current input character</a>
in the <a href=#rcdata-state>RCDATA state</a>.</dd>
- </dl><h5 id=rawtext-less-than-sign-state><span class=secno>11.2.4.14 </span><dfn>RAWTEXT less-than sign state</dfn></h5>
+ </dl><h5 id=rawtext-less-than-sign-state><span class=secno>13.2.4.14 </span><dfn>RAWTEXT less-than sign state</dfn></h5>
<!-- identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g -->
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80561,7 +85141,7 @@
<a href=#current-input-character>current input character</a> in the <a href=#rawtext-state>RAWTEXT
state</a>.</dd>
- </dl><h5 id=rawtext-end-tag-open-state><span class=secno>11.2.4.15 </span><dfn>RAWTEXT end tag open state</dfn></h5>
+ </dl><h5 id=rawtext-end-tag-open-state><span class=secno>13.2.4.15 </span><dfn>RAWTEXT end tag open state</dfn></h5>
<!-- identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g -->
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80588,7 +85168,7 @@
character token, and reconsume the <a href=#current-input-character>current input
character</a> in the <a href=#rawtext-state>RAWTEXT state</a>.</dd>
- </dl><h5 id=rawtext-end-tag-name-state><span class=secno>11.2.4.16 </span><dfn>RAWTEXT end tag name state</dfn></h5>
+ </dl><h5 id=rawtext-end-tag-name-state><span class=secno>13.2.4.16 </span><dfn>RAWTEXT end tag name state</dfn></h5>
<!-- identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g -->
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80633,7 +85213,7 @@
the buffer), and reconsume the <a href=#current-input-character>current input character</a>
in the <a href=#rawtext-state>RAWTEXT state</a>.</dd>
- </dl><h5 id=script-data-less-than-sign-state><span class=secno>11.2.4.17 </span><dfn>Script data less-than sign state</dfn></h5>
+ </dl><h5 id=script-data-less-than-sign-state><span class=secno>13.2.4.17 </span><dfn>Script data less-than sign state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80651,7 +85231,7 @@
<a href=#current-input-character>current input character</a> in the <a href=#script-data-state>script data
state</a>.</dd>
- </dl><h5 id=script-data-end-tag-open-state><span class=secno>11.2.4.18 </span><dfn>Script data end tag open state</dfn></h5>
+ </dl><h5 id=script-data-end-tag-open-state><span class=secno>13.2.4.18 </span><dfn>Script data end tag open state</dfn></h5>
<!-- identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g -->
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80678,7 +85258,7 @@
character token, and reconsume the <a href=#current-input-character>current input
character</a> in the <a href=#script-data-state>script data state</a>.</dd>
- </dl><h5 id=script-data-end-tag-name-state><span class=secno>11.2.4.19 </span><dfn>Script data end tag name state</dfn></h5>
+ </dl><h5 id=script-data-end-tag-name-state><span class=secno>13.2.4.19 </span><dfn>Script data end tag name state</dfn></h5>
<!-- identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g -->
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80723,7 +85303,7 @@
the buffer), and reconsume the <a href=#current-input-character>current input character</a>
in the <a href=#script-data-state>script data state</a>.</dd>
- </dl><h5 id=script-data-escape-start-state><span class=secno>11.2.4.20 </span><dfn>Script data escape start state</dfn></h5>
+ </dl><h5 id=script-data-escape-start-state><span class=secno>13.2.4.20 </span><dfn>Script data escape start state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80735,7 +85315,7 @@
<dd>Reconsume the <a href=#current-input-character>current input character</a> in the
<a href=#script-data-state>script data state</a>.</dd>
- </dl><h5 id=script-data-escape-start-dash-state><span class=secno>11.2.4.21 </span><dfn>Script data escape start dash state</dfn></h5>
+ </dl><h5 id=script-data-escape-start-dash-state><span class=secno>13.2.4.21 </span><dfn>Script data escape start dash state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80747,7 +85327,7 @@
<dd>Reconsume the <a href=#current-input-character>current input character</a> in the
<a href=#script-data-state>script data state</a>.</dd>
- </dl><h5 id=script-data-escaped-state><span class=secno>11.2.4.22 </span><dfn>Script data escaped state</dfn></h5>
+ </dl><h5 id=script-data-escaped-state><span class=secno>13.2.4.22 </span><dfn>Script data escaped state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80771,7 +85351,7 @@
<dd>Emit the <a href=#current-input-character>current input character</a> as a character
token.</dd>
- </dl><h5 id=script-data-escaped-dash-state><span class=secno>11.2.4.23 </span><dfn>Script data escaped dash state</dfn></h5>
+ </dl><h5 id=script-data-escaped-dash-state><span class=secno>13.2.4.23 </span><dfn>Script data escaped dash state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80796,7 +85376,7 @@
<dd>Switch to the <a href=#script-data-escaped-state>script data escaped state</a>. Emit the
<a href=#current-input-character>current input character</a> as a character token.</dd>
- </dl><h5 id=script-data-escaped-dash-dash-state><span class=secno>11.2.4.24 </span><dfn>Script data escaped dash dash state</dfn></h5>
+ </dl><h5 id=script-data-escaped-dash-dash-state><span class=secno>13.2.4.24 </span><dfn>Script data escaped dash dash state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80824,7 +85404,7 @@
<dd>Switch to the <a href=#script-data-escaped-state>script data escaped state</a>. Emit the
<a href=#current-input-character>current input character</a> as a character token.</dd>
- </dl><h5 id=script-data-escaped-less-than-sign-state><span class=secno>11.2.4.25 </span><dfn>Script data escaped less-than sign state</dfn></h5>
+ </dl><h5 id=script-data-escaped-less-than-sign-state><span class=secno>13.2.4.25 </span><dfn>Script data escaped less-than sign state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80852,7 +85432,7 @@
<a href=#current-input-character>current input character</a> in the <a href=#script-data-escaped-state>script data
escaped state</a>.</dd>
- </dl><h5 id=script-data-escaped-end-tag-open-state><span class=secno>11.2.4.26 </span><dfn>Script data escaped end tag open state</dfn></h5>
+ </dl><h5 id=script-data-escaped-end-tag-open-state><span class=secno>13.2.4.26 </span><dfn>Script data escaped end tag open state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80878,7 +85458,7 @@
character token, and reconsume the <a href=#current-input-character>current input
character</a> in the <a href=#script-data-escaped-state>script data escaped state</a>.</dd>
- </dl><h5 id=script-data-escaped-end-tag-name-state><span class=secno>11.2.4.27 </span><dfn>Script data escaped end tag name state</dfn></h5>
+ </dl><h5 id=script-data-escaped-end-tag-name-state><span class=secno>13.2.4.27 </span><dfn>Script data escaped end tag name state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80922,7 +85502,7 @@
the buffer), and reconsume the <a href=#current-input-character>current input character</a>
in the <a href=#script-data-escaped-state>script data escaped state</a>.</dd>
- </dl><h5 id=script-data-double-escape-start-state><span class=secno>11.2.4.28 </span><dfn>Script data double escape start state</dfn></h5>
+ </dl><h5 id=script-data-double-escape-start-state><span class=secno>13.2.4.28 </span><dfn>Script data double escape start state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80953,7 +85533,7 @@
<dd>Reconsume the <a href=#current-input-character>current input character</a> in the
<a href=#script-data-escaped-state>script data escaped state</a>.</dd>
- </dl><h5 id=script-data-double-escaped-state><span class=secno>11.2.4.29 </span><dfn>Script data double escaped state</dfn></h5>
+ </dl><h5 id=script-data-double-escaped-state><span class=secno>13.2.4.29 </span><dfn>Script data double escaped state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -80978,7 +85558,7 @@
<dd>Emit the <a href=#current-input-character>current input character</a> as a character
token.</dd>
- </dl><h5 id=script-data-double-escaped-dash-state><span class=secno>11.2.4.30 </span><dfn>Script data double escaped dash state</dfn></h5>
+ </dl><h5 id=script-data-double-escaped-dash-state><span class=secno>13.2.4.30 </span><dfn>Script data double escaped dash state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81005,7 +85585,7 @@
state</a>. Emit the <a href=#current-input-character>current input character</a> as a
character token.</dd>
- </dl><h5 id=script-data-double-escaped-dash-dash-state><span class=secno>11.2.4.31 </span><dfn>Script data double escaped dash dash state</dfn></h5>
+ </dl><h5 id=script-data-double-escaped-dash-dash-state><span class=secno>13.2.4.31 </span><dfn>Script data double escaped dash dash state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81035,7 +85615,7 @@
state</a>. Emit the <a href=#current-input-character>current input character</a> as a
character token.</dd>
- </dl><h5 id=script-data-double-escaped-less-than-sign-state><span class=secno>11.2.4.32 </span><dfn>Script data double escaped less-than sign state</dfn></h5>
+ </dl><h5 id=script-data-double-escaped-less-than-sign-state><span class=secno>13.2.4.32 </span><dfn>Script data double escaped less-than sign state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81048,7 +85628,7 @@
<dd>Reconsume the <a href=#current-input-character>current input character</a> in the
<a href=#script-data-double-escaped-state>script data double escaped state</a>.</dd>
- </dl><h5 id=script-data-double-escape-end-state><span class=secno>11.2.4.33 </span><dfn>Script data double escape end state</dfn></h5>
+ </dl><h5 id=script-data-double-escape-end-state><span class=secno>13.2.4.33 </span><dfn>Script data double escape end state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81079,7 +85659,7 @@
<dd>Reconsume the <a href=#current-input-character>current input character</a> in the
<a href=#script-data-double-escaped-state>script data double escaped state</a>.</dd>
- </dl><h5 id=before-attribute-name-state><span class=secno>11.2.4.34 </span><dfn>Before attribute name state</dfn></h5>
+ </dl><h5 id=before-attribute-name-state><span class=secno>13.2.4.34 </span><dfn>Before attribute name state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81127,7 +85707,7 @@
its value to the empty string. Switch to the <a href=#attribute-name-state>attribute name
state</a>.</dd>
- </dl><h5 id=attribute-name-state><span class=secno>11.2.4.35 </span><dfn>Attribute name state</dfn></h5>
+ </dl><h5 id=attribute-name-state><span class=secno>13.2.4.35 </span><dfn>Attribute name state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81180,7 +85760,7 @@
associated with it (if any).</p>
- <h5 id=after-attribute-name-state><span class=secno>11.2.4.36 </span><dfn>After attribute name state</dfn></h5>
+ <h5 id=after-attribute-name-state><span class=secno>13.2.4.36 </span><dfn>After attribute name state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81230,7 +85810,7 @@
its value to the empty string. Switch to the <a href=#attribute-name-state>attribute name
state</a>.</dd>
- </dl><h5 id=before-attribute-value-state><span class=secno>11.2.4.37 </span><dfn>Before attribute value state</dfn></h5>
+ </dl><h5 id=before-attribute-value-state><span class=secno>13.2.4.37 </span><dfn>Before attribute value state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81275,7 +85855,7 @@
attribute's value. Switch to the <a href=#attribute-value-(unquoted)-state>attribute value (unquoted)
state</a>.</dd>
- </dl><h5 id=attribute-value-(double-quoted)-state><span class=secno>11.2.4.38 </span><dfn>Attribute value (double-quoted) state</dfn></h5>
+ </dl><h5 id=attribute-value-(double-quoted)-state><span class=secno>13.2.4.38 </span><dfn>Attribute value (double-quoted) state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81300,7 +85880,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
attribute's value.</dd>
- </dl><h5 id=attribute-value-(single-quoted)-state><span class=secno>11.2.4.39 </span><dfn>Attribute value (single-quoted) state</dfn></h5>
+ </dl><h5 id=attribute-value-(single-quoted)-state><span class=secno>13.2.4.39 </span><dfn>Attribute value (single-quoted) state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81325,7 +85905,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
attribute's value.</dd>
- </dl><h5 id=attribute-value-(unquoted)-state><span class=secno>11.2.4.40 </span><dfn>Attribute value (unquoted) state</dfn></h5>
+ </dl><h5 id=attribute-value-(unquoted)-state><span class=secno>13.2.4.40 </span><dfn>Attribute value (unquoted) state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81365,7 +85945,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
attribute's value.</dd>
- </dl><h5 id=character-reference-in-attribute-value-state><span class=secno>11.2.4.41 </span><dfn>Character reference in attribute value state</dfn></h5>
+ </dl><h5 id=character-reference-in-attribute-value-state><span class=secno>13.2.4.41 </span><dfn>Character reference in attribute value state</dfn></h5>
<p>Attempt to <a href=#consume-a-character-reference>consume a character reference</a>.</p>
@@ -81379,7 +85959,7 @@
into this state.</p>
- <h5 id=after-attribute-value-(quoted)-state><span class=secno>11.2.4.42 </span><dfn>After attribute value (quoted) state</dfn></h5>
+ <h5 id=after-attribute-value-(quoted)-state><span class=secno>13.2.4.42 </span><dfn>After attribute value (quoted) state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81405,7 +85985,7 @@
<dd><a href=#parse-error>Parse error</a>. Reconsume the character in
the <a href=#before-attribute-name-state>before attribute name state</a>.</dd>
- </dl><h5 id=self-closing-start-tag-state><span class=secno>11.2.4.43 </span><dfn>Self-closing start tag state</dfn></h5>
+ </dl><h5 id=self-closing-start-tag-state><span class=secno>13.2.4.43 </span><dfn>Self-closing start tag state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81422,7 +86002,7 @@
<dd><a href=#parse-error>Parse error</a>. Reconsume the character in
the <a href=#before-attribute-name-state>before attribute name state</a>.</dd>
- </dl><h5 id=bogus-comment-state><span class=secno>11.2.4.44 </span><dfn>Bogus comment state</dfn></h5>
+ </dl><h5 id=bogus-comment-state><span class=secno>13.2.4.44 </span><dfn>Bogus comment state</dfn></h5>
<p>Consume every character up to and including the first U+003E
GREATER-THAN SIGN character (>) or the end of the file (EOF),
@@ -81441,7 +86021,7 @@
character.</p>
- <h5 id=markup-declaration-open-state><span class=secno>11.2.4.45 </span><dfn>Markup declaration open state</dfn></h5>
+ <h5 id=markup-declaration-open-state><span class=secno>13.2.4.45 </span><dfn>Markup declaration open state</dfn></h5>
<p>If the next two characters are both U+002D HYPHEN-MINUS
characters (-), consume those two characters, create a comment token
@@ -81465,7 +86045,7 @@
comment.</p>
- <h5 id=comment-start-state><span class=secno>11.2.4.46 </span><dfn>Comment start state</dfn></h5>
+ <h5 id=comment-start-state><span class=secno>13.2.4.46 </span><dfn>Comment start state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81490,7 +86070,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the comment
token's data. Switch to the <a href=#comment-state>comment state</a>.</dd>
- </dl><h5 id=comment-start-dash-state><span class=secno>11.2.4.47 </span><dfn>Comment start dash state</dfn></h5>
+ </dl><h5 id=comment-start-dash-state><span class=secno>13.2.4.47 </span><dfn>Comment start dash state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81517,7 +86097,7 @@
<a href=#current-input-character>current input character</a> to the comment token's
data. Switch to the <a href=#comment-state>comment state</a>.</dd>
- </dl><h5 id=comment-state><span class=secno>11.2.4.48 </span><dfn id=comment>Comment state</dfn></h5>
+ </dl><h5 id=comment-state><span class=secno>13.2.4.48 </span><dfn id=comment>Comment state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81537,7 +86117,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the comment
token's data.</dd>
- </dl><h5 id=comment-end-dash-state><span class=secno>11.2.4.49 </span><dfn>Comment end dash state</dfn></h5>
+ </dl><h5 id=comment-end-dash-state><span class=secno>13.2.4.49 </span><dfn>Comment end dash state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81560,7 +86140,7 @@
<a href=#current-input-character>current input character</a> to the comment token's
data. Switch to the <a href=#comment-state>comment state</a>.</dd>
- </dl><h5 id=comment-end-state><span class=secno>11.2.4.50 </span><dfn>Comment end state</dfn></h5>
+ </dl><h5 id=comment-end-state><span class=secno>13.2.4.50 </span><dfn>Comment end state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81596,7 +86176,7 @@
comment token's data. Switch to the <a href=#comment-state>comment
state</a>.</dd>
- </dl><h5 id=comment-end-bang-state><span class=secno>11.2.4.51 </span><dfn>Comment end bang state</dfn></h5>
+ </dl><h5 id=comment-end-bang-state><span class=secno>13.2.4.51 </span><dfn>Comment end bang state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81626,7 +86206,7 @@
character</a> to the comment token's data. Switch to the
<a href=#comment-state>comment state</a>.</dd>
- </dl><h5 id=doctype-state><span class=secno>11.2.4.52 </span><dfn>DOCTYPE state</dfn></h5>
+ </dl><h5 id=doctype-state><span class=secno>13.2.4.52 </span><dfn>DOCTYPE state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81646,7 +86226,7 @@
<dd><a href=#parse-error>Parse error</a>. Reconsume the character in the
<a href=#before-doctype-name-state>before DOCTYPE name state</a>.</dd>
- </dl><h5 id=before-doctype-name-state><span class=secno>11.2.4.53 </span><dfn>Before DOCTYPE name state</dfn></h5>
+ </dl><h5 id=before-doctype-name-state><span class=secno>13.2.4.53 </span><dfn>Before DOCTYPE name state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81683,7 +86263,7 @@
<a href=#current-input-character>current input character</a>. Switch to the <a href=#doctype-name-state>DOCTYPE name
state</a>.</dd>
- </dl><h5 id=doctype-name-state><span class=secno>11.2.4.54 </span><dfn>DOCTYPE name state</dfn></h5>
+ </dl><h5 id=doctype-name-state><span class=secno>13.2.4.54 </span><dfn>DOCTYPE name state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81716,7 +86296,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
DOCTYPE token's name.</dd>
- </dl><h5 id=after-doctype-name-state><span class=secno>11.2.4.55 </span><dfn>After DOCTYPE name state</dfn></h5>
+ </dl><h5 id=after-doctype-name-state><span class=secno>13.2.4.55 </span><dfn>After DOCTYPE name state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81756,7 +86336,7 @@
</dd>
- </dl><h5 id=after-doctype-public-keyword-state><span class=secno>11.2.4.56 </span><dfn>After DOCTYPE public keyword state</dfn></h5>
+ </dl><h5 id=after-doctype-public-keyword-state><span class=secno>13.2.4.56 </span><dfn>After DOCTYPE public keyword state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81793,7 +86373,7 @@
<i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus
DOCTYPE state</a>.</dd>
- </dl><h5 id=before-doctype-public-identifier-state><span class=secno>11.2.4.57 </span><dfn>Before DOCTYPE public identifier state</dfn></h5>
+ </dl><h5 id=before-doctype-public-identifier-state><span class=secno>13.2.4.57 </span><dfn>Before DOCTYPE public identifier state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81829,7 +86409,7 @@
<i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus
DOCTYPE state</a>.</dd>
- </dl><h5 id=doctype-public-identifier-(double-quoted)-state><span class=secno>11.2.4.58 </span><dfn>DOCTYPE public identifier (double-quoted) state</dfn></h5>
+ </dl><h5 id=doctype-public-identifier-(double-quoted)-state><span class=secno>13.2.4.58 </span><dfn>DOCTYPE public identifier (double-quoted) state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81854,7 +86434,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
DOCTYPE token's public identifier.</dd>
- </dl><h5 id=doctype-public-identifier-(single-quoted)-state><span class=secno>11.2.4.59 </span><dfn>DOCTYPE public identifier (single-quoted) state</dfn></h5>
+ </dl><h5 id=doctype-public-identifier-(single-quoted)-state><span class=secno>13.2.4.59 </span><dfn>DOCTYPE public identifier (single-quoted) state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81879,7 +86459,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
DOCTYPE token's public identifier.</dd>
- </dl><h5 id=after-doctype-public-identifier-state><span class=secno>11.2.4.60 </span><dfn>After DOCTYPE public identifier state</dfn></h5>
+ </dl><h5 id=after-doctype-public-identifier-state><span class=secno>13.2.4.60 </span><dfn>After DOCTYPE public identifier state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81915,7 +86495,7 @@
<i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus
DOCTYPE state</a>.</dd>
- </dl><h5 id=between-doctype-public-and-system-identifiers-state><span class=secno>11.2.4.61 </span><dfn>Between DOCTYPE public and system identifiers state</dfn></h5>
+ </dl><h5 id=between-doctype-public-and-system-identifiers-state><span class=secno>13.2.4.61 </span><dfn>Between DOCTYPE public and system identifiers state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81950,7 +86530,7 @@
<i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus
DOCTYPE state</a>.</dd>
- </dl><h5 id=after-doctype-system-keyword-state><span class=secno>11.2.4.62 </span><dfn>After DOCTYPE system keyword state</dfn></h5>
+ </dl><h5 id=after-doctype-system-keyword-state><span class=secno>13.2.4.62 </span><dfn>After DOCTYPE system keyword state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -81987,7 +86567,7 @@
<i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus
DOCTYPE state</a>.</dd>
- </dl><h5 id=before-doctype-system-identifier-state><span class=secno>11.2.4.63 </span><dfn>Before DOCTYPE system identifier state</dfn></h5>
+ </dl><h5 id=before-doctype-system-identifier-state><span class=secno>13.2.4.63 </span><dfn>Before DOCTYPE system identifier state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -82023,7 +86603,7 @@
<i>force-quirks flag</i> to <i>on</i>. Switch to the <a href=#bogus-doctype-state>bogus
DOCTYPE state</a>.</dd>
- </dl><h5 id=doctype-system-identifier-(double-quoted)-state><span class=secno>11.2.4.64 </span><dfn>DOCTYPE system identifier (double-quoted) state</dfn></h5>
+ </dl><h5 id=doctype-system-identifier-(double-quoted)-state><span class=secno>13.2.4.64 </span><dfn>DOCTYPE system identifier (double-quoted) state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -82049,7 +86629,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
DOCTYPE token's system identifier.</dd>
- </dl><h5 id=doctype-system-identifier-(single-quoted)-state><span class=secno>11.2.4.65 </span><dfn>DOCTYPE system identifier (single-quoted) state</dfn></h5>
+ </dl><h5 id=doctype-system-identifier-(single-quoted)-state><span class=secno>13.2.4.65 </span><dfn>DOCTYPE system identifier (single-quoted) state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -82075,7 +86655,7 @@
<dd>Append the <a href=#current-input-character>current input character</a> to the current
DOCTYPE token's system identifier.</dd>
- </dl><h5 id=after-doctype-system-identifier-state><span class=secno>11.2.4.66 </span><dfn>After DOCTYPE system identifier state</dfn></h5>
+ </dl><h5 id=after-doctype-system-identifier-state><span class=secno>13.2.4.66 </span><dfn>After DOCTYPE system identifier state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -82100,7 +86680,7 @@
state</a>. (This does <em>not</em> set the DOCTYPE token's
<i>force-quirks flag</i> to <i>on</i>.)</dd>
- </dl><h5 id=bogus-doctype-state><span class=secno>11.2.4.67 </span><dfn>Bogus DOCTYPE state</dfn></h5>
+ </dl><h5 id=bogus-doctype-state><span class=secno>13.2.4.67 </span><dfn>Bogus DOCTYPE state</dfn></h5>
<p>Consume the <a href=#next-input-character>next input character</a>:</p>
@@ -82115,7 +86695,7 @@
<dt>Anything else</dt>
<dd>Ignore the character.</dd>
- </dl><h5 id=cdata-section-state><span class=secno>11.2.4.68 </span><dfn>CDATA section state</dfn></h5>
+ </dl><h5 id=cdata-section-state><span class=secno>13.2.4.68 </span><dfn>CDATA section state</dfn></h5>
<p>Consume every character up to the next occurrence of the three
character sequence U+005D RIGHT SQUARE BRACKET U+005D RIGHT SQUARE
@@ -82134,7 +86714,7 @@
- <h5 id=tokenizing-character-references><span class=secno>11.2.4.69 </span>Tokenizing character references</h5>
+ <h5 id=tokenizing-character-references><span class=secno>13.2.4.69 </span>Tokenizing character references</h5>
<p>This section defines how to <dfn id=consume-a-character-reference>consume a character
reference</dfn>. This definition is used when parsing character
@@ -82345,7 +86925,7 @@
thing to do is to close some formatting elements from the middle of
the stack when you hit a limit, or something. -->
- <h4 id=tree-construction><span class=secno>11.2.5 </span><dfn>Tree construction</dfn></h4>
+ <h4 id=tree-construction><span class=secno>13.2.5 </span><dfn>Tree construction</dfn></h4>
<p>The input to the tree construction stage is a sequence of tokens
from the <a href=#tokenization>tokenization</a> stage. The tree construction
@@ -82453,7 +87033,7 @@
constraints.</p>
- <h5 id=creating-and-inserting-elements><span class=secno>11.2.5.1 </span>Creating and inserting elements</h5>
+ <h5 id=creating-and-inserting-elements><span class=secno>13.2.5.1 </span>Creating and inserting elements</h5>
<p>When the steps below require the UA to <dfn id=create-an-element-for-the-token title="create an
element for the token">create an element for a token</dfn> in a
@@ -82633,7 +87213,7 @@
<li><p>Then, switch the <a href=#insertion-mode>insertion mode</a> to "<a href=#parsing-main-incdata title="insertion mode: text">text</a>".</li>
- </ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>11.2.5.2 </span>Closing elements that have implied end tags</h5>
+ </ol><h5 id=closing-elements-that-have-implied-end-tags><span class=secno>13.2.5.2 </span>Closing elements that have implied end tags</h5>
<p>When the steps below require the UA to <dfn id=generate-implied-end-tags>generate implied end
tags</dfn>, then, while the <a href=#current-node>current node</a> is a
@@ -82649,7 +87229,7 @@
above steps as if that element was not in the above list.</p>
- <h5 id=foster-parenting><span class=secno>11.2.5.3 </span>Foster parenting</h5>
+ <h5 id=foster-parenting><span class=secno>13.2.5.3 </span>Foster parenting</h5>
<p>Foster parenting happens when content is misnested in tables.</p>
@@ -82687,10 +87267,10 @@
- <h5 id=parsing-main-inhtml><span class=secno>11.2.5.4 </span>The rules for parsing tokens in HTML content</h5>
+ <h5 id=parsing-main-inhtml><span class=secno>13.2.5.4 </span>The rules for parsing tokens in HTML content</h5>
- <h6 id=the-initial-insertion-mode><span class=secno>11.2.5.4.1 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h6>
+ <h6 id=the-initial-insertion-mode><span class=secno>13.2.5.4.1 </span>The "<dfn title="insertion mode: initial">initial</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#the-initial-insertion-mode title="insertion mode: initial">initial</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -82883,7 +87463,7 @@
</dd>
- </dl><h6 id=the-before-html-insertion-mode><span class=secno>11.2.5.4.2 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h6>
+ </dl><h6 id=the-before-html-insertion-mode><span class=secno>13.2.5.4.2 </span>The "<dfn title="insertion mode: before html">before html</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#the-before-html-insertion-mode title="insertion mode: before html">before html</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -82966,7 +87546,7 @@
as described in the next section.</p>
- <h6 id=the-before-head-insertion-mode><span class=secno>11.2.5.4.3 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h6>
+ <h6 id=the-before-head-insertion-mode><span class=secno>13.2.5.4.3 </span>The "<dfn title="insertion mode: before head">before head</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#the-before-head-insertion-mode title="insertion mode: before head">before head</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -83031,7 +87611,7 @@
</dd>
- </dl><h6 id=parsing-main-inhead><span class=secno>11.2.5.4.4 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-inhead><span class=secno>13.2.5.4.4 </span>The "<dfn title="insertion mode: in head">in head</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inhead title="insertion mode: in head">in head</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -83197,7 +87777,7 @@
</dd>
- </dl><h6 id=parsing-main-inheadnoscript><span class=secno>11.2.5.4.5 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-inheadnoscript><span class=secno>13.2.5.4.5 </span>The "<dfn title="insertion mode: in head noscript">in head noscript</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inheadnoscript title="insertion mode: in head noscript">in head noscript</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -83257,7 +87837,7 @@
</dd>
- </dl><h6 id=the-after-head-insertion-mode><span class=secno>11.2.5.4.6 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h6>
+ </dl><h6 id=the-after-head-insertion-mode><span class=secno>13.2.5.4.6 </span>The "<dfn title="insertion mode: after head">after head</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#the-after-head-insertion-mode title="insertion mode: after head">after head</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -83347,7 +87927,7 @@
token.</p>
</dd>
- </dl><h6 id=parsing-main-inbody><span class=secno>11.2.5.4.7 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-inbody><span class=secno>13.2.5.4.7 </span>The "<dfn title="insertion mode: in body">in body</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inbody title="insertion mode: in body">in body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -84610,7 +89190,7 @@
</ol></dd>
- </dl><h6 id=parsing-main-incdata><span class=secno>11.2.5.4.8 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-incdata><span class=secno>13.2.5.4.8 </span>The "<dfn title="insertion mode: text">text</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-incdata title="insertion mode: text">text</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -84762,7 +89342,7 @@
</dd>
- </dl><h6 id=parsing-main-intable><span class=secno>11.2.5.4.9 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-intable><span class=secno>13.2.5.4.9 </span>The "<dfn title="insertion mode: in table">in table</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intable title="insertion mode: in table">in table</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -84965,7 +89545,7 @@
- <h6 id=parsing-main-intabletext><span class=secno>11.2.5.4.10 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h6>
+ <h6 id=parsing-main-intabletext><span class=secno>13.2.5.4.10 </span>The "<dfn title="insertion mode: in table text">in table text</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intabletext title="insertion mode: in table text">in table text</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85004,7 +89584,7 @@
</dd>
- </dl><h6 id=parsing-main-incaption><span class=secno>11.2.5.4.11 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-incaption><span class=secno>13.2.5.4.11 </span>The "<dfn title="insertion mode: in caption">in caption</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-incaption title="insertion mode: in caption">in caption</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85061,7 +89641,7 @@
mode</a>.</p>
</dd>
- </dl><h6 id=parsing-main-incolgroup><span class=secno>11.2.5.4.12 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-incolgroup><span class=secno>13.2.5.4.12 </span>The "<dfn title="insertion mode: in column group">in column group</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-incolgroup title="insertion mode: in column group">in column group</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85147,7 +89727,7 @@
</dd>
- </dl><h6 id=parsing-main-intbody><span class=secno>11.2.5.4.13 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-intbody><span class=secno>13.2.5.4.13 </span>The "<dfn title="insertion mode: in table body">in table body</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intbody title="insertion mode: in table body">in table body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85235,7 +89815,7 @@
case</a>.</p>
- <h6 id=parsing-main-intr><span class=secno>11.2.5.4.14 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h6>
+ <h6 id=parsing-main-intr><span class=secno>13.2.5.4.14 </span>The "<dfn title="insertion mode: in row">in row</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intr title="insertion mode: in row">in row</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85325,7 +89905,7 @@
case</a>.</p>
- <h6 id=parsing-main-intd><span class=secno>11.2.5.4.15 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h6>
+ <h6 id=parsing-main-intd><span class=secno>13.2.5.4.15 </span>The "<dfn title="insertion mode: in cell">in cell</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-intd title="insertion mode: in cell">in cell</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85418,7 +89998,7 @@
cell</a> algorithm is invoked.</p>
- <h6 id=parsing-main-inselect><span class=secno>11.2.5.4.16 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h6>
+ <h6 id=parsing-main-inselect><span class=secno>13.2.5.4.16 </span>The "<dfn title="insertion mode: in select">in select</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselect title="insertion mode: in select">in select</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85568,7 +90148,7 @@
<p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
</dd>
- </dl><h6 id=parsing-main-inselectintable><span class=secno>11.2.5.4.17 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-inselectintable><span class=secno>13.2.5.4.17 </span>The "<dfn title="insertion mode: in select in table">in select in table</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselectintable title="insertion mode: in select in table">in select in table</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85599,7 +90179,7 @@
mode</a>.</p>
</dd>
- </dl><h6 id=parsing-main-afterbody><span class=secno>11.2.5.4.18 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-afterbody><span class=secno>13.2.5.4.18 </span>The "<dfn title="insertion mode: after body">after body</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterbody title="insertion mode: after body">after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85656,7 +90236,7 @@
</dd>
- </dl><h6 id=parsing-main-inframeset><span class=secno>11.2.5.4.19 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-inframeset><span class=secno>13.2.5.4.19 </span>The "<dfn title="insertion mode: in frameset">in frameset</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-inframeset title="insertion mode: in frameset">in frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85748,7 +90328,7 @@
<p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
</dd>
- </dl><h6 id=parsing-main-afterframeset><span class=secno>11.2.5.4.20 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
+ </dl><h6 id=parsing-main-afterframeset><span class=secno>13.2.5.4.20 </span>The "<dfn title="insertion mode: after frameset">after frameset</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#parsing-main-afterframeset title="insertion mode: after frameset">after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85801,7 +90381,7 @@
<p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
</dd>
- </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>11.2.5.4.21 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
+ </dl><h6 id=the-after-after-body-insertion-mode><span class=secno>13.2.5.4.21 </span>The "<dfn title="insertion mode: after after body">after after body</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#the-after-after-body-insertion-mode title="insertion mode: after after body">after after body</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85834,7 +90414,7 @@
reprocess the token.</p>
</dd>
- </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>11.2.5.4.22 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
+ </dl><h6 id=the-after-after-frameset-insertion-mode><span class=secno>13.2.5.4.22 </span>The "<dfn title="insertion mode: after after frameset">after after frameset</dfn>" insertion mode</h6>
<p>When the user agent is to apply the rules for the "<a href=#the-after-after-frameset-insertion-mode title="insertion mode: after after frameset">after after frameset</a>" <a href=#insertion-mode>insertion mode</a>, the user agent must handle the token as follows:</p>
@@ -85871,7 +90451,7 @@
<p><a href=#parse-error>Parse error</a>. Ignore the token.</p>
</dd>
- </dl><h5 id=parsing-main-inforeign><span class=secno>11.2.5.5 </span>The rules for parsing tokens <dfn title="insertion mode: in foreign content">in foreign content</dfn></h5>
+ </dl><h5 id=parsing-main-inforeign><span class=secno>13.2.5.5 </span>The rules for parsing tokens <dfn title="insertion mode: in foreign content">in foreign content</dfn></h5>
<p>When the user agent is to apply the rules for parsing tokens in foreign content, the user agent must handle the token as follows:</p>
@@ -86093,7 +90673,7 @@
<div class=impl>
- <h4 id=the-end><span class=secno>11.2.6 </span>The end</h4>
+ <h4 id=the-end><span class=secno>13.2.6 </span>The end</h4>
<p>Once the user agent <dfn id=stop-parsing title="stop parsing">stops parsing</dfn>
the document, the user agent must run the following steps:</p>
@@ -86215,7 +90795,7 @@
<div class=impl>
- <h4 id=coercing-an-html-dom-into-an-infoset><span class=secno>11.2.7 </span>Coercing an HTML DOM into an infoset</h4>
+ <h4 id=coercing-an-html-dom-into-an-infoset><span class=secno>13.2.7 </span>Coercing an HTML DOM into an infoset</h4>
<p>When an application uses an <a href=#html-parser>HTML parser</a> in
conjunction with an XML pipeline, it is possible that the
@@ -86304,7 +90884,7 @@
<div class=impl>
- <h4 id=an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>11.2.8 </span>An introduction to error handling and strange cases in the parser</h4>
+ <h4 id=an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>13.2.8 </span>An introduction to error handling and strange cases in the parser</h4>
<p><i>This section is non-normative.</i></p>
@@ -86312,7 +90892,7 @@
the <a href=#html-parser>HTML parser</a> handles these cases.</p>
- <h5 id=misnested-tags:-b-i-/b-/i><span class=secno>11.2.8.1 </span>Misnested tags: <b><i></b></i></h5>
+ <h5 id=misnested-tags:-b-i-/b-/i><span class=secno>13.2.8.1 </span>Misnested tags: <b><i></b></i></h5>
<p><i>This section is non-normative.</i></p>
@@ -86346,7 +90926,7 @@
received, and the "5" text node is inserted, the DOM looks as
follows:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">4</span></ul><li class=t3><code>#text</code>: <span title="">5</span></ul></ul></ul></ul><h5 id=misnested-tags:-b-p-/b-/p><span class=secno>11.2.8.2 </span>Misnested tags: <b><p></b></p></h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul><li class=t1><code><a href=#the-i-element>i</a></code><ul><li class=t3><code>#text</code>: <span title="">4</span></ul><li class=t3><code>#text</code>: <span title="">5</span></ul></ul></ul></ul><h5 id=misnested-tags:-b-p-/b-/p><span class=secno>13.2.8.2 </span>Misnested tags: <b><p></b></p></h5>
<p><i>This section is non-normative.</i></p>
@@ -86395,7 +90975,7 @@
elements</a>, so that when the "3" is parsed, it is appended to
the <code><a href=#the-p-element>p</a></code> element:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul><h5 id=unexpected-markup-in-tables><span class=secno>11.2.8.3 </span>Unexpected markup in tables</h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">1</span></ul><li class=t1><code><a href=#the-p-element>p</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">2</span></ul><li class=t3><code>#text</code>: <span title="">3</span></ul></ul></ul></ul><h5 id=unexpected-markup-in-tables><span class=secno>13.2.8.3 </span>Unexpected markup in tables</h5>
<p><i>This section is non-normative.</i></p>
@@ -86494,7 +91074,7 @@
result in yet another <code><a href=#the-b-element>b</a></code> element being created, this
time after the table:</p>
- <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">ccc</span></ul></ul></ul></ul><h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>11.2.8.4 </span>Scripts that modify the page as it is being pars
ed</h5>
+ <ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-b-element>b</a></code><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">bbb</span></ul><li class=t1><code><a href=#the-table-element>table</a></code><ul><li class=t1><code><a href=#the-tbody-element>tbody</a></code><ul><li class=t1><code><a href=#the-tr-element>tr</a></code><ul><li class=t1><code><a href=#the-td-element>td</a></code><ul><li class=t3><code>#text</code>: <span title="">aaa</span></ul></ul></ul></ul><li class=t1><code><a href=#the-b-element>b</a></code><ul><li class=t3><code>#text</code>: <span title="">ccc</span></ul></ul></ul></ul><h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>13.2.8.4 </span>Scripts that modify the page as it is being pars
ed</h5>
<p><i>This section is non-normative.</i></p>
@@ -86543,7 +91123,7 @@
<ul class=domTree><li class=t1><code><a href=#the-html-element>html</a></code><ul><li class=t1><code><a href=#the-head-element>head</a></code><li class=t1><code><a href=#the-body-element>body</a></code><ul><li class=t1><code><a href=#the-script-element>script</a></code><ul><li class=t3><code>#text</code>: <span title="">alert(document.URL);</span></ul></ul></ul></ul><p>This script does execute, resulting in an alert that says "http://example.com/inner".</p>
- <h5 id=the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>11.2.8.5 </span>The execution of scripts that are moving across multiple documents</h5>
+ <h5 id=the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>13.2.8.5 </span>The execution of scripts that are moving across multiple documents</h5>
<p><i>This section is non-normative.</i></p>
@@ -86564,7 +91144,7 @@
- <h5 id=unclosed-formatting-elements><span class=secno>11.2.8.6 </span>Unclosed formatting elements</h5>
+ <h5 id=unclosed-formatting-elements><span class=secno>13.2.8.6 </span>Unclosed formatting elements</h5>
<p><i>This section is non-normative.</i></p>
@@ -86596,7 +91176,7 @@
- <h3 id=serializing-html-fragments><span class=secno>11.3 </span>Serializing HTML fragments</h3>
+ <h3 id=serializing-html-fragments><span class=secno>13.3 </span>Serializing HTML fragments</h3>
<p>The following steps form the <dfn id=html-fragment-serialization-algorithm>HTML fragment serialization
algorithm</dfn>. The algorithm takes as input a DOM
@@ -86860,7 +91440,7 @@
<li><p>If the algorithm was <em>not</em> invoked in the
<i>attribute mode</i>, replace any occurrences of the "<code title=""><</code>" character by the string "<code title=""><</code>", and any occurrences of the "<code title="">></code>" character by the string "<code title="">></code>".</li>
- </ol><h3 id=parsing-html-fragments><span class=secno>11.4 </span>Parsing HTML fragments</h3>
+ </ol><h3 id=parsing-html-fragments><span class=secno>13.4 </span>Parsing HTML fragments</h3>
<p>The following steps form the <dfn id=html-fragment-parsing-algorithm>HTML fragment parsing
algorithm</dfn>. The algorithm optionally takes as input an
@@ -87040,7 +91620,7 @@
- <h3 id=named-character-references><span class=secno>11.5 </span><dfn>Named character references</dfn></h3>
+ <h3 id=named-character-references><span class=secno>13.5 </span><dfn>Named character references</dfn></h3>
<p>This table lists the character reference names that are supported
by HTML, and the code points to which they refer. It is referenced
@@ -87061,7 +91641,7 @@
- <h2 id=the-xhtml-syntax><span class=secno>12 </span><dfn id=xhtml>The XHTML syntax</dfn></h2>
+ <h2 id=the-xhtml-syntax><span class=secno>14 </span><dfn id=xhtml>The XHTML syntax</dfn></h2>
<p class=note>This section only describes the rules for XML
resources. Rules for <code><a href=#text/html>text/html</a></code> resources are discussed
@@ -87070,7 +91650,7 @@
<div class=impl>
- <h3 id=writing-xhtml-documents><span class=secno>12.1 </span>Writing XHTML documents</h3>
+ <h3 id=writing-xhtml-documents><span class=secno>14.1 </span>Writing XHTML documents</h3>
</div>
@@ -87095,7 +91675,7 @@
<div class=impl>
- <h3 id=parsing-xhtml-documents><span class=secno>12.2 </span>Parsing XHTML documents</h3>
+ <h3 id=parsing-xhtml-documents><span class=secno>14.2 </span>Parsing XHTML documents</h3>
<p>This section describes the relationship between XML and the DOM,
with a particular emphasis on how this interacts with HTML.</p>
@@ -87212,7 +91792,7 @@
- <h3 id=serializing-xhtml-fragments><span class=secno>12.3 </span>Serializing XHTML fragments</h3>
+ <h3 id=serializing-xhtml-fragments><span class=secno>14.3 </span>Serializing XHTML fragments</h3>
<p>The <dfn id=xml-fragment-serialization-algorithm>XML fragment serialization algorithm</dfn> for a
<code><a href=#document>Document</a></code> or <code><a href=#element>Element</a></code> node either returns a
@@ -87309,7 +91889,7 @@
- <h3 id=parsing-xhtml-fragments><span class=secno>12.4 </span>Parsing XHTML fragments</h3>
+ <h3 id=parsing-xhtml-fragments><span class=secno>14.4 </span>Parsing XHTML fragments</h3>
<p>The <dfn id=xml-fragment-parsing-algorithm>XML fragment parsing algorithm</dfn> either returns a
<code><a href=#document>Document</a></code> or throws a <code><a href=#syntaxerror>SyntaxError</a></code> exception.
@@ -87383,7 +91963,7 @@
<div class=impl>
- <h2 id=rendering><span class=secno>13 </span>Rendering</h2>
+ <h2 id=rendering><span class=secno>15 </span>Rendering</h2>
<p><i>User agents are not required to present HTML documents in any
particular way. However, this section provides a set of suggestions
@@ -87399,7 +91979,7 @@
"must".</i></p>
- <h3 id=introduction-15><span class=secno>13.1 </span>Introduction</h3>
+ <h3 id=introduction-17><span class=secno>15.1 </span>Introduction</h3>
<p>In general, user agents are expected to support CSS, and many of
the suggestions in this section are expressed in CSS terms. User
@@ -87440,7 +92020,7 @@
- <h3 id=the-css-user-agent-style-sheet-and-presentational-hints><span class=secno>13.2 </span>The CSS user agent style sheet and presentational hints</h3>
+ <h3 id=the-css-user-agent-style-sheet-and-presentational-hints><span class=secno>15.2 </span>The CSS user agent style sheet and presentational hints</h3>
<p>The CSS rules given in these subsections are, except where
otherwise specified, expected to be used as part of the user-agent
@@ -87501,10 +92081,10 @@
- <h3 id=non-replaced-elements><span class=secno>13.3 </span>Non-replaced elements</h3>
+ <h3 id=non-replaced-elements><span class=secno>15.3 </span>Non-replaced elements</h3>
- <h4 id=hidden-elements><span class=secno>13.3.1 </span>Hidden elements</h4>
+ <h4 id=hidden-elements><span class=secno>15.3.1 </span>Hidden elements</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -87519,7 +92099,7 @@
'none', irrespective of CSS rules.</p>
- <h4 id=the-page><span class=secno>13.3.2 </span>The page</h4>
+ <h4 id=the-page><span class=secno>15.3.2 </span>The page</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -87650,7 +92230,7 @@
- <h4 id=flow-content-1><span class=secno>13.3.3 </span>Flow content</h4>
+ <h4 id=flow-content-1><span class=secno>15.3.3 </span>Flow content</h4>
<!-- del, ins, and map are inline. -->
@@ -87715,7 +92295,7 @@
- <h4 id=phrasing-content-1><span class=secno>13.3.4 </span>Phrasing content</h4>
+ <h4 id=phrasing-content-1><span class=secno>15.3.4 </span>Phrasing content</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -87902,7 +92482,7 @@
</li>
- </ol><h4 id=bidirectional-text><span class=secno>13.3.5 </span>Bidirectional text</h4>
+ </ol><h4 id=bidirectional-text><span class=secno>15.3.5 </span>Bidirectional text</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -87915,7 +92495,7 @@
textarea[dir=auto], pre[dir=auto] { unicode-bidi: plaintext; } /* <a href=#case-insensitive-selector-exception>case-insensitive</a> */</pre>
- <h4 id=sections-and-headings><span class=secno>13.3.6 </span>Sections and headings</h4>
+ <h4 id=sections-and-headings><span class=secno>15.3.6 </span>Sections and headings</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -87948,7 +92528,7 @@
- <h4 id=lists><span class=secno>13.3.7 </span>Lists</h4>
+ <h4 id=lists><span class=secno>15.3.7 </span>Lists</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -88017,7 +92597,7 @@
to render the counter in the list item marker.</p>
- <h4 id=tables><span class=secno>13.3.8 </span>Tables</h4>
+ <h4 id=tables><span class=secno>15.3.8 </span>Tables</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -88370,7 +92950,7 @@
- <h4 id=form-controls><span class=secno>13.3.9 </span>Form controls</h4>
+ <h4 id=form-controls><span class=secno>15.3.9 </span>Form controls</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -88394,7 +92974,7 @@
- <h4 id=the-hr-element-0><span class=secno>13.3.10 </span>The <code><a href=#the-hr-element>hr</a></code> element</h4>
+ <h4 id=the-hr-element-0><span class=secno>15.3.10 </span>The <code><a href=#the-hr-element>hr</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -88444,7 +93024,7 @@
- <h4 id=the-fieldset-element-0><span class=secno>13.3.11 </span>The <code><a href=#the-fieldset-element>fieldset</a></code> element</h4>
+ <h4 id=the-fieldset-element-0><span class=secno>15.3.11 </span>The <code><a href=#the-fieldset-element>fieldset</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -88491,9 +93071,9 @@
<td>On the right
<tr><td><code title="">center</code>
<td>In the middle
- </table><h3 id=replaced-elements><span class=secno>13.4 </span>Replaced elements</h3>
+ </table><h3 id=replaced-elements><span class=secno>15.4 </span>Replaced elements</h3>
- <h4 id=embedded-content-2><span class=secno>13.4.1 </span>Embedded content</h4>
+ <h4 id=embedded-content-2><span class=secno>15.4.1 </span>Embedded content</h4>
<p>The <code><a href=#the-embed-element>embed</a></code>, <code><a href=#the-iframe-element>iframe</a></code>, and
<code><a href=#the-video-element>video</a></code> elements are expected to be treated as replaced
@@ -88566,14 +93146,14 @@
<div class=impl>
- <h4 id=timed-text-tracks-0><span class=secno>13.4.2 </span>Timed text tracks</h4>
+ <h4 id=timed-text-tracks-0><span class=secno>15.4.2 </span>Timed text tracks</h4>
<p class=note>This section is intended to be moved to its own CSS
module once an editor is found to run with it.</p>
- <h5 id=webvtt-cue-text-rendering-rules><span class=secno>13.4.2.1 </span><dfn>WebVTT cue text rendering rules</dfn></h5>
+ <h5 id=webvtt-cue-text-rendering-rules><span class=secno>15.4.2.1 </span><dfn>WebVTT cue text rendering rules</dfn></h5>
<p>The <dfn id=rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT text
tracks</dfn> render the <a href=#text-track title="text track">text
@@ -89129,7 +93709,7 @@
entirely.</p>
- <h5 id=applying-css-properties-to-webvtt-node-objects><span class=secno>13.4.2.2 </span>Applying CSS properties to <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a></h5>
+ <h5 id=applying-css-properties-to-webvtt-node-objects><span class=secno>15.4.2.2 </span>Applying CSS properties to <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a></h5>
<p>When following the <a href=#rules-for-updating-the-display-of-webvtt-text-tracks>rules for updating the display of WebVTT
text tracks</a>, user agents must set properties of <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a> as defined in
@@ -89192,7 +93772,7 @@
values.</p>
- <h5 id=css-extensions><span class=secno>13.4.2.3 </span>CSS extensions</h5>
+ <h5 id=css-extensions><span class=secno>15.4.2.3 </span>CSS extensions</h5>
<p>When a user agent is rendering one or more <a href=#text-track-cue title="text
track cue">text track cues</a> according to the <a href=#webvtt-cue-text-rendering-rules>WebVTT cue
@@ -89224,7 +93804,7 @@
':past' and ':future' pseudo-classes.</p>
- <h6 id="the-'::cue'-pseudo-element"><span class=secno>13.4.2.3.1 </span>The '::cue' pseudo-element</h6>
+ <h6 id="the-'::cue'-pseudo-element"><span class=secno>15.4.2.3.1 </span>The '::cue' pseudo-element</h6>
<p>The '<dfn id=pseudo-cue title=pseudo-cue>::cue</dfn>' pseudo-element (with no
argument) matches any <a href=#list-of-webvtt-node-objects>List of WebVTT Node Objects</a>
@@ -89366,7 +93946,7 @@
the <a href=#webvtt-cue-background-box>WebVTT cue background box</a>.</p>
- <h6 id="the-':past'-and-':future'-pseudo-classes"><span class=secno>13.4.2.3.2 </span>The ':past' and ':future' pseudo-classes</h6>
+ <h6 id="the-':past'-and-':future'-pseudo-classes"><span class=secno>15.4.2.3.2 </span>The ':past' and ':future' pseudo-classes</h6>
<p>The <dfn id=past-pseudo-class title=past-pseudo-class>':past'</dfn> and <dfn id=future-pseudo-class title=future-pseudo-class>':future'</dfn> pseudo-classes only
match <a href=#webvtt-node-object title="WebVTT Node Object">WebVTT Node Objects</a>.</p>
@@ -89404,7 +93984,7 @@
<div class=impl>
- <h4 id=images-0><span class=secno>13.4.3 </span>Images</h4>
+ <h4 id=images-0><span class=secno>15.4.3 </span>Images</h4>
<p>When an <code><a href=#the-img-element>img</a></code> element or an <code><a href=#the-input-element>input</a></code> element
when its <code title=attr-input-type><a href=#attr-input-type>type</a></code> attribute is in
@@ -89486,7 +94066,7 @@
<div class=impl>
- <h4 id=attributes-for-embedded-content-and-images><span class=secno>13.4.4 </span>Attributes for embedded content and images</h4>
+ <h4 id=attributes-for-embedded-content-and-images><span class=secno>15.4.4 </span>Attributes for embedded content and images</h4>
<p>The following CSS rules are expected to apply as
<a href=#presentational-hints>presentational hints</a>:</p>
@@ -89582,7 +94162,7 @@
<div class=impl>
- <h4 id=image-maps-0><span class=secno>13.4.5 </span>Image maps</h4>
+ <h4 id=image-maps-0><span class=secno>15.4.5 </span>Image maps</h4>
<p>Shapes on an <a href=#image-map>image map</a> are expected to act, for the
purpose of the CSS cascade, as elements independent of the original
@@ -89610,7 +94190,7 @@
<div class=impl>
- <h4 id=toolbars-0><span class=secno>13.4.6 </span>Toolbars</h4>
+ <h4 id=toolbars-0><span class=secno>15.4.6 </span>Toolbars</h4>
<p>When a <code><a href=#the-menu-element>menu</a></code> element's <code title=attr-menu-type><a href=#attr-menu-type>type</a></code> attribute is in the <a href=#toolbar-state title="toolbar state">toolbar</a> state, the element is
expected to be treated as a replaced element with a height about two
@@ -89626,9 +94206,9 @@
<div class=impl>
- <h3 id=bindings><span class=secno>13.5 </span>Bindings</h3>
+ <h3 id=bindings><span class=secno>15.5 </span>Bindings</h3>
- <h4 id=introduction-16><span class=secno>13.5.1 </span>Introduction</h4>
+ <h4 id=introduction-18><span class=secno>15.5.1 </span>Introduction</h4>
<p>A number of elements have their rendering defined in terms of the
'binding' property. <a href=#refsBECSS>[BECSS]</a></p>
@@ -89651,7 +94231,7 @@
<div class=impl>
- <h4 id=the-button-element-0><span class=secno>13.5.2 </span>The <code><a href=#the-button-element>button</a></code> element</h4>
+ <h4 id=the-button-element-0><span class=secno>15.5.2 </span>The <code><a href=#the-button-element>button</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89667,7 +94247,7 @@
<div class=impl>
- <h4 id=the-details-element-0><span class=secno>13.5.3 </span>The <code><a href=#the-details-element>details</a></code> element</h4>
+ <h4 id=the-details-element-0><span class=secno>15.5.3 </span>The <code><a href=#the-details-element>details</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89702,7 +94282,7 @@
<div class=impl>
- <h4 id=the-input-element-as-a-text-entry-widget><span class=secno>13.5.4 </span>The <code><a href=#the-input-element>input</a></code> element as a text entry widget</h4>
+ <h4 id=the-input-element-as-a-text-entry-widget><span class=secno>15.5.4 </span>The <code><a href=#the-input-element>input</a></code> element as a text entry widget</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89749,7 +94329,7 @@
<div class=impl>
- <h4 id=the-input-element-as-domain-specific-widgets><span class=secno>13.5.5 </span>The <code><a href=#the-input-element>input</a></code> element as domain-specific widgets</h4>
+ <h4 id=the-input-element-as-domain-specific-widgets><span class=secno>15.5.5 </span>The <code><a href=#the-input-element>input</a></code> element as domain-specific widgets</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89804,7 +94384,7 @@
<div class=impl>
- <h4 id=the-input-element-as-a-range-control><span class=secno>13.5.6 </span>The <code><a href=#the-input-element>input</a></code> element as a range control</h4>
+ <h4 id=the-input-element-as-a-range-control><span class=secno>15.5.6 </span>The <code><a href=#the-input-element>input</a></code> element as a range control</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89830,7 +94410,7 @@
<div class=impl>
- <h4 id=the-input-element-as-a-color-well><span class=secno>13.5.7 </span>The <code><a href=#the-input-element>input</a></code> element as a color well</h4>
+ <h4 id=the-input-element-as-a-color-well><span class=secno>15.5.7 </span>The <code><a href=#the-input-element>input</a></code> element as a color well</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89852,7 +94432,7 @@
<div class=impl>
- <h4 id=the-input-element-as-a-checkbox-and-radio-button-widgets><span class=secno>13.5.8 </span>The <code><a href=#the-input-element>input</a></code> element as a checkbox and radio button widgets</h4>
+ <h4 id=the-input-element-as-a-checkbox-and-radio-button-widgets><span class=secno>15.5.8 </span>The <code><a href=#the-input-element>input</a></code> element as a checkbox and radio button widgets</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89874,7 +94454,7 @@
<div class=impl>
- <h4 id=the-input-element-as-a-file-upload-control><span class=secno>13.5.9 </span>The <code><a href=#the-input-element>input</a></code> element as a file upload control</h4>
+ <h4 id=the-input-element-as-a-file-upload-control><span class=secno>15.5.9 </span>The <code><a href=#the-input-element>input</a></code> element as a file upload control</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89892,7 +94472,7 @@
<div class=impl>
- <h4 id=the-input-element-as-a-button><span class=secno>13.5.10 </span>The <code><a href=#the-input-element>input</a></code> element as a button</h4>
+ <h4 id=the-input-element-as-a-button><span class=secno>15.5.10 </span>The <code><a href=#the-input-element>input</a></code> element as a button</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -89913,7 +94493,7 @@
<div class=impl>
- <h4 id=the-marquee-element-0><span class=secno>13.5.11 </span>The <code><a href=#the-marquee-element>marquee</a></code> element</h4>
+ <h4 id=the-marquee-element-0><span class=secno>15.5.11 </span>The <code><a href=#the-marquee-element>marquee</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -90077,7 +94657,7 @@
<div class=impl>
- <h4 id=the-meter-element-0><span class=secno>13.5.12 </span>The <code><a href=#the-meter-element>meter</a></code> element</h4>
+ <h4 id=the-meter-element-0><span class=secno>15.5.12 </span>The <code><a href=#the-meter-element>meter</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -90108,7 +94688,7 @@
<div class=impl>
- <h4 id=the-progress-element-0><span class=secno>13.5.13 </span>The <code><a href=#the-progress-element>progress</a></code> element</h4>
+ <h4 id=the-progress-element-0><span class=secno>15.5.13 </span>The <code><a href=#the-progress-element>progress</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -90154,7 +94734,7 @@
<div class=impl>
- <h4 id=the-select-element-0><span class=secno>13.5.14 </span>The <code><a href=#the-select-element>select</a></code> element</h4>
+ <h4 id=the-select-element-0><span class=secno>15.5.14 </span>The <code><a href=#the-select-element>select</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -90222,7 +94802,7 @@
<div class=impl>
- <h4 id=the-textarea-element-0><span class=secno>13.5.15 </span>The <code><a href=#the-textarea-element>textarea</a></code> element</h4>
+ <h4 id=the-textarea-element-0><span class=secno>15.5.15 </span>The <code><a href=#the-textarea-element>textarea</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -90277,7 +94857,7 @@
<div class=impl>
- <h4 id=the-keygen-element-0><span class=secno>13.5.16 </span>The <code><a href=#the-keygen-element>keygen</a></code> element</h4>
+ <h4 id=the-keygen-element-0><span class=secno>15.5.16 </span>The <code><a href=#the-keygen-element>keygen</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -90293,7 +94873,7 @@
<div class=impl>
- <h4 id=the-time-element-0><span class=secno>13.5.17 </span>The <code><a href=#the-time-element>time</a></code> element</h4>
+ <h4 id=the-time-element-0><span class=secno>15.5.17 </span>The <code><a href=#the-time-element>time</a></code> element</h4>
<pre class=css>@namespace url(http://www.w3.org/1999/xhtml);
@@ -90313,7 +94893,7 @@
<div class=impl>
- <h3 id=frames-and-framesets><span class=secno>13.6 </span>Frames and framesets</h3>
+ <h3 id=frames-and-framesets><span class=secno>15.6 </span>Frames and framesets</h3>
<p>When an <code><a href=#the-html-element>html</a></code> element's second child element is a
<code><a href=#frameset>frameset</a></code> element, the user agent is expected to render
@@ -90598,9 +95178,9 @@
<div class=impl>
- <h3 id=interactive-media><span class=secno>13.7 </span>Interactive media</h3>
+ <h3 id=interactive-media><span class=secno>15.7 </span>Interactive media</h3>
- <h4 id=links,-forms,-and-navigation><span class=secno>13.7.1 </span>Links, forms, and navigation</h4>
+ <h4 id=links,-forms,-and-navigation><span class=secno>15.7.1 </span>Links, forms, and navigation</h4>
<p>User agents are expected to allow the user to control aspects of
<a href=#hyperlink>hyperlink</a> activation and <a href=#form-submission>form submission</a>,
@@ -90636,7 +95216,7 @@
- <h4 id=the-title-attribute-0><span class=secno>13.7.2 </span>The <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute</h4>
+ <h4 id=the-title-attribute-0><span class=secno>15.7.2 </span>The <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute</h4>
<p>Given an element (e.g. the element designated by the mouse
cursor), if the element, or one of its ancestors, has a <code title=attr-title><a href=#the-title-attribute>title</a></code> attribute, and the nearest such
@@ -90674,7 +95254,7 @@
</div>
- <h4 id=editing-hosts><span class=secno>13.7.3 </span>Editing hosts</h4>
+ <h4 id=editing-hosts><span class=secno>15.7.3 </span>Editing hosts</h4>
<p>The current text editing caret (i.e. the <a href=#active-range>active
range</a>, if it is empty and in an <a href=#editing-host>editing host</a>),
@@ -90688,7 +95268,7 @@
- <h4 id=text-rendered-in-native-user-interfaces><span class=secno>13.7.4 </span>Text rendered in native user interfaces</h4>
+ <h4 id=text-rendered-in-native-user-interfaces><span class=secno>15.7.4 </span>Text rendered in native user interfaces</h4>
<p>User agents are expected to honor the Unicode semantics of text
that is exposed in user interfaces, for example supporting the
@@ -90784,7 +95364,7 @@
- <h3 id=print-media><span class=secno>13.8 </span>Print media</h3>
+ <h3 id=print-media><span class=secno>15.8 </span>Print media</h3>
<p>User agents are expected to allow the user to request the
opportunity to <dfn id=obtain-a-physical-form>obtain a physical form</dfn> (or a
@@ -90804,9 +95384,9 @@
- <h2 id=obsolete><span class=secno>14 </span>Obsolete features</h2>
+ <h2 id=obsolete><span class=secno>16 </span>Obsolete features</h2>
- <h3 id=obsolete-but-conforming-features><span class=secno>14.1 </span>Obsolete but conforming features</h3>
+ <h3 id=obsolete-but-conforming-features><span class=secno>16.1 </span>Obsolete but conforming features</h3>
<p>Features listed in this section will trigger warnings in
conformance checkers.</p>
@@ -90855,7 +95435,7 @@
<div class=impl>
- <h4 id=warnings-for-obsolete-but-conforming-features><span class=secno>14.1.1 </span>Warnings for obsolete but conforming features</h4>
+ <h4 id=warnings-for-obsolete-but-conforming-features><span class=secno>16.1.1 </span>Warnings for obsolete but conforming features</h4>
<p>To ease the transition from HTML4 Transitional documents to the
language defined in <em>this</em> specification, and to discourage
@@ -90903,7 +95483,7 @@
</div>
- <h3 id=non-conforming-features><span class=secno>14.2 </span>Non-conforming features</h3>
+ <h3 id=non-conforming-features><span class=secno>16.2 </span>Non-conforming features</h3>
<p>Elements in the following list are entirely obsolete, and must
not be used by authors:</p>
@@ -91195,9 +95775,9 @@
<div class=impl>
- <h3 id=requirements-for-implementations><span class=secno>14.3 </span>Requirements for implementations</h3>
+ <h3 id=requirements-for-implementations><span class=secno>16.3 </span>Requirements for implementations</h3>
- <h4 id=the-applet-element><span class=secno>14.3.1 </span>The <dfn><code>applet</code></dfn> element</h4>
+ <h4 id=the-applet-element><span class=secno>16.3.1 </span>The <dfn><code>applet</code></dfn> element</h4>
<p>The <code><a href=#the-applet-element>applet</a></code> element is a Java-specific variant of the
<code><a href=#the-embed-element>embed</a></code> element. The <code><a href=#the-applet-element>applet</a></code> element is now
@@ -91277,7 +95857,7 @@
<a href=#url>URL</a>.</p>
- <h4 id=the-marquee-element><span class=secno>14.3.2 </span>The <dfn><code>marquee</code></dfn> element</h4>
+ <h4 id=the-marquee-element><span class=secno>16.3.2 </span>The <dfn><code>marquee</code></dfn> element</h4>
<p>The <code><a href=#the-marquee-element>marquee</a></code> element is a presentational element that
animates content. CSS transitions and animations are a more
@@ -91454,7 +96034,7 @@
attribute.</p>
- <h4 id=frames><span class=secno>14.3.3 </span>Frames</h4>
+ <h4 id=frames><span class=secno>16.3.3 </span>Frames</h4>
<p>The <dfn id=frameset><code>frameset</code></dfn> element acts as <a href=#the-body-element-0>the
body element</a> in documents that use frames.</p>
@@ -91630,7 +96210,7 @@
- <h4 id=other-elements,-attributes-and-apis><span class=secno>14.3.4 </span>Other elements, attributes and APIs</h4> <!-- alphabetical by name and attribute -->
+ <h4 id=other-elements,-attributes-and-apis><span class=secno>16.3.4 </span>Other elements, attributes and APIs</h4> <!-- alphabetical by name and attribute -->
<p>User agents must treat <code><a href=#acronym>acronym</a></code> elements in a manner
equivalent to <code><a href=#the-abbr-element>abbr</a></code> elements in terms of semantics and
@@ -92323,13 +96903,13 @@
- <h2 id=iana><span class=secno>15 </span>IANA considerations</h2>
+ <h2 id=iana><span class=secno>17 </span>IANA considerations</h2>
<!-- http://www.w3.org/2002/06/registering-mediatype.html -->
- <h3 id=text/html><span class=secno>15.1 </span><dfn><code>text/html</code></dfn></h3>
+ <h3 id=text/html><span class=secno>17.1 </span><dfn><code>text/html</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -92459,7 +97039,7 @@
provide state information for in-page scripts.</p>
- <h3 id=text/html-sandboxed><span class=secno>15.2 </span><dfn><code>text/html-sandboxed</code></dfn></h3>
+ <h3 id=text/html-sandboxed><span class=secno>17.2 </span><dfn><code>text/html-sandboxed</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -92542,7 +97122,7 @@
scripts.</p>
- <h3 id=multipart/x-mixed-replace><span class=secno>15.3 </span><dfn><code>multipart/x-mixed-replace</code></dfn></h3>
+ <h3 id=multipart/x-mixed-replace><span class=secno>17.3 </span><dfn><code>multipart/x-mixed-replace</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -92607,7 +97187,7 @@
part as defined by the type used by that body part.</p>
- <h3 id=application/xhtml+xml><span class=secno>15.4 </span><dfn><code>application/xhtml+xml</code></dfn></h3>
+ <h3 id=application/xhtml+xml><span class=secno>17.4 </span><dfn><code>application/xhtml+xml</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -92672,7 +97252,7 @@
type</a>. <a href=#refsRFC3023>[RFC3023]</a></p>
- <h3 id=application/x-www-form-urlencoded><span class=secno>15.5 </span><dfn><code>application/x-www-form-urlencoded</code></dfn></h3>
+ <h3 id=application/x-www-form-urlencoded><span class=secno>17.5 </span><dfn><code>application/x-www-form-urlencoded</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -92739,7 +97319,7 @@
identifiers.</p>
- <h3 id=text/cache-manifest><span class=secno>15.6 </span><dfn><code>text/cache-manifest</code></dfn></h3>
+ <h3 id=text/cache-manifest><span class=secno>17.6 </span><dfn><code>text/cache-manifest</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -92810,7 +97390,7 @@
<!--PING-->
- <h3 id=text/ping><span class=secno>15.7 </span><dfn><code>text/ping</code></dfn></h3>
+ <h3 id=text/ping><span class=secno>17.7 </span><dfn><code>text/ping</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -92875,7 +97455,7 @@
<!--TTVTT-->
<div data-component="other Hixie drafts (editor: Ian Hickson)">
- <h3 id=text/vtt><span class=secno>15.8 </span><dfn><code>text/vtt</code></dfn></h3>
+ <h3 id=text/vtt><span class=secno>17.8 </span><dfn><code>text/vtt</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -92956,7 +97536,7 @@
<!--MD-->
- <h3 id=application/microdata+json><span class=secno>15.9 </span><dfn><code>application/microdata+json</code></dfn></h3>
+ <h3 id=application/microdata+json><span class=secno>17.9 </span><dfn><code>application/microdata+json</code></dfn></h3>
<p>This registration is for community review and will be submitted
@@ -93028,7 +97608,7 @@
<!--PEERCONNECTION-->
- <h3 id=application/html-peer-connection-data><span class=secno>15.10 </span><dfn><code>application/html-peer-connection-data</code></dfn></h3>
+ <h3 id=application/html-peer-connection-data><span class=secno>17.10 </span><dfn><code>application/html-peer-connection-data</code></dfn></h3>
<p>This registration is for community review and will be submitted
to the IESG for review, approval, and registration with IANA.</p>
@@ -93109,7 +97689,7 @@
<!--PING-->
- <h3 id=ping-from><span class=secno>15.11 </span><dfn title=http-ping-from><code>Ping-From</code></dfn></h3>
+ <h3 id=ping-from><span class=secno>17.11 </span><dfn title=http-ping-from><code>Ping-From</code></dfn></h3>
<p>This section describes a header field for registration in the
Permanent Message Header Field Registry. <a href=#refsRFC3864>[RFC3864]</a></p>
@@ -93128,7 +97708,7 @@
</dd>
<dt>Related information</dt>
<dd>None.</dd>
- </dl><h3 id=ping-to><span class=secno>15.12 </span><dfn title=http-ping-to><code>Ping-To</code></dfn></h3>
+ </dl><h3 id=ping-to><span class=secno>17.12 </span><dfn title=http-ping-to><code>Ping-To</code></dfn></h3>
<p>This section describes a header field for registration in the
Permanent Message Header Field Registry. <a href=#refsRFC3864>[RFC3864]</a></p>
@@ -93147,7 +97727,7 @@
</dd>
<dt>Related information</dt>
<dd>None.</dd>
- </dl><!--PING--><h3 id=web+-scheme-prefix><span class=secno>15.13 </span><dfn title=scheme-web><code>web+</code> scheme prefix</dfn></h3>
+ </dl><!--PING--><h3 id=web+-scheme-prefix><span class=secno>17.13 </span><dfn title=scheme-web><code>web+</code> scheme prefix</dfn></h3>
<p>This section describes a convention for use with the IANA URI
scheme registry. It does not itself register a specific scheme. <a href=#refsRFC4395>[RFC4395]</a></p>
@@ -93523,7 +98103,7 @@
<td>Legend for corresponding <code><a href=#the-dd-element>dd</a></code> element(s)</td>
<td>none</td>
<td><code><a href=#the-dl-element>dl</a></code></td>
- <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
+ <td><a href=#flow-content title="Flow content">flow</a>*</td>
<td><a href=#global-attributes title="global attributes">globals</a></td>
<td><code><a href=#htmlelement>HTMLElement</a></code></td>
<tr><th><code><a href=#the-em-element>em</a></code></th>
@@ -94228,7 +98808,7 @@
<td>Table header cell</td>
<td>none</td>
<td><code><a href=#the-tr-element>tr</a></code></td>
- <td><a href=#phrasing-content title="Phrasing content">phrasing</a></td>
+ <td><a href=#flow-content title="Flow content">flow</a>*</td>
<td><a href=#global-attributes title="global attributes">globals</a>;
<code title=attr-tdth-colspan><a href=#attr-tdth-colspan>colspan</a></code>;
<code title=attr-tdth-rowspan><a href=#attr-tdth-rowspan>rowspan</a></code>;
@@ -95691,7 +100271,7 @@
<tr><th id=ix-handler-window-onstorage> <code title="">onstorage</code>
<td> <code title=handler-window-onstorage><a href=#handler-window-onstorage>body</a></code>
- <td> <code title=event-storage>storage</code> event handler for <code><a href=#window>Window</a></code> object
+ <td> <code title=event-storage><a href=#event-storage>storage</a></code> event handler for <code><a href=#window>Window</a></code> object
<td> <a href=#event-handler-content-attributes title="event handler content attributes">Event handler content attribute</a>
<tr><th id=ix-handler-onsubmit> <code title="">onsubmit</code>
@@ -96082,133 +100662,8 @@
<tr><td> <code><a href=#the-wbr-element>wbr</a></code>
<td> <code><a href=#htmlelement>HTMLElement</a></code>
- </table><!-- (only has events from HTML5) --><h3 class=no-num id=events-0>Events</h3>
+ </table><h2 class=no-num id=references>References</h2><!--REFS-->
- <p><i>This section is non-normative.</i></p>
-
- <table><caption>List of events</caption>
- <thead><tr><th> Event
- <th> Interface
- <th> Description
- <tbody><tr><td> <code title=event-DOMContentLoaded>DOMContentLoaded</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#document>Document</a></code> once it and its scripts have loaded, without waiting for other subresources
-
- <tr><td> <code title=event-abort>abort</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the download was aborted by the user
-
- <tr><td> <code title=event-afterprint>afterprint</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> after printing
-
- <tr><td> <code title=event-beforeprint>beforeprint</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> before printing
-
- <tr><td> <code title=event-beforeunload>beforeunload</code>
- <td> <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the page is about to be unloaded, in case the page would like to show a warning prompt
-
- <tr><td> <code title=event-blur>blur</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at nodes losing focus
-
- <tr><td> <code title=event-change>change</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at controls when the user commits a value change
-
- <tr><td> <code title=event-click><a href=#event-click>click</a></code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at an element before its <a href=#activation-behavior>activation behavior</a> is run
-
- <tr><td> <code title=event-contextmenu>contextmenu</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at elements when the user requests their context menu
-
- <tr><td> <code title=event-DOMContentLoaded>DOMContentLoaded</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#document>Document</a></code> once the parser has finished
-
- <tr><td> <code title=event-error>error</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at elements when network and script errors occur
-
- <tr><td> <code title=event-focus>focus</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at nodes gaining focus
-
- <tr><td> <code title=event-hashchange><a href=#event-hashchange>hashchange</a></code>
- <td> <code><a href=#hashchangeevent>HashChangeEvent</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the fragment identifier part of <a href="#the-document's-current-address">the document's current address</a> changes
-
- <tr><td> <code title=event-input>input</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at controls when the user changes the value
-
- <tr><td> <code title=event-invalid>invalid</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at controls during form validation if they do not satisfy their constraints
-
- <tr><td> <code title=event-load>load</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the document has finished loading; fired at an element containing a resource (e.g. <code><a href=#the-img-element>img</a></code>, <code><a href=#the-embed-element>embed</a></code>) when its resource has finished loading
-
- <tr><td> <code title=event-message><a href=#event-message>message</a></code>
- <td> <code><a href=#messageevent>MessageEvent</a></code>
- <td> Fired at an object when the object receives a message
-
- <tr><td> <code title=event-offline><a href=#event-offline>offline</a></code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the network connections fails
-
- <tr><td> <code title=event-online><a href=#event-online>online</a></code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the network connections returns
-
- <tr><td> <code title=event-pagehide><a href=#event-pagehide>pagehide</a></code>
- <td> <code><a href=#pagetransitionevent>PageTransitionEvent</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the page's entry in the <a href=#session-history>session history</a> stops being the <a href=#current-entry>current entry</a>
-
- <tr><td> <code title=event-pageshow><a href=#event-pageshow>pageshow</a></code>
- <td> <code><a href=#pagetransitionevent>PageTransitionEvent</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the page's entry in the <a href=#session-history>session history</a> becomes the <a href=#current-entry>current entry</a>
-
- <tr><td> <code title=event-popstate><a href=#event-popstate>popstate</a></code>
- <td> <code><a href=#popstateevent>PopStateEvent</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> when the user navigates the <a href=#session-history>session history</a>
-
- <tr><td> <code title=event-readystatechange><a href=#event-readystatechange>readystatechange</a></code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#document>Document</a></code> when it finishes parsing and again when all its subresources have finished loading
-
- <tr><td> <code title=event-reset>reset</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at a <code><a href=#the-form-element>form</a></code> element when it is <a href=#concept-form-reset title=concept-form-reset>reset</a>
-
- <tr><td> <code title=event-show>show</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at a <code><a href=#the-menu-element>menu</a></code> element when it is shown as a context menu
-
- <tr><td> <code title=event-submit>submit</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at a <code><a href=#the-form-element>form</a></code> element when it is <a href=#concept-form-submit title=concept-form-submit>submitted</a>
-
- <tr><td> <code title=event-unload>unload</code>
- <td> <code><a href=#event>Event</a></code>
- <td> Fired at the <code><a href=#window>Window</a></code> object when the page is going away
-
- </table><p class=note>See also <a href=#mediaevents>media element
- events</a>, <a href=#mediasteamevents><code>MediaStream</code> and
- <code>PeerConnection</code> events</a>, <a href=#appcacheevents>application cache events</a>, and <a href=#dndevents>drag-and-drop events</a>.</p>
-
-
-
-
-
-
- <h2 class=no-num id=references>References</h2><!--REFS-->
-
<p>All references are normative unless marked "Non-normative".</p>
<!-- Dates are only included for standards older than the Web, because the newer ones keep changing. -->
@@ -96393,14 +100848,6 @@
<dt id=refsEUCJP>[EUCJP]</dt>
<dd><cite>Definition and Notes of Japanese EUC</cite>. UI-OSF-USLP. In English in the abridged translation of the <a href=http://home.m05.itscom.net/numa/uocjleE.pdf>UI-OSF Application Platform Profile for Japanese Environment</a>, Appendix C.</dd>
- <dt id=refsEVENTSOURCE>[EVENTSOURCE]</dt>
- <!--
- <dd><cite><a href="http://www.w3.org/TR/eventsource/">Server-Sent
- Events</a></cite>, I. Hickson. W3C.</dd>
- -->
- <dd><cite><a href=http://dev.w3.org/html5/eventsource/>Server-Sent
- Events</a></cite>, I. Hickson. W3C.</dd>
-
<dt id=refsFILEAPI>[FILEAPI]</dt>
<dd><cite><a href=http://dev.w3.org/2006/webapi/FileUpload/publish/FileAPI.html>File
API</a></cite>, A. Ranganathan. W3C.</dd>
@@ -96830,27 +101277,6 @@
<dd><cite><a href=http://tools.ietf.org/html/rfc5988>Web
Linking</a></cite>, M. Nottingham. IETF.</dd>
- <dt id=refsWEBSOCKET>[WEBSOCKET]</dt>
- <!--
- <dd><cite><a href="http://www.w3.org/TR/websockets/">The WebSocket
- API</a></cite>, I. Hickson. W3C.</dd>
- -->
- <dd><cite><a href=http://dev.w3.org/html5/websockets/>The WebSocket
- API</a></cite>, I. Hickson. W3C.</dd>
-
- <dt id=refsWEBSTORAGE>[WEBSTORAGE]</dt>
- <dd><cite><a href=http://dev.w3.org/html5/webstorage/>Web
- Storage</a></cite>, I. Hickson. W3C.</dd>
-
- <dt id=refsWEBWORKERS>[WEBWORKERS]</dt>
- <!--
- <dd><cite><a
- href="http://www.w3.org/TR/webworkers/">Workers</a></cite>,
- I. Hickson. W3C.</dd>
- -->
- <dd><cite><a href=http://dev.w3.org/html5/workers/>Web
- Workers</a></cite>, I. Hickson. W3C.</dd>
-
<dt id=refsWHATWGWIKI>[WHATWGWIKI]</dt>
<dd><cite><a href=http://wiki.whatwg.org/>The WHATWG Wiki</a></cite>. WHATWG.</dd>
@@ -96869,6 +101295,10 @@
<dt id=refsWIN949>[WIN949]</dt>
<dd><cite><a href=http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP949.TXT>Windows Codepage 949</a></cite>. Microsoft.</dd>
+ <dt id=refsWSP>[WSP]</dt>
+ <dd><cite><a href=http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol>The
+ WebSocket protocol</a></cite>, I. Fette. IETF.</dd>
+
<dt id=refsX121>[X121]</dt>
<dd><cite>Recommendation X.121 — International Numbering Plan for
Public Data Networks</cite>, CCITT Blue Book, Fascicle VIII.3,
@@ -96915,8 +101345,6 @@
<dd>(Non-normative) <cite><a href=""></a></cite>, . .</dd>
-->
-
-
</dl><h2 class=no-num id=acknowledgements>Acknowledgements</h2> <!-- ACKS -->
<p>Thanks to Tim Berners-Lee for inventing HTML, without which none
@@ -97539,7 +101967,16 @@
<p>Thanks to the many sources that provided inspiration for the
examples used in the specification.</p>
+
+ <div itemscope="" itemtype=http://n.whatwg.org/work>
+ <p>The abstract is based on <a href=http://www.flickr.com/photos/wonderlane/2986252088/ itemprop=work>a photo</a>
+ by <a href=http://www.flickr.com/photos/wonderlane/ itemprop=http://creativecommons.org/ns#attributionURL>Wonderlane</a>.
+ (<a href=http://creativecommons.org/licenses/by/2.0/ itemprop=license>CC BY 2.0</a>)
+ </div>
+
+
+
<p>Thanks also to the Microsoft blogging community for some ideas,
to the attendees of the W3C Workshop on Web Applications and
Compound Documents for inspiration, to the #mrt crew, the #mrt.no
Modified: source
===================================================================
--- source 2011-10-04 15:43:21 UTC (rev 6618)
+++ source 2011-10-04 16:57:57 UTC (rev 6619)
@@ -72,7 +72,7 @@
<p>The WHATWG work is all published in one specification
<!--END complete--><!--END epub-->
- (known as "<a href="http://www.whatwg.org/specs/web-apps/current-work/complete/">Web Applications 1.0</a>"),
+ (known as "<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">HTML</a>"),
<!--END html--><!--END dev-html-->
<!--START complete--><!--START epub-->
(the one you are reading right now),
@@ -82,19 +82,19 @@
including an edition optimized for Web developers
<!--END complete--><!--END epub--><!--END html-->
- (which you are reading right now),
+ (which you are reading right now).
<!--END dev-html-->
<!--START complete--><!--START epub--><!--START html-->
- (known as <a href="http://developers.whatwg.org/">HTML5</a>),
+ (known as <a href="http://developers.whatwg.org/">HTML5</a>).
<!--START dev-html-->
- and one which focuses mainly on the core HTML language
+ <!-- and one which focuses mainly on the core HTML language -->
<!--END complete--><!--END epub--><!--END dev-html-->
- (which you are reading right now).
+ <!-- (which you are reading right now). -->
<!--END html-->
<!--START complete--><!--START epub--><!--START dev-html-->
- (known as the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">HTML Living Standard</a>).
+ <!-- (known as the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">HTML Living Standard</a>). -->
<!--START html-->
In addition, two subparts of the specification are republished as
@@ -110,11 +110,14 @@
<!--END complete--><!--END epub--><!--END dev-html-->
this specification (the HTML Living Standard).
<!--END html-->
-<!--START complete--><!--START epub--><!--START dev-html-->
+<!--START complete--><!--START epub-->
+ this specification (the HTML Living Standard).
+<!--END complete--><!--END epub-->
+<!--START dev-html-->
the <a
href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">HTML
Living Standard</a>.
-<!--START html-->
+<!--START html--><!--START complete--><!--START epub-->
</p>
@@ -132,6 +135,7 @@
a whole reach a more mature state.</p>
-->
+
<h6 class="no-toc">How do the WHATWG and W3C specifications differ?</h6>
<p>The features present in both the WHATWG and W3C specifications
@@ -471,8 +475,8 @@
<!--START complete--><!--START epub--><!--START html--><!--START dev-html--><!--w3c-html--><!--VERSION-->
<p>A separate document has been published by the W3C HTML working
- group to document the differences between this specification and the
- language described in the HTML4 specification. <a
+ group to document the differences between the HTML specified in this
+ document and the language described in the HTML4 specification. <a
href="#refsHTMLDIFF">[HTMLDIFF]</a></p>
More information about the Commit-Watchers
mailing list