[html5] r1037 - /

whatwg at whatwg.org whatwg at whatwg.org
Mon Oct 8 12:28:53 PDT 2007


Author: ianh
Date: 2007-10-08 12:28:51 -0700 (Mon, 08 Oct 2007)
New Revision: 1037

Modified:
   index
   source
Log:
[] (0) * Add comment regarding the imperative voice used in algorithms.
* Removed references to RFC2732.
* Fixed references to <hostname> (changed to <host>, mentioned <ihost> where appropriate).
* Add note saying we need to handle IP addresses in definition of origin.
* Added section 'Unscripted same-origin checks'.
* Moved the 'Offline Web applications' section (and renamed it 'Browser state').
* Added section 'Offline Web applications' for offline application caches.
* Made surgical changes to the history traversal to mention offline application caches.
* Made surgical changes to the navigation to mention offline application caches.
* Made surgical changes to the parser to mention offline application caches.
* Fixed cross-references to 'accessible' in the storage section.
* Defined '<hostport>' which the RFCs had dropped on the floor.
* Fixed typos, added XXX notes to the editor, made certain IDs more consistent.

Modified: index
===================================================================
--- index	2007-09-25 09:54:15 UTC (rev 1036)
+++ index	2007-10-08 19:28:51 UTC (rev 1037)
@@ -22,8 +22,7 @@
 
    <h1 id=html-5>HTML 5</h1>
 
-   <h2 class="no-num no-toc" id=working>Working Draft — 25 September
-    2007</h2>
+   <h2 class="no-num no-toc" id=working>Working Draft — 8 October 2007</h2>
 
    <p>You can take part in this work. <a
     href="http://www.whatwg.org/mailing-list">Join the working group's
@@ -987,24 +986,27 @@
 
        <li><a href="#origin"><span class=secno>4.3.2. </span>Origin</a>
 
-       <li><a href="#security2"><span class=secno>4.3.3. </span>Security
+       <li><a href="#unscripted"><span class=secno>4.3.3. </span>Unscripted
+        same-origin checks</a>
+
+       <li><a href="#security2"><span class=secno>4.3.4. </span>Security
         exceptions</a>
 
-       <li><a href="#javascript-protocol"><span class=secno>4.3.4. </span>The
+       <li><a href="#javascript-protocol"><span class=secno>4.3.5. </span>The
         <code title="">javascript:</code> protocol</a>
 
-       <li><a href="#events"><span class=secno>4.3.5. </span>Events</a>
+       <li><a href="#events"><span class=secno>4.3.6. </span>Events</a>
         <ul class=toc>
-         <li><a href="#event-handler-attributes"><span class=secno>4.3.5.1.
+         <li><a href="#event-handler-attributes"><span class=secno>4.3.6.1.
           </span>Event handler attributes</a>
 
-         <li><a href="#event"><span class=secno>4.3.5.2. </span>Event
+         <li><a href="#event"><span class=secno>4.3.6.2. </span>Event
           firing</a>
 
-         <li><a href="#events0"><span class=secno>4.3.5.3. </span>Events and
+         <li><a href="#events0"><span class=secno>4.3.6.3. </span>Events and
           the <code>Window</code> object</a>
 
-         <li><a href="#runtime-script-errors"><span class=secno>4.3.5.4.
+         <li><a href="#runtime-script-errors"><span class=secno>4.3.6.4.
           </span>Runtime script errors</a>
         </ul>
       </ul>
@@ -1014,279 +1016,311 @@
 
      <li><a href="#browser"><span class=secno>4.5. </span>Browser state</a>
       <ul class=toc>
-       <li><a href="#offline"><span class=secno>4.5.1. </span>Offline Web
-        applications</a>
-
-       <li><a href="#custom-handlers"><span class=secno>4.5.2. </span>Custom
+       <li><a href="#custom-handlers"><span class=secno>4.5.1. </span>Custom
         protocol and content handlers</a>
         <ul class=toc>
-         <li><a href="#security3"><span class=secno>4.5.2.1. </span>Security
+         <li><a href="#security3"><span class=secno>4.5.1.1. </span>Security
           and privacy</a>
 
-         <li><a href="#sample-handler-impl"><span class=secno>4.5.2.2.
+         <li><a href="#sample-handler-impl"><span class=secno>4.5.1.2.
           </span>Sample user interface</a>
         </ul>
       </ul>
 
-     <li><a href="#history"><span class=secno>4.6. </span>Session history and
+     <li><a href="#offline"><span class=secno>4.6. </span>Offline Web
+      applications</a>
+      <ul class=toc>
+       <li><a href="#introduction1"><span class=secno>4.6.1.
+        </span>Introduction</a>
+
+       <li><a href="#appcache"><span class=secno>4.6.2. </span>Application
+        caches</a>
+
+       <li><a href="#manifests"><span class=secno>4.6.3. </span>The cache
+        manifest syntax</a>
+        <ul class=toc>
+         <li><a href="#writing"><span class=secno>4.6.3.1. </span>Writing
+          cache manifests</a>
+
+         <li><a href="#parsing0"><span class=secno>4.6.3.2. </span>Parsing
+          cache manifests</a>
+        </ul>
+
+       <li><a href="#updating1"><span class=secno>4.6.4. </span>Updating an
+        application cache</a>
+
+       <li><a href="#processing2"><span class=secno>4.6.5. </span>Processing
+        model</a>
+        <ul class=toc>
+         <li><a href="#changes"><span class=secno>4.6.5.1. </span>Changes to
+          the networking model</a>
+        </ul>
+
+       <li><a href="#application"><span class=secno>4.6.6. </span>Application
+        cache API</a>
+
+       <li><a href="#browser0"><span class=secno>4.6.7. </span>Browser
+        state</a>
+      </ul>
+
+     <li><a href="#history"><span class=secno>4.7. </span>Session history and
       navigation</a>
       <ul class=toc>
-       <li><a href="#the-session"><span class=secno>4.6.1. </span>The session
+       <li><a href="#the-session"><span class=secno>4.7.1. </span>The session
         history of browsing contexts</a>
 
-       <li><a href="#the-history"><span class=secno>4.6.2. </span>The
+       <li><a href="#the-history"><span class=secno>4.7.2. </span>The
         <code>History</code> interface</a>
 
-       <li><a href="#activating"><span class=secno>4.6.3. </span>Activating
+       <li><a href="#activating"><span class=secno>4.7.3. </span>Activating
         state objects</a>
 
-       <li><a href="#the-location"><span class=secno>4.6.4. </span>The
+       <li><a href="#the-location"><span class=secno>4.7.4. </span>The
         <code>Location</code> interface</a>
         <ul class=toc>
-         <li><a href="#security4"><span class=secno>4.6.4.1.
+         <li><a href="#security4"><span class=secno>4.7.4.1.
           </span>Security</a>
         </ul>
 
-       <li><a href="#history-notes"><span class=secno>4.6.5.
+       <li><a href="#history-notes"><span class=secno>4.7.5.
         </span>Implementation notes for session history</a>
       </ul>
 
-     <li><a href="#navigating"><span class=secno>4.7. </span>Navigating
+     <li><a href="#navigating"><span class=secno>4.8. </span>Navigating
       across documents</a>
       <ul class=toc>
-       <li><a href="#read-html"><span class=secno>4.7.1. </span>Page load
+       <li><a href="#read-html"><span class=secno>4.8.1. </span>Page load
         processing model for HTML files</a>
 
-       <li><a href="#read-xml"><span class=secno>4.7.2. </span>Page load
+       <li><a href="#read-xml"><span class=secno>4.8.2. </span>Page load
         processing model for XML files</a>
 
-       <li><a href="#read-text"><span class=secno>4.7.3. </span>Page load
+       <li><a href="#read-text"><span class=secno>4.8.3. </span>Page load
         processing model for text files</a>
 
-       <li><a href="#read-image"><span class=secno>4.7.4. </span>Page load
+       <li><a href="#read-image"><span class=secno>4.8.4. </span>Page load
         processing model for images</a>
 
-       <li><a href="#read-plugin"><span class=secno>4.7.5. </span>Page load
+       <li><a href="#read-plugin"><span class=secno>4.8.5. </span>Page load
         processing model for content that uses plugins</a>
 
-       <li><a href="#non-DOM-inline-content"><span class=secno>4.7.6.
-        </span>Page load processing model for inline content that doesn't
-        have a DOM</a>
+       <li><a href="#read-ua-inline"><span class=secno>4.8.6. </span>Page
+        load processing model for inline content that doesn't have a DOM</a>
 
-       <li><a href="#scroll-to-fragid"><span class=secno>4.7.7.
+       <li><a href="#scroll-to-fragid"><span class=secno>4.8.7.
         </span>Scrolling to a fragment identifier</a>
       </ul>
 
-     <li><a href="#content-type-sniffing"><span class=secno>4.8.
+     <li><a href="#content-type-sniffing"><span class=secno>4.9.
       </span>Determining the type of a new resource in a browsing context</a>
       
       <ul class=toc>
-       <li><a href="#content-type0"><span class=secno>4.8.1.
+       <li><a href="#content-type0"><span class=secno>4.9.1.
         </span>Content-Type sniffing: text or binary</a>
 
-       <li><a href="#content-type1"><span class=secno>4.8.2.
+       <li><a href="#content-type1"><span class=secno>4.9.2.
         </span>Content-Type sniffing: unknown type</a>
 
-       <li><a href="#content-type2"><span class=secno>4.8.3.
+       <li><a href="#content-type2"><span class=secno>4.9.3.
         </span>Content-Type sniffing: image</a>
 
-       <li><a href="#content-type3"><span class=secno>4.8.4.
+       <li><a href="#content-type3"><span class=secno>4.9.4.
         </span>Content-Type sniffing: feed or HTML</a>
 
-       <li><a href="#content-type"><span class=secno>4.8.5.
+       <li><a href="#content-type"><span class=secno>4.9.5.
         </span>Content-Type metadata</a>
       </ul>
 
-     <li><a href="#storage"><span class=secno>4.9. </span>Client-side session
-      and persistent storage of name/value pairs</a>
+     <li><a href="#storage"><span class=secno>4.10. </span>Client-side
+      session and persistent storage of name/value pairs</a>
       <ul class=toc>
-       <li><a href="#introduction1"><span class=secno>4.9.1.
+       <li><a href="#introduction2"><span class=secno>4.10.1.
         </span>Introduction</a>
 
-       <li><a href="#the-storage"><span class=secno>4.9.2. </span>The
+       <li><a href="#the-storage"><span class=secno>4.10.2. </span>The
         <code>Storage</code> interface</a>
 
-       <li><a href="#the-storageitem"><span class=secno>4.9.3. </span>The
+       <li><a href="#the-storageitem"><span class=secno>4.10.3. </span>The
         <code>StorageItem</code> interface</a>
 
-       <li><a href="#the-sessionstorage"><span class=secno>4.9.4. </span>The
+       <li><a href="#the-sessionstorage"><span class=secno>4.10.4. </span>The
         <code title=dom-sessionStorage>sessionStorage</code> attribute</a>
 
-       <li><a href="#the-globalstorage"><span class=secno>4.9.5. </span>The
+       <li><a href="#the-globalstorage"><span class=secno>4.10.5. </span>The
         <code title=dom-globalStorage>globalStorage</code> attribute</a>
 
-       <li><a href="#the-storage0"><span class=secno>4.9.6. </span>The <code
+       <li><a href="#the-storage0"><span class=secno>4.10.6. </span>The <code
         title=event-storage>storage</code> event</a>
 
-       <li><a href="#miscellaneous0"><span class=secno>4.9.7.
+       <li><a href="#miscellaneous0"><span class=secno>4.10.7.
         </span>Miscellaneous implementation requirements for storage
         areas</a>
         <ul class=toc>
-         <li><a href="#disk-space"><span class=secno>4.9.7.1. </span>Disk
+         <li><a href="#disk-space"><span class=secno>4.10.7.1. </span>Disk
           space</a>
 
-         <li><a href="#threads0"><span class=secno>4.9.7.2.
+         <li><a href="#threads0"><span class=secno>4.10.7.2.
           </span>Threads</a>
         </ul>
 
-       <li><a href="#security5"><span class=secno>4.9.8. </span>Security and
+       <li><a href="#security5"><span class=secno>4.10.8. </span>Security and
         privacy</a>
         <ul class=toc>
-         <li><a href="#user-tracking"><span class=secno>4.9.8.1. </span>User
+         <li><a href="#user-tracking"><span class=secno>4.10.8.1. </span>User
           tracking</a>
 
-         <li><a href="#cookie"><span class=secno>4.9.8.2. </span>Cookie
+         <li><a href="#cookie"><span class=secno>4.10.8.2. </span>Cookie
           resurrection</a>
 
-         <li><a href="#integrity"><span class=secno>4.9.8.3. </span>Integrity
-          of "public" storage areas</a>
+         <li><a href="#integrity"><span class=secno>4.10.8.3.
+          </span>Integrity of "public" storage areas</a>
 
-         <li><a href="#cross-protocol"><span class=secno>4.9.8.4.
+         <li><a href="#cross-protocol"><span class=secno>4.10.8.4.
           </span>Cross-protocol and cross-port attacks</a>
 
-         <li><a href="#dns-spoofing"><span class=secno>4.9.8.5. </span>DNS
+         <li><a href="#dns-spoofing"><span class=secno>4.10.8.5. </span>DNS
           spoofing attacks</a>
 
-         <li><a href="#cross-directory"><span class=secno>4.9.8.6.
+         <li><a href="#cross-directory"><span class=secno>4.10.8.6.
           </span>Cross-directory attacks</a>
 
-         <li><a href="#public"><span class=secno>4.9.8.7. </span>Public
+         <li><a href="#public"><span class=secno>4.10.8.7. </span>Public
           storage areas corresponding to hosts</a>
 
-         <li><a href="#storage0"><span class=secno>4.9.8.8. </span>Storage
+         <li><a href="#storage0"><span class=secno>4.10.8.8. </span>Storage
           areas in the face of untrusted higher-level domains that do not
           correspond to public storage areas</a>
 
-         <li><a href="#storage1"><span class=secno>4.9.8.9. </span>Storage
+         <li><a href="#storage1"><span class=secno>4.10.8.9. </span>Storage
           areas in the face of untrusted subdomains</a>
 
-         <li><a href="#implementation"><span class=secno>4.9.8.10.
+         <li><a href="#implementation"><span class=secno>4.10.8.10.
           </span>Implementation risks</a>
         </ul>
       </ul>
 
-     <li><a href="#sql"><span class=secno>4.10. </span>Client-side database
+     <li><a href="#sql"><span class=secno>4.11. </span>Client-side database
       storage</a>
       <ul class=toc>
-       <li><a href="#introduction2"><span class=secno>4.10.1.
+       <li><a href="#introduction3"><span class=secno>4.11.1.
         </span>Introduction</a>
 
-       <li><a href="#databases"><span class=secno>4.10.2.
+       <li><a href="#databases"><span class=secno>4.11.2.
         </span>Databases</a>
 
-       <li><a href="#executing"><span class=secno>4.10.3. </span>Executing
+       <li><a href="#executing"><span class=secno>4.11.3. </span>Executing
         SQL statements</a>
 
-       <li><a href="#database"><span class=secno>4.10.4. </span>Database
+       <li><a href="#database"><span class=secno>4.11.4. </span>Database
         query results</a>
 
-       <li><a href="#privacy"><span class=secno>4.10.5. </span>Privacy</a>
+       <li><a href="#privacy"><span class=secno>4.11.5. </span>Privacy</a>
 
-       <li><a href="#security6"><span class=secno>4.10.6. </span>Security</a>
+       <li><a href="#security6"><span class=secno>4.11.6. </span>Security</a>
         
         <ul class=toc>
-         <li><a href="#user-agents"><span class=secno>4.10.6.1. </span>User
+         <li><a href="#user-agents"><span class=secno>4.11.6.1. </span>User
           agents</a>
 
-         <li><a href="#sql-injection"><span class=secno>4.10.6.2. </span>SQL
+         <li><a href="#sql-injection"><span class=secno>4.11.6.2. </span>SQL
           injection</a>
         </ul>
       </ul>
 
-     <li><a href="#links"><span class=secno>4.11. </span>Links</a>
+     <li><a href="#links"><span class=secno>4.12. </span>Links</a>
       <ul class=toc>
-       <li><a href="#hyperlink"><span class=secno>4.11.1. </span>Hyperlink
+       <li><a href="#hyperlink"><span class=secno>4.12.1. </span>Hyperlink
         elements</a>
 
-       <li><a href="#following"><span class=secno>4.11.2. </span>Following
+       <li><a href="#following"><span class=secno>4.12.2. </span>Following
         hyperlinks</a>
         <ul class=toc>
-         <li><a href="#hyperlink0"><span class=secno>4.11.2.1.
+         <li><a href="#hyperlink0"><span class=secno>4.12.2.1.
           </span>Hyperlink auditing</a>
         </ul>
 
-       <li><a href="#linkTypes"><span class=secno>4.11.3. </span>Link
+       <li><a href="#linkTypes"><span class=secno>4.12.3. </span>Link
         types</a>
         <ul class=toc>
-         <li><a href="#link-type"><span class=secno>4.11.3.1. </span>Link
+         <li><a href="#link-type"><span class=secno>4.12.3.1. </span>Link
           type "<code>alternate</code>"</a>
 
-         <li><a href="#link-type0"><span class=secno>4.11.3.2. </span>Link
+         <li><a href="#link-type0"><span class=secno>4.12.3.2. </span>Link
           type "<code>archives</code>"</a>
 
-         <li><a href="#link-type1"><span class=secno>4.11.3.3. </span>Link
+         <li><a href="#link-type1"><span class=secno>4.12.3.3. </span>Link
           type "<code>author</code>"</a>
 
-         <li><a href="#link-type2"><span class=secno>4.11.3.4. </span>Link
+         <li><a href="#link-type2"><span class=secno>4.12.3.4. </span>Link
           type "<code>bookmark</code>"</a>
 
-         <li><a href="#link-type3"><span class=secno>4.11.3.5. </span>Link
+         <li><a href="#link-type3"><span class=secno>4.12.3.5. </span>Link
           type "<code>contact</code>"</a>
 
-         <li><a href="#link-type4"><span class=secno>4.11.3.6. </span>Link
+         <li><a href="#link-type4"><span class=secno>4.12.3.6. </span>Link
           type "<code>external</code>"</a>
 
-         <li><a href="#link-type5"><span class=secno>4.11.3.7. </span>Link
+         <li><a href="#link-type5"><span class=secno>4.12.3.7. </span>Link
           type "<code>feed</code>"</a>
 
-         <li><a href="#link-type6"><span class=secno>4.11.3.8. </span>Link
+         <li><a href="#link-type6"><span class=secno>4.12.3.8. </span>Link
           type "<code>help</code>"</a>
 
-         <li><a href="#link-type7"><span class=secno>4.11.3.9. </span>Link
+         <li><a href="#link-type7"><span class=secno>4.12.3.9. </span>Link
           type "<code>icon</code>"</a>
 
-         <li><a href="#link-type8"><span class=secno>4.11.3.10. </span>Link
+         <li><a href="#link-type8"><span class=secno>4.12.3.10. </span>Link
           type "<code>license</code>"</a>
 
-         <li><a href="#link-type9"><span class=secno>4.11.3.11. </span>Link
+         <li><a href="#link-type9"><span class=secno>4.12.3.11. </span>Link
           type "<code>nofollow</code>"</a>
 
-         <li><a href="#link-type10"><span class=secno>4.11.3.12. </span>Link
+         <li><a href="#link-type10"><span class=secno>4.12.3.12. </span>Link
           type "<code>pingback</code>"</a>
 
-         <li><a href="#link-type11"><span class=secno>4.11.3.13. </span>Link
+         <li><a href="#link-type11"><span class=secno>4.12.3.13. </span>Link
           type "<code>prefetch</code>"</a>
 
-         <li><a href="#link-type12"><span class=secno>4.11.3.14. </span>Link
+         <li><a href="#link-type12"><span class=secno>4.12.3.14. </span>Link
           type "<code>search</code>"</a>
 
-         <li><a href="#link-type13"><span class=secno>4.11.3.15. </span>Link
+         <li><a href="#link-type13"><span class=secno>4.12.3.15. </span>Link
           type "<code>stylesheet</code>"</a>
 
-         <li><a href="#link-type14"><span class=secno>4.11.3.16. </span>Link
+         <li><a href="#link-type14"><span class=secno>4.12.3.16. </span>Link
           type "<code>sidebar</code>"</a>
 
-         <li><a href="#link-type15"><span class=secno>4.11.3.17. </span>Link
+         <li><a href="#link-type15"><span class=secno>4.12.3.17. </span>Link
           type "<code>tag</code>"</a>
 
-         <li><a href="#hierarchical"><span class=secno>4.11.3.18.
+         <li><a href="#hierarchical"><span class=secno>4.12.3.18.
           </span>Hierarchical link types</a>
           <ul class=toc>
-           <li><a href="#link-type16"><span class=secno>4.11.3.18.1.
+           <li><a href="#link-type16"><span class=secno>4.12.3.18.1.
             </span>Link type "<code>first</code>"</a>
 
-           <li><a href="#link-type17"><span class=secno>4.11.3.18.2.
+           <li><a href="#link-type17"><span class=secno>4.12.3.18.2.
             </span>Link type "<code>index</code>"</a>
 
-           <li><a href="#link-type18"><span class=secno>4.11.3.18.3.
+           <li><a href="#link-type18"><span class=secno>4.12.3.18.3.
             </span>Link type "<code>last</code>"</a>
 
-           <li><a href="#link-type19"><span class=secno>4.11.3.18.4.
+           <li><a href="#link-type19"><span class=secno>4.12.3.18.4.
             </span>Link type "<code>next</code>"</a>
 
-           <li><a href="#link-type20"><span class=secno>4.11.3.18.5.
+           <li><a href="#link-type20"><span class=secno>4.12.3.18.5.
             </span>Link type "<code>prev</code>"</a>
 
-           <li><a href="#link-type21"><span class=secno>4.11.3.18.6.
+           <li><a href="#link-type21"><span class=secno>4.12.3.18.6.
             </span>Link type "<code>up</code>"</a>
           </ul>
 
-         <li><a href="#other0"><span class=secno>4.11.3.19. </span>Other link
+         <li><a href="#other0"><span class=secno>4.12.3.19. </span>Other link
           types</a>
         </ul>
       </ul>
 
-     <li><a href="#interfaces"><span class=secno>4.12. </span>Interfaces for
+     <li><a href="#interfaces"><span class=secno>4.13. </span>Interfaces for
       URI manipulation</a>
     </ul>
 
@@ -1393,7 +1427,7 @@
        <li><a href="#connecting"><span class=secno>6.2.2. </span>Connecting
         to an event stream</a>
 
-       <li><a href="#parsing0"><span class=secno>6.2.3. </span>Parsing an
+       <li><a href="#parsing1"><span class=secno>6.2.3. </span>Parsing an
         event stream</a>
 
        <li><a href="#event-stream-interpretation"><span class=secno>6.2.4.
@@ -1466,7 +1500,7 @@
      <li><a href="#crossDocumentMessages"><span class=secno>6.4.
       </span>Cross-document messaging</a>
       <ul class=toc>
-       <li><a href="#processing2"><span class=secno>6.4.1. </span>Processing
+       <li><a href="#processing3"><span class=secno>6.4.1. </span>Processing
         model</a>
       </ul>
     </ul>
@@ -1476,7 +1510,7 @@
 
    <li><a href="#syntax"><span class=secno>8. </span>The HTML syntax</a>
     <ul class=toc>
-     <li><a href="#writing"><span class=secno>8.1. </span>Writing HTML
+     <li><a href="#writing0"><span class=secno>8.1. </span>Writing HTML
       documents</a>
       <ul class=toc>
        <li><a href="#the-doctype"><span class=secno>8.1.1. </span>The
@@ -1591,7 +1625,7 @@
      <li><a href="#serialising"><span class=secno>8.4. </span>Serialising
       HTML fragments</a>
 
-     <li><a href="#parsing1"><span class=secno>8.5. </span>Parsing HTML
+     <li><a href="#parsing2"><span class=secno>8.5. </span>Parsing HTML
       fragments</a>
 
      <li><a href="#entities"><span class=secno>8.6. </span>Entities</a>
@@ -1831,6 +1865,11 @@
    letters in this specification. <a href="#refsRFC2119">[RFC2119]</a></p>
   <!-- XXX but they should be marked up -->
 
+  <p>Requirements phrased in the imperative as part of algorithms (such as
+   "strip any leading space characters" or "return false and abort these
+   steps") are to be interpreted with the meaning of the key word ("must",
+   "should", "may", etc) used in introducing the algorithm.
+
   <p>This specification describes the conformance criteria for user agents
    (relevant to implementors) and documents (relevant to authors and
    authoring tool implementors).
@@ -2263,10 +2302,9 @@
 
   <p>For readability, the term URI is used to refer to both ASCII URIs and
    Unicode IRIs, as those terms are defined by RFC 3986 and RFC 3987
-   respectively, and as modified by RFC 2732. On the rare occasions where
-   IRIs are not allowed but ASCII URIs are, this is called out explicitly. <a
-   href="#refsRFC3986">[RFC3986]</a> <a href="#refsRFC3987">[RFC3987]</a> <a
-   href="#refsRFC2732">[RFC2732]</a>
+   respectively. On the rare occasions where IRIs are not allowed but ASCII
+   URIs are, this is called out explicitly. <a
+   href="#refsRFC3986">[RFC3986]</a> <a href="#refsRFC3987">[RFC3987]</a>
 
   <p>The term <dfn id=root-element>root element</dfn>, when not qualified to
    explicitly refer to the document's root element, means the furthest
@@ -2559,8 +2597,8 @@
   <p>If the <code>Document</code> object's <span title="the document's
    address">address</span><!-- XXX xref --> is hierarchical and uses a
    server-based naming authority, then its <dfn id=domain0 title="document's
-   domain">domain</dfn> is the <hostname> part of that address.
-   Otherwise, it has no domain.
+   domain">domain</dfn> is the <host>/<ihost> part of that
+   address. Otherwise, it has no domain.
 
   <p class=note>The <code title=dom-document-domain><a
    href="#domain">domain</a></code> attribute is used to enable pages on
@@ -2568,6 +2606,8 @@
    class=big-issue>, though this is not yet defined by this
    specification</span>.</p>
   <!-- XXX xref -->
+
+  <p class=big-issue>we should handle IP addresses here</p>
   <!--XXX
     http://lxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp
     search for ::GetDomain ::SetDomain
@@ -3741,9 +3781,9 @@
    method must do nothing if there is no <a
    href="#script-created">script-created parser</a> associated with the
    document. If there is such a parser, then, when the method is called, the
-   user agent must insert an <a href="#explicit">explicit "EOF" character</a>
-   at the <a href="#insertion">insertion point</a> of the parser's <a
-   href="#input0">input stream</a>.
+   user agent must insert an <a href="#explicit0">explicit "EOF"
+   character</a> at the <a href="#insertion">insertion point</a> of the
+   parser's <a href="#input0">input stream</a>.
 
   <h4 id=dynamic0><span class=secno>2.5.2. </span>Dynamic markup insertion in
    HTML</h4>
@@ -19751,7 +19791,7 @@
    conforming document with no <code><a href="#noscript">noscript</a></code>
    elements and no <code><a href="#script0">script</a></code> elements, and
    such that no step in the algorithm causes an <a href="#html-0">HTML
-   parser</a> to flag a <a href="#parse">parse error</a>:
+   parser</a> to flag a <a href="#parse0">parse error</a>:
 
   <ol>
    <li>Remove every <code><a href="#script0">script</a></code> element from
@@ -24647,6 +24687,8 @@
   <p>Access to certain APIs is granted or denied to scripts based on the <dfn
    id=origin0>origin</dfn> of the script and the API being accessed.
 
+  <p>The origin of a script depends on the context of that script:
+
   <dl>
    <dt>If a script is in a <code><a href="#script0">script</a></code> element
 
@@ -24703,14 +24745,14 @@
 
   <p>The origin of a <code>Document</code> or image that was served over the
    network and whose address uses a URI scheme with a server-based naming
-   authority is the tuple consisting of the <scheme>, <host>, and
-   <port> parts of the <code>Document</code>'s full URI. <a
-   href="#refsRFC3986">[RFC3986]</a> <a href="#refsRFC3987">[RFC3987]</a> <a
-   href="#refsRFC2732">[RFC2732]</a>
+   authority is the tuple consisting of the <scheme>,
+   <host>/<ihost>, and <port> parts of the
+   <code>Document</code>'s full URI. <a href="#refsRFC3986">[RFC3986]</a> <a
+   href="#refsRFC3987">[RFC3987]</a>
 
   <p>The origin of a <code>Document</code> or image that was generated from a
    <code>data:</code> URI found in another <code>Document</code> or in a
-   script is the origin of the that <code>Document</code> or script.
+   script is the origin of the <code>Document</code> or script.
 
   <p>The origin of a <code>Document</code> or image that was generated from a
    <code>data:</code> URI from another source is a globally unique identifier
@@ -24739,11 +24781,93 @@
    kill multi-homed systems like GMail. Should we do something like have a
    DNS record say whether or not to include the IP in the origin for a host?
 
-  <h4 id=security2><span class=secno>4.3.3. </span>Security exceptions</h4>
+  <h4 id=unscripted><span class=secno>4.3.3. </span>Unscripted same-origin
+   checks</h4>
 
+  <p>When two URIs are to be compared to determine if they have the <dfn
+   id=same-schemehostport>same scheme/host/port</dfn>, it means that the
+   following algorithm must be invoked, where <var title="">uri<sub
+   title="">1</sub></var> and <var title="">uri<sub title="">2</sub></var>
+   are the two URIs.
+
+  <ol>
+   <li>
+    <p>First, both <var title="">uri<sub title="">1</sub></var> and <var
+     title="">uri<sub title="">2</sub></var> must be normalized to obtain the
+     two tuples (<var title="">scheme<sub title="">1</sub></var>, <var
+     title="">host<sub title="">1</sub></var>, <var title="">port<sub
+     title="">1</sub></var>) and (<var title="">scheme<sub
+     title="">2</sub></var>, <var title="">host<sub title="">2</sub></var>,
+     <var title="">port<sub title="">2</sub></var>), by applying the
+     following subalgorithm to each URI:</p>
+
+    <ol>
+     <li>
+      <p>Let <var title="">uri</var> be the URI being normalized.
+
+     <li>
+      <p>Parse <var title="">uri</var> according to the rules described in
+       RFC 3986 and RFC 3987. <a href="#refsRFC3986">[RFC3986]</a> <a
+       href="#refsRFC3987">[RFC3987]</a>
+
+     <li>
+      <p>If <var title="">uri</var> does not use a server-based naming
+       authority, then fail the overall algorithm — the two URIs do not
+       have the same scheme/host/port.
+
+     <li>
+      <p>Let <var title="">scheme</var> be the <scheme> component of
+       the URI. If the UA doesn't support the given protocol, then fail the
+       overall algorithm — the two URIs do not have the same
+       scheme/host/port<!-- (this should not be
+     possible, since this algorithm is only invoked with URIs that
+     have been actually fetched) -->.
+
+     <li>
+      <p>Let <var title="">host</var> be the <host>/<ihost>
+       component of the URI.
+
+     <li>
+      <p>Apply the IDNA ToASCII algorithm to <var title="">host</var>, with
+       both the AllowUnassigned and UseSTD3ASCIIRules flags set. Let <var
+       title="">host</var> be the result of the ToASCII algorithm.</p>
+
+      <p>If ToASCII fails to convert one of the components of the string,
+       e.g. because it is too long or because it contains invalid characters,
+       then fail the overall algorithm — the two URIs do not have the
+       same scheme/host/port. <a href="#refsRFC3490">[RFC3490]</a></p>
+
+     <li>
+      <p>If no port is explicitly listed, then let <var title="">port</var>
+       be the default port for the protocol given by <var
+       title="">scheme</var>. Otherwise, let <var title="">port</var> be the
+       <port> component of the URI.
+
+     <li>
+      <p>Return the tuple (<var title="">scheme</var>, <var
+       title="">host</var>, <var title="">port</var>).
+    </ol>
+
+   <li>
+    <p>If <var title="">scheme<sub title="">1</sub></var> is not
+     case-insensitively<!-- XXX ascii case matching --> identical to <var
+     title="">scheme<sub title="">2</sub></var>, or if <var title="">host<sub
+     title="">1</sub></var> is not
+     case-insensitively<!-- XXX ascii case matching --> identical to <var
+     title="">host<sub title="">2</sub></var>, or if <var title="">port<sub
+     title="">1</sub></var> is not identical to <var title="">port<sub
+     title="">2</sub></var>, then fail the overall algorithm — the two
+     URIs do not have the same scheme/host/port.
+
+   <li>
+    <p>Otherwise, the two URIs do have the same scheme/host/port.
+  </ol>
+
+  <h4 id=security2><span class=secno>4.3.4. </span>Security exceptions</h4>
+
   <p class=big-issue>Define <dfn id=security8>security exception</dfn>.
 
-  <h4 id=javascript-protocol><span class=secno>4.3.4. </span><dfn
+  <h4 id=javascript-protocol><span class=secno>4.3.5. </span><dfn
    id=the-javascript title="javascript protocol">The <code
    title="">javascript:</code> protocol</dfn></h4>
 
@@ -24818,7 +24942,7 @@
     context</a>.</p>
   </div>
 
-  <h4 id=events><span class=secno>4.3.5. </span>Events</h4>
+  <h4 id=events><span class=secno>4.3.6. </span>Events</h4>
 
   <p class=big-issue>We need to define how to handle events that are to be
    fired on a Document that is no longer the active document of its browsing
@@ -24829,7 +24953,7 @@
    element section, which says scripts don't run when the document isn't
    active.
 
-  <h5 id=event-handler-attributes><span class=secno>4.3.5.1. </span>Event
+  <h5 id=event-handler-attributes><span class=secno>4.3.6.1. </span>Event
    handler attributes</h5>
 
   <p><a href="#html-elements">HTML elements</a> can have <dfn id=event1>event
@@ -24885,7 +25009,8 @@
    and DOM attributes, and on <code><a href="#window">Window</a></code>
    objects, as DOM attributes:
 
-  <dl>
+  <dl><!-- XXX should change 'the element' below to 'the object' or something -->
+
    <dt><dfn id=onabort title=handler-onabort><code>onabort</code></dfn>
 
    <dd>
@@ -25216,7 +25341,7 @@
    set to invoke the function associated with the event handler attribute
    otherwise.
 
-  <h5 id=event><span class=secno>4.3.5.2. </span>Event firing</h5>
+  <h5 id=event><span class=secno>4.3.6.2. </span>Event firing</h5>
 
   <p class=big-issue>maybe this should be moved higher up (terminology?
    conformance? DOM?) Also, the whole terminology thing should be changed so
@@ -25303,7 +25428,7 @@
    actions are defined in terms of <em>any</em> event of the right type on
    that element, not those that are dispatched in expected ways.
 
-  <h5 id=events0><span class=secno>4.3.5.3. </span>Events and the <code><a
+  <h5 id=events0><span class=secno>4.3.6.3. </span>Events and the <code><a
    href="#window">Window</a></code> object</h5>
 
   <p>When an event is dispatched at a DOM node in a <code>Document</code> in
@@ -25322,7 +25447,7 @@
     bubbling has been prevented.
   </ol>
 
-  <h5 id=runtime-script-errors><span class=secno>4.3.5.4. </span>Runtime
+  <h5 id=runtime-script-errors><span class=secno>4.3.6.4. </span>Runtime
    script errors</h5>
 
   <p><em>This section only applies to user agents that support scripting in
@@ -25425,33 +25550,7 @@
 <!-- XXX there are other attributes! -->};</pre>
   <!-- also, see window.external.AddSearchProvider() and similar DOM APIs from IE -->
 
-  <h4 id=offline><span class=secno>4.5.1. </span>Offline Web applications</h4>
-
-  <p>The <dfn id=navigator.online
-   title=dom-navigator-onLine><code>navigator.onLine</code></dfn> attribute
-   must return false if the user agent will not contact the network when the
-   user follows links or when a script requests a remote page (or knows that
-   such an attempt would fail), and must return true otherwise.
-
-  <p>The <dfn id=offline0 title=event-offline><code>offline</code></dfn>
-   event must be fired when the value of the <code
-   title=dom-navigator-onLine><a
-   href="#navigator.online">navigator.onLine</a></code> attribute of the
-   <code><a href="#window">Window</a></code> changes from true to false.
-
-  <p>The <dfn id=online title=event-online><code>online</code></dfn> event
-   must be fired when the value of the <code title=dom-navigator-onLine><a
-   href="#navigator.online">navigator.onLine</a></code> attribute of the
-   <code><a href="#window">Window</a></code> changes from false to true.
-
-  <p>These events are in no namespace, do bubble, are not cancelable, have no
-   default action, and use the normal <code>Event</code> interface. They must
-   be fired on <a href="#the-body0">the body element</a>. (As the events
-   bubble, they will reach the <code><a href="#window">Window</a></code>
-   object.)</p>
-  <!-- XXX ononline onoffline need to be defined -->
-
-  <h4 id=custom-handlers><span class=secno>4.5.2. </span>Custom protocol and
+  <h4 id=custom-handlers><span class=secno>4.5.1. </span>Custom protocol and
    content handlers</h4>
 
   <p>The <dfn id=registerprotocolhandler
@@ -25583,10 +25682,10 @@
 
   <p>This section does not define how the pages registered by these methods
    are used, beyond the requirements on how to process the <var
-   title="">uri</var> value (see above). To some extent, the <span
-   title="navigating across documents">processing model for navigating across
-   documents</span> defines some cases where these methods are relevant, but
-   in general UAs may use this information wherever they would otherwise
+   title="">uri</var> value (see above). To some extent, the <a
+   href="#navigate" title=navigate>processing model for navigating across
+   documents</a> defines some cases where these methods are relevant, but in
+   general UAs may use this information wherever they would otherwise
    consider handing content to native plugins or helper applications.
 
   <p>UAs must not use registered content handlers to handle content that was
@@ -25594,7 +25693,7 @@
    non-idempotent transaction), as the remote site would not be able to fetch
    the same data.
 
-  <h5 id=security3><span class=secno>4.5.2.1. </span>Security and privacy</h5>
+  <h5 id=security3><span class=secno>4.5.1.1. </span>Security and privacy</h5>
 
   <p>These mechanisms can introduce a number of concerns, in particular
    privacy concerns.
@@ -25672,7 +25771,7 @@
    trust the third-party handler, a decision many users are unable to make or
    even understand).
 
-  <h5 id=sample-handler-impl><span class=secno>4.5.2.2. </span>Sample user
+  <h5 id=sample-handler-impl><span class=secno>4.5.1.2. </span>Sample user
    interface</h5>
 
   <p><em>This section is non-normative.</em>
@@ -25755,9 +25854,1332 @@
    would work equivalently, but for unknown MIME types instead of unknown
    protocols.
 
-  <h3 id=history><span class=secno>4.6. </span>Session history and navigation</h3>
+  <h3 id=offline><span class=secno>4.6. </span>Offline Web applications</h3>
 
-  <h4 id=the-session><span class=secno>4.6.1. </span>The session history of
+  <h4 id=introduction1><span class=secno>4.6.1. </span>Introduction</h4>
+
+  <p class=big-issue>...
+
+  <h4 id=appcache><span class=secno>4.6.2. </span>Application caches</h4>
+
+  <p>An <dfn id=application0>application cache</dfn> is a collection of
+   resources. An application cache is identified by the URI of a resource
+   manifest which is used to populate the cache.
+
+  <p>Application caches are versioned, and there can be different instances
+   of caches for the same manifest URI, each having a different version.
+
+  <p>Each group of application caches for the same manifest URI have a common
+   <dfn id=update0 title=concept-appcache-status>update status</dfn>, which
+   is one of the following: <i>idle</i>, <i>checking</i>, <i>downloading</i>,
+   <i>update ready</i>.
+
+  <p id="#appcache-history-1">A <a href="#browsing0">browsing context</a> can
+   be associated with an application cache. A <a href="#child">child browsing
+   context</a> is always associated with the same browsing context as its <a
+   href="#parent">parent browsing context</a>, if any. A <a
+   href="#top-level">top-level browsing context</a> is associated with the
+   application cache appropriate for its <a href="#active">active
+   document</a>. (A browsing context's associated cache thus can <a
+   href="#appcache-history-2">change</a> during <a href="#traverse"
+   title="traverse the history">session history traversal</a>.)
+
+  <p>A <code>Document</code> initially has no appropriate cache, but steps <a
+   href="#parser-appcache">in the parser</a> and in the <a href="#navigate"
+   title=navigate>navigation</a> sections cause <a href="#application2"
+   title=concept-appcache-init-with-attribute>cache selection</a> to occur
+   early in the page load process.
+
+  <p>An application cache consists of:
+
+  <ul>
+   <li>
+    <p>One of more resources (including their out-of-band metadata, such as
+     HTTP headers, if any), identified by URIs, each falling into one (or
+     more) of the following categories:</p>
+
+    <dl>
+     <dt><dfn id=implicit title=concept-appcache-implicit>Implicit
+      entries</dfn>
+
+     <dd>Resources that were added to the cache because a <a
+      href="#top-level">top-level browsing context</a> was <a
+      href="#navigate" title=navigate>navigated</a> to that document and the
+      document indicated that this was its cache, using the <code
+      title=attr-html-application>application</code> attribute.
+
+     <dt><dfn id=the-manifest title=concept-appcache-manifest>The
+      manifest</dfn>
+
+     <dd>The resource corresponding to the URI that was given in an implicit
+      entry's <code><a href="#html">html</a></code> element's <code
+      title=attr-html-application>application</code> attribute. The manifest
+      is downloaded and processed during the <a
+      href="#application1">application cache update process</a>. All the <a
+      href="#implicit" title=concept-appcache-implicit>implicit entries</a>
+      have the <a href="#same-schemehostport">same scheme/host/port</a> as
+      the manifest.
+
+     <dt><dfn id=explicit title=concept-appcache-explicit>Explicit
+      entries</dfn>
+
+     <dd>Resources that were listed in the cache's <a href="#the-manifest"
+      title=concept-appcache-manifest>manifest</a>. Explicit entries can also
+      be marked as <dfn id=foreign
+      title=concept-appcache-foreign>foreign</dfn>, which means that they
+      have an <code title=attr-html-application>application</code> attribute
+      but that it doesn't point at this cache's <a href="#the-manifest"
+      title=concept-appcache-manifest>manifest</a>.
+
+     <dt><dfn id=fallback0 title=concept-appcache-fallback>Fallback
+      entries</dfn>
+
+     <dd>Resources that were listed in the cache's <a href="#the-manifest"
+      title=concept-appcache-manifest>manifest</a> as fallback entries.
+
+     <dt><dfn id=opportunistically
+      title=concept-appcache-oppcache>Opportunistically cached entries</dfn>
+
+     <dd>Resources whose URIs <a href="#matches"
+      title=concept-appcache-matches-oppcache>matched</a> an <a
+      href="#opportunistic" title=concept-appcache-oppcache-ns>opportunistic
+      caching namespace</a> when they were fetched, and were therefore cached
+      in the application cache.
+
+     <dt><dfn id=dynamic3 title=concept-appcache-dynamic>Dynamic
+      entries</dfn>
+
+     <dd>Resources that were added to the cache by the <code
+      title=dom-appcache-add><a href="#adduri">add()</a></code> method.
+    </dl>
+
+   <li>Zero or more <dfn id=opportunistic
+    title=concept-appcache-oppcache-ns>opportunistic caching
+    namespaces</dfn>: URIs, used as <a href="#matches"
+    title=concept-appcache-matches-oppcache>prefix match patterns</a>, each
+    of which is mapped to a <a href="#fallback0"
+    title=concept-appcache-fallback>fallback entry</a>. Each namespace URI
+    prefix, when parsed as a URI, has the <a href="#same-schemehostport">same
+    scheme/host/port</a> as <a href="#the-manifest"
+    title=concept-appcache-manifest>the manifest</a>.
+
+   <li>Zero or more URIs that form the <dfn id=online
+    title=concept-appcache-onlinewhitelist>online whitelist</dfn>.
+  </ul>
+
+  <p>Multiple application caches can contain the same resource, e.g. if their
+   manifests all reference that resource. If the user agent is to <dfn
+   id=select0 title=concept-appcache-selection>select an application
+   cache</dfn> from a list of caches that contain a resource, that the user
+   agent must use the application cache that the user most likely wants to
+   see the resource from, taking into account the following:
+
+  <ul>
+   <li>which application cache was most recently updated,
+
+   <li>which application cache was being used to display the resource from
+    which the user decided to look at the new resource, and
+
+   <li>which application cache the user prefers.
+  </ul>
+
+  <h4 id=manifests><span class=secno>4.6.3. </span>The cache manifest syntax</h4>
+
+  <h5 id=writing><span class=secno>4.6.3.1. </span>Writing cache manifests</h5>
+
+  <p>Manifests must be served using the <code
+   title="">text/cache-manifest</code> MIME type. All resources served using
+   the <code title="">text/cache-manifest</code> MIME type must follow the
+   syntax of application cache manifests, as described in this section.
+
+  <p>An application cache manifest is a text file, whose text is encoded
+   using UTF-8. Data in application cache manifests is line-based. Newlines
+   must be represented by U+000A LINE FEED (LF) characters, U+000D CARRIAGE
+   RETURN (CR) characters, or U+000D CARRIAGE RETURN (CR) U+000A LINE FEED
+   (LF) pairs.
+
+  <p class=note>This is a willful double violation of RFC2046.
+
+  <p>The first line of an application cache manifest must consist of the
+   string "CACHE", a single U+0020 SPACE character, the string "MANIFEST",
+   and zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab)
+   characters. If any other text is found on the first line, the user agent
+   will ignore the entire file. The first line may optionally be preceded by
+   a U+FEFF BYTE ORDER MARK (BOM) character.
+
+  <p>Subsequent lines, if any, must all be one of the following:
+
+  <dl>
+   <dt>A blank line
+
+   <dd>
+    <p>Blank lines must consist of zero or more U+0020 SPACE and U+0009
+     CHARACTER TABULATION (tab) characters only.</p>
+
+   <dt>A comment
+
+   <dd>
+    <p>Comment lines must consist of zero or more U+0020 SPACE and U+0009
+     CHARACTER TABULATION (tab) characters, followed by a single U+0023
+     NUMBER SIGN (#) character, followed by zero or more characters other
+     than U+000A LINE FEED (LF) and U+000D CARRIAGE RETURN (CR) characters.</p>
+
+    <p class=note>Comments must be on a line on their own. If they were to be
+     included on a line with a URI, the "#" would be mistaken for part of a
+     fragment identifier.</p>
+
+   <dt>A section header
+
+   <dd>
+    <p>Section headers change the current section. There are three possible
+     section headers:
+
+    <dl>
+     <dt><code>CACHE:</code>
+
+     <dd>Switches to the explicit section.
+
+     <dt><code>FALLBACK:</code>
+
+     <dd>Switches to the fallback section.
+
+     <dt><code>NETWORK:</code>
+
+     <dd>Switches to the online whitelist section.
+    </dl>
+
+    <p>Section header lines must consist of zero or more U+0020 SPACE and
+     U+0009 CHARACTER TABULATION (tab) characters, followed by one of the
+     names above (including the U+003A COLON (:) character) followed by zero
+     or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters.</p>
+
+    <p>Ironically, by default, the current section is the explicit section.</p>
+
+   <dt>Data for the current section
+
+   <dd>
+    <p>The format that data lines must take depends on the current section.</p>
+
+    <p>When the current section is the explicit section or the online
+     whitelist section, data lines must consist of zero or more U+0020 SPACE
+     and U+0009 CHARACTER TABULATION (tab) characters, a valid URI reference
+     or IRI reference, and then zero or more U+0020 SPACE and U+0009
+     CHARACTER TABULATION (tab) characters. <a
+     href="#refsRFC3986">[RFC3986]</a> <a href="#refsRFC3987">[RFC3987]</a></p>
+
+    <p>When the current section is the fallback section, data lines must
+     consist of zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION
+     (tab) characters, a valid URI reference or IRI reference, one or more
+     U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters, another
+     valid URI reference or IRI reference, and then zero or more U+0020 SPACE
+     and U+0009 CHARACTER TABULATION (tab) characters. <a
+     href="#refsRFC3986">[RFC3986]</a> <a href="#refsRFC3987">[RFC3987]</a></p>
+  </dl>
+
+  <p>Manifests may contain sections more than once. Sections may be empty.
+
+  <p>Manifests must specify all the URIs that are to be cached. URIs that are
+   to be fallback pages associated with <a href="#opportunistic"
+   title=concept-appcache-oppcache-ns>opportunistic caching namespaces</a>,
+   and those namespaces themselves, must be given in fallback sections, with
+   the namespace being the first URI of the data line, and the corresponding
+   fallback page being the second URI. All the other pages to be cached must
+   be listed in explicit sections.
+
+  <p>Relative URIs must be given relative to the manifest's own URI.
+
+  <p>URIs in manifests must not have fragment identifiers.
+
+  <p><a href="#opportunistic"
+   title=concept-appcache-oppcache-ns>Opportunistic caching namespaces</a>
+   must have the <a href="#same-schemehostport">same scheme/host/port</a> as
+   the manifest itself.
+
+  <p>An opportunistic caching namespace must not be listed more than once.
+
+  <p>URIs that the user agent is to put into the <a href="#online"
+   title=concept-appcache-onlinewhitelist>online whitelist</a> must all be
+   specified in online whitelist sections. (This is needed for any URI that
+   the page is intending to use to communicate back to the server.)
+
+  <p>URIs in the online whitelist section must not also be listed in explicit
+   section, and must not be listed as fallback entries in the fallback
+   section. (URIs in the online whitelist section may match opportunistic
+   caching namespaces, however.)
+
+  <h5 id=parsing0><span class=secno>4.6.3.2. </span>Parsing cache manifests</h5>
+
+  <p>When a user agent is to <dfn id=parse>parse a manifest</dfn>, it means
+   that the user agent must run the following steps:
+
+  <ol>
+   <li>
+    <p>The user agent must decode the bytestream corresponding with the
+     manifest to be parsed, treating it as UTF-8. Bytes or sequences of bytes
+     that are not valid UTF-8 sequences must be interpreted as a U+FFFD
+     REPLACEMENT CHARACTER. All U+0000 NULL characters must be replaced by
+     U+FFFD REPLACEMENT CHARACTERs.
+
+   <li>
+    <p>Let <var title="">explicit URIs</var> be an initially empty list of <a
+     href="#explicit" title=concept-appcache-explicit>explicit entries</a>.
+
+   <li>
+    <p>Let <var title="">fallback URIs</var> be an initially empty mapping of
+     <a href="#opportunistic"
+     title=concept-appcache-oppcache-ns>opportunistic caching namespaces</a>
+     to <a href="#fallback0" title=concept-appcache-fallback>fallback
+     entries</a>.
+
+   <li>
+    <p>Let <var title="">online whitelist URIs</var> be an initially empty
+     list of URIs for a <a href="#online"
+     title=concept-appcache-onlinewhitelist>online whitelist</a>.
+
+   <li>
+    <p>Let <var title="">input</var> be the decoded text of the manifest's
+     bytestream.
+
+   <li>
+    <p>Let <var title="">position</var> be a pointer into <var
+     title="">input</var>, initially pointing at the first character.
+
+   <li>
+    <p>If <var title="">position</var> is pointing at a U+FEFF BYTE ORDER
+     MARK (BOM) character, then advance <var title="">position</var> to the
+     next character.
+
+   <li>
+    <p>If the characters starting from <var title="">position</var> are
+     "CACHE", followed by a U+0020 SPACE character, followed by "MANIFEST",
+     then advance <var title="">position</var> to the next character after
+     those. Otherwise, this isn't a cache manifest; abort this algorithm with
+     a failure while checking for the magic signature.
+
+   <li>
+    <p>If <var title="">position</var> is not past the end of <var
+     title="">input</var> and the character at <var title="">position</var>
+     is neither a U+000A LINE FEED (LF) characters nor a U+000D CARRIAGE
+     RETURN (CR) character, then this isn't a cache manifest; abort this
+     algorithm with a failure while checking for the magic signature.
+
+   <li>
+    <p>This is a cache manifest. The algorithm cannot fail beyond this point
+     (though bogus lines can get ignored).
+
+   <li>
+    <p>Let <var title="">mode</var> be "explicit".
+
+   <li>
+    <p><em>Start of line</em>: If <var title="">position</var> is past the
+     end of <var title="">input</var>, then jump to the last step. Otherwise,
+     <a href="#collect">collect a sequence of characters</a> that are U+000A
+     LINE FEED (LF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, or U+0009
+     CHARACTER TABULATION (tab) characters.
+
+   <li>
+    <p>Now, <a href="#collect">collect a sequence of characters</a> that are
+     <em>not</em> U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)
+     characters, and let the result be <var title="">line</var>.
+
+   <li>
+    <p>If the first character in <var title="">line</var> is a U+0023 NUMBER
+     SIGN (#) character, then jump back to the step labelled "start of line".
+
+   <li>
+    <p>Drop any trailing U+0020 SPACE, or U+0009 CHARACTER TABULATION (tab)
+     characters at the end of <var title="">line</var>.
+
+   <li>
+    <p>If <var title="">line</var> equals "CACHE:" (the word "CACHE" followed
+     by a U+003A COLON (:) character), then set <var title="">mode</var> to
+     "explicit" and jump back to the step labelled "start of line".
+
+   <li>
+    <p>If <var title="">line</var> equals "FALLBACK:" (the word "FALLBACK"
+     followed by a U+003A COLON (:) character), then set <var
+     title="">mode</var> to "fallback" and jump back to the step labelled
+     "start of line".
+
+   <li>
+    <p>If <var title="">line</var> equals "NETWORK:" (the word "NETWORK"
+     followed by a U+003A COLON (:) character), then set <var
+     title="">mode</var> to "online whitelist" and jump back to the step
+     labelled "start of line".
+
+   <li>
+    <p>This is either a data line or it is syntactically incorrect.</p>
+
+    <dl class=switch>
+     <dt>If <var title="">mode</var> is "explicit"
+
+     <dd>
+      <p>If <var title="">line</var> is not a syntactically valid URI
+       reference or IRI reference, then jump back to the step labelled "start
+       of line".</p>
+
+      <p>Otherwise, resolve the URI reference or IRI reference to an absolute
+       URI or IRI, drop any fragment identifier, and add this URI to the <var
+       title="">explicit URIs</var>.</p>
+
+     <dt>If <var title="">mode</var> is "fallback"
+
+     <dd>
+      <p>If <var title="">line</var> does not contain at least one U+0020
+       SPACE or U+0009 CHARACTER TABULATION (tab) character, then jump back
+       to the step labelled "start of line".</p>
+
+      <p>Otherwise, let everything before the first U+0020 SPACE or U+0009
+       CHARACTER TABULATION (tab) character in <var title="">line</var> be
+       <var title="">part one</var>, and let everything after the first
+       U+0020 SPACE or U+0009 CHARACTER TABULATION (tab) character in <var
+       title="">line</var> be <var title="">part two</var>.</p>
+
+      <p>Strip any leading U+0020 SPACE or U+0009 CHARACTER TABULATION (tab)
+       characters in <var title="">part two</var>.</p>
+
+      <p>If <var title="">part one</var> and <var title="">part two</var> are
+       not both syntactically valid URI or IRI references, then jump back to
+       the step labelled "start of line".</p>
+
+      <p>Resolve the URI or IRI references in <var title="">part one</var>
+       and <var title="">part two</var> to absolute URIs or IRIs.</p>
+
+      <p>If the absolute URI or IRI corresponding to <var title="">part
+       one</var> is already in the <var title="">fallback URIs</var> mapping
+       as an <a href="#opportunistic"
+       title=concept-appcache-oppcache-ns>opportunistic caching
+       namespaces</a>, then jump back to the step labelled "start of line".</p>
+
+      <p>If the absolute URI or IRI corresponding to <var title="">part
+       one</var> does not have the <a href="#same-schemehostport">same
+       scheme/host/port</a> as the manifest's URI, then jump back to the step
+       labelled "start of line".</p>
+      <!-- SECURITY -->
+      <p>Otherwise, add the absolute URI or IRI corresponding to <var
+       title="">part one</var> to the <var title="">fallback URIs</var>
+       mapping as an <a href="#opportunistic"
+       title=concept-appcache-oppcache-ns>opportunistic caching
+       namespaces</a>, mapped to the absolute URI corresponding to <var
+       title="">part two</var> as the <a href="#fallback0"
+       title=concept-appcache-fallback>fallback entry</a>.</p>
+
+     <dt>If <var title="">mode</var> is "online whitelist"
+
+     <dd>
+      <p>If <var title="">line</var> is not a syntactically valid URI
+       reference or IRI reference, then jump back to the step labelled "start
+       of line".</p>
+
+      <p>Otherwise, resolve the URI reference or IRI reference to an absolute
+       URI or IRI, drop any fragment identifier, and add this URI to the <var
+       title="">online whitelist URIs</var>.</p>
+    </dl>
+
+   <li>
+    <p>Jump back to the step labelled "start of line". (That step jumps to
+     the next, and last, step when the end of the file is reached.)
+
+   <li>
+    <p>Return the <var title="">explicit URIs</var> list, the <var
+     title="">fallback URIs</var> mapping, and the <var title="">online
+     URIs</var>.
+  </ol>
+
+  <p>Relative URI references and IRI references resolved to absolute URIs or
+   IRIs in the above algorithm must use the manifest's URI as the Base URI
+   from the Retrieval URI for the purposes reference resolution as defined by
+   RFC 3986. <a href="#refsRFC3986">[RFC3986]</a>
+
+  <h4 id=updating1><span class=secno>4.6.4. </span>Updating an application
+   cache</h4>
+
+  <p>When the user agent is required (by other parts of this specification)
+   to start the <dfn id=application1>application cache update process</dfn>,
+   the user agent must run the following steps:
+
+  <p class=big-issue>the event stuff needs to be more consistent -- something
+   about showing every step of the ui or no steps or something; and we need
+   to deal with showing ui for browsing contexts that open when an update is
+   already in progress, and we may need to give applications control over the
+   ui the first time they cache themselves (right now the original cache is
+   done without notifications to the browsing contexts)
+
+  <ol>
+   <li>
+    <p>Let <var title="">manifest URI</var> be the URI of the <a
+     href="#the-manifest" title=concept-appcache-manifest>manifest</a> of the
+     cache to be updated.
+
+   <li>
+    <p>Let <var title="">cache group</var> be the group of <a
+     href="#application0" title="application cache">application caches</a>
+     identified by <var title="">manifest URI</var>.
+
+   <li>
+    <p>Let <var title="">cache</var> be the most recently updated <a
+     href="#application0">application cache</a> identified by <var
+     title="">manifest URI</var> (that is, the newest version found in <var
+     title="">cache group</var>).
+
+   <li>
+    <p>If the <a href="#update0" title=concept-appcache-status>status</a> of
+     the <var title="">cache group</var> is either <i>checking</i> or
+     <i>downloading</i>, then abort these steps, as an update is already in
+     progress for them. Otherwise, set the <a href="#update0"
+     title=concept-appcache-status>status</a> of this group of caches to
+     <i>checking</i>. This entire step must be performed as one atomic
+     operation so as to avoid race conditions.
+
+   <li>
+    <p>If there is already a resource with the URI of <var title="">manifest
+     URI</var> in <var title="">cache</var>, and that resource is categorised
+     as a <a href="#the-manifest"
+     title=concept-appcache-manifest>manifest</a>, then this is an <dfn
+     id=upgrade title=concept-appcache-upgrade>upgrade attempt</dfn>.
+     Otherwise, this is a <dfn id=cache title=concept-appcache-cache>cache
+     attempt</dfn>.</p>
+
+    <p class=note>If this is a <a href="#cache"
+     title=concept-appcache-cache>cache attempt</a>, then <var
+     title="">cache</var> is forcibly the only application cache in <var
+     title="">cache group</var>, and it hasn't ever been populated from its
+     manifest (i.e. this update is an attempt to download the application for
+     the first time). It also can't have any browsing contexts associated
+     with it.</p>
+
+   <li>
+    <p><a href="#firing2">Fire a simple event</a> called <code
+     title=event-checking>checking</code> at the <code><a
+     href="#applicationcache">ApplicationCache</a></code> singleton of each
+     <a href="#top-level">top-level browsing context</a> that is associated
+     with a cache in <var title="">cache group</var>. The default action of
+     this event should be the display of some sort of user interface
+     indicating to the user that the user agent is checking for the
+     availability of updates.</p>
+
+   <li>
+    <p>Fetch the resource from <var title="">manifest URI</var>, and let <var
+     title="">manifest</var> be that resource.</p>
+
+    <p>If the resource is labelled with the MIME type <code
+     title="">text/cache-manifest</code>, parse <var title="">manifest</var>
+     according to the <a href="#parse" title="parse a manifest">rules for
+     parsing manifests</a>, obtaining a list of <a href="#explicit"
+     title=concept-appcache-explicit>explicit entries</a>, <a
+     href="#fallback0" title=concept-appcache-fallback>fallback entries</a>
+     and the <a href="#opportunistic"
+     title=concept-appcache-oppcache-ns>opportunistic caching namespaces</a>
+     that map to them, and entries for the <a href="#online"
+     title=concept-appcache-onlinewhitelist>online whitelist</a>.</p>
+
+   <li>
+    <p>If the previous step fails (e.g. the server returns a 4xx or 5xx
+     response or equivalent, or there is a DNS error, or the connection times
+     out, or the parser for manifests fails when checking the magic
+     signature), or if the resource is labelled with a MIME type other than
+     <code title="">text/cache-manifest</code>, then run these substeps:</p>
+
+    <ol>
+     <li>
+      <p><a href="#firing2">Fire a simple event</a> called <code
+       title=event-error><a href="#error1">error</a></code> at the <code><a
+       href="#applicationcache">ApplicationCache</a></code> singleton of each
+       <a href="#top-level">top-level browsing context</a> that is associated
+       with a cache in <var title="">cache group</var>. The default action of
+       this event should be the display of some sort of user interface
+       indicating to the user that the user agent failed to save the
+       application for offline use.
+
+     <li>
+      <p>If this is a <a href="#cache" title=concept-appcache-cache>cache
+       attempt</a>, then discard <var title="">cache</var> and abort the
+       update process, optionally alerting the user to the failure.
+
+     <li>
+      <p>Otherwise, jump to the last step in the overall set of steps of the
+       update process.
+    </ol>
+
+   <li>
+    <p>If this is an <a href="#upgrade"
+     title=concept-appcache-upgrade>upgrade attempt</a> and the newly
+     downloaded <var title="">manifest</var> is byte-for-byte identical to
+     the manifest found in <var title="">cache</var>, or if the server
+     reported it as "304 Not Modified" or equivalent, then <a
+     href="#firing2">fire a simple event</a> called <code
+     title=event-noupdate>noupdate</code> at the <code><a
+     href="#applicationcache">ApplicationCache</a></code> singleton of each
+     <a href="#top-level">top-level browsing context</a> that is associated
+     with a cache in <var title="">cache group</var>. The default action of
+     this event should be the display of some sort of user interface
+     indicating to the user that the application is up to date. Then, jump to
+     the last step of the update process.
+
+   <li>
+    <p>Set the <a href="#update0" title=concept-appcache-status>status</a> of
+     <var title="">cache group</var> to <i>downloading</i>.
+
+   <li>
+    <p><a href="#firing2">Fire a simple event</a> called <code
+     title=event-downloading>downloading</code> at the <code><a
+     href="#applicationcache">ApplicationCache</a></code> singleton of each
+     <a href="#top-level">top-level browsing context</a> that is associated
+     with a cache in <var title="">cache group</var>. The default action of
+     this event should be the display of some sort of user interface
+     indicating to the user that a new version is being downloaded.
+
+   <li>
+    <p>If this is an <a href="#upgrade"
+     title=concept-appcache-upgrade>upgrade attempt</a>, then let <var
+     title="">new cache</var> be a newly created <a
+     href="#application0">application cache</a> identified by <span
+     title="">manifest URI</span>, being a new version in <var title="">cache
+     group</var>. Otherwise, let <var title="">new cache</var> and <var
+     title="">cache</var> be the same version of the application cache.
+
+   <li>
+    <p>Let <var title="">file list</var> be an empty list of URIs with flags.
+
+   <li>
+    <p>Add all the URIs in the list of <a href="#explicit"
+     title=concept-appcache-explicit>explicit entries</a> obtained by parsing
+     <var title="">manifest</var> to <var title="">file list</var>, each
+     flagged with "explicit entry".
+
+   <li>
+    <p>Add all the URIs in the list of <a href="#fallback0"
+     title=concept-appcache-fallback>fallback entries</a> obtained by parsing
+     <var title="">manifest</var> to <var title="">file list</var>, each
+     flagged with "fallback entry".
+
+   <li>
+    <p>If this is an <a href="#upgrade"
+     title=concept-appcache-upgrade>upgrade attempt</a>, then add all the
+     URIs of <a href="#opportunistically"
+     title=concept-appcache-oppcache>opportunistically cached entries</a> in
+     <var title="">cache</var> that <a href="#matches"
+     title=concept-appcache-matches-oppcache>match</a> the <a
+     href="#opportunistic" title=concept-appcache-oppcache-ns>opportunistic
+     caching namespaces</a> obtained by parsing <var title="">manifest</var>
+     to <var title="">file list</var>, each flagged with "opportunistic
+     entry".
+
+   <li>
+    <p>If this is an <a href="#upgrade"
+     title=concept-appcache-upgrade>upgrade attempt</a>, then add all the
+     URIs of <a href="#dynamic3" title=concept-appcache-dynamic>dynamic
+     entries in <var title="">cache</var> to <var title="">file list</var>,
+     each flagged with "dynamic entry".</a>
+
+   <li>
+    <p>If any URI is in <var title="">file list</var> more than once, then
+     merge the entries into one entry for that URI, that entry having all the
+     flags that the original entries had.
+
+   <li>
+    <p>For each URI in <var title="">file list</var>, run the following
+     steps:</p>
+
+    <ol>
+     <li>
+      <p><a href="#firing2">Fire a simple event</a> called <code
+       title=event-progress><a href="#progress0">progress</a></code> at the
+       <code><a href="#applicationcache">ApplicationCache</a></code>
+       singleton of each <a href="#top-level">top-level browsing context</a>
+       that is associated with a cache in <var title="">cache group</var>.
+       The default action of this event should be the display of some sort of
+       user interface indicating to the user that a file is being downloaded
+       in preparation for updating the application.
+     </li>
+     <!-- XXX need to include
+     progress information -->
+
+     <li>
+      <p>Fetch the resource. If this is an <a href="#upgrade"
+       title=concept-appcache-upgrade>upgrade attempt</a>, then use <var
+       title="">cache</var> as an HTTP cache, and honour HTTP caching
+       semantics (such as expiration, ETags, and so forth) with respect to
+       that cache. User agents may also have other caches in place.
+
+     <li>
+      <p>If the previous steps fails (e.g. the server returns a 4xx or 5xx
+       response or equivalent, or there is a DNS error, or the connection
+       times out), then run these substeps:</p>
+
+      <ol>
+       <li>
+        <p><a href="#firing2">Fire a simple event</a> called <code
+         title=event-error><a href="#error1">error</a></code> at the <code><a
+         href="#applicationcache">ApplicationCache</a></code> singleton of
+         each <a href="#top-level">top-level browsing context</a> that is
+         associated with a cache in <var title="">cache group</var>. The
+         default action of this event should be the display of some sort of
+         user interface indicating to the user that the user agent failed to
+         save the application for offline use.
+
+       <li>
+        <p>If this is a <a href="#cache" title=concept-appcache-cache>cache
+         attempt</a>, then discard <var title="">cache</var> and abort the
+         update process, optionally alerting the user to the failure.
+
+       <li>
+        <p>Otherwise, jump to the last step in the overall set of steps of
+         the update process.
+      </ol>
+
+     <li>
+      <p>Otherwise, the fetching succeeded. Store the resource in the <var
+       title="">new cache</var>.
+
+     <li>
+      <p>If the URI being processed was flagged as an "explicit entry" in
+       <var title="">file list</var>, then categorise the entry as an <a
+       href="#explicit" title=concept-appcache-explicit>explicit entry</a>.
+
+     <li>
+      <p>If the URI being processed was flagged as a "fallback entry" in <var
+       title="">file list</var>, then categorise the entry as a <a
+       href="#fallback0" title=concept-appcache-fallback>fallback entry</a>.
+
+     <li>
+      <p>If the URI being processed was flagged as a "opportunistic entry" in
+       <var title="">file list</var>, then categorise the entry as an <a
+       href="#opportunistically"
+       title=concept-appcache-oppcache>opportunistically cached entry</a>.
+
+     <li>
+      <p>If the URI being processed was flagged as an "dynamic entry" in <var
+       title="">file list</var>, then categorise the entry as a <a
+       href="#dynamic3" title=concept-appcache-dynamic>dynamic entry</a>.
+    </ol>
+
+   <li>
+    <p>Store <var title="">manifest</var> in <var title="">new cache</var>,
+     if it's not there already, and categorise this entry (whether newly
+     added or not) as <a href="#the-manifest"
+     title=concept-appcache-manifest>the manifest</a>.
+
+   <li>
+    <p>Store the list of <a href="#opportunistic"
+     title=concept-appcache-oppcache-ns>opportunistic caching namespaces</a>,
+     and the URIs of the <a href="#fallback0"
+     title=concept-appcache-fallback>fallback entries</a> that they map to,
+     in the new cache.
+
+   <li>
+    <p>Store the URIs that form the new <a href="#online"
+     title=concept-appcache-onlinewhitelist>online whitelist</a> in the new
+     cache.
+
+   <li>
+    <p>If this is a <a href="#cache" title=concept-appcache-cache>cache
+     attempt</a>, then:</p>
+
+    <p>Set the <a href="#update0" title=concept-appcache-status>status</a> of
+     <var title="">cache group</var> to <i>idle</i>.</p>
+
+    <p>Associate any <code>Document</code> objects that were <a
+     href="#flagAsCandidateForCache">flagged as candidates</a> for this
+     manifest URI's caches with <var title="">cache</var>.</p>
+
+    <p><a href="#firing2">Fire a simple event</a> called <code
+     title=event-cached>cached</code> at the <code><a
+     href="#applicationcache">ApplicationCache</a></code> singleton of each
+     <a href="#top-level">top-level browsing context</a> that is associated
+     with a cache in <var title="">cache group</var>. The default action of
+     this event should be the display of some sort of user interface
+     indicating to the user that the application has been cached and that
+     they can now use it offline.</p>
+
+   <li>
+    <p>Otherwise, this is an <a href="#upgrade"
+     title=concept-appcache-upgrade>upgrade attempt</a>:</p>
+
+    <p>Set the <a href="#update0" title=concept-appcache-status>status</a> of
+     <var title="">cache group</var> to <i>update ready</i>.</p>
+
+    <p><a href="#firing2">Fire a simple event</a> called <code
+     title=event-updateready>updateready</code> at the <code><a
+     href="#applicationcache">ApplicationCache</a></code> singleton of each
+     <a href="#top-level">top-level browsing context</a> that is associated
+     with a cache in <var title="">cache group</var>. The default action of
+     this event should be the display of some sort of user interface
+     indicating to the user that a new version is available and that they can
+     activate it by reloading the page.</p>
+
+   <li>
+    <p>Abort these steps. The following step is jumped to by various parts of
+     the algorithm above when they have to cancel the update.
+
+   <li>
+    <p>Let the <a href="#update0" title=concept-appcache-status>status</a> of
+     the group of caches to which <var title="">cache</var> belongs be
+     <i>idle</i>. If appropriate, remove any user interface indicating that
+     an update for this cache is in progress.
+  </ol>
+
+  <h4 id=processing2><span class=secno>4.6.5. </span>Processing model</h4>
+
+  <p>The processing model of application caches for offline support in Web
+   applications is part of the <a href="#navigate"
+   title=navigate>navigation</a> model, but references the algorithms defined
+   in this section.
+
+  <p>A URI <dfn id=matches title=concept-appcache-matches-oppcache>matches an
+   opportunistic caching namespace</dfn> if there exists an <a
+   href="#application0">application cache</a> whose <a href="#the-manifest"
+   title=concept-appcache-manifest>manifest</a>'s URI has the <a
+   href="#same-schemehostport">same scheme/host/port</a> as the URI in
+   question, and if that application cache has an <a href="#opportunistic"
+   title=concept-appcache-oppcache-ns>opportunistic caching namespace</a>
+   with a <path> component that exactly matches the start of the
+   <path> component of the URI being examined. If multiple
+   opportunistic caching namespaces match the same URI, the one with the
+   longest <path> component is the one that matches. A URI looking for
+   an opportunistic caching namespace can match more than one application
+   cache at a time, but only matches one namespace in each cache.
+
+  <div class=example>
+   <p>If a manifest <code title="">http://example.com/app1/manifest</code>
+    declares that <code title="">http://example.com/resources/images</code>
+    should be opportunistically cached, and the user navigates to <code
+    title="">http://example.com/resources/images/cat.png</code>, then the
+    user agent will decide that the application cache identified by <code
+    title="">http://example.com/app1/manifest</code> contains a namespace
+    with a match for that URI.</p>
+  </div>
+
+  <p>When the <dfn id=application2
+   title=concept-appcache-init-with-attribute>application cache selection
+   algorithm</dfn> algorithm is invoked with a manifest URI, the user agent
+   must run the first applicable set of steps from the following list:
+
+  <dl class=switch>
+   <dt>If the resource is not being loaded as part of navigation of a <a
+    href="#top-level">top-level browsing context</a>
+
+   <dd>
+    <p>As an optimisation, if the resource was loaded from an <a
+     href="#application0">application cache</a>, and the manifest URI of that
+     cache doesn't match the manifest URI with which the algorithm was
+     invoked, then the user agent should mark the entry in that application
+     cache corresponding to the resource that was just loaded as being <a
+     href="#foreign" title=concept-appcache-foreign>foreign</a>.</p>
+
+    <p>Other than that, nothing special happens with respect to application
+     caches.</p>
+   </dd>
+   <!-- otherwise, we're talking top-level browsing contexts only: -->
+
+   <dt>If the resource being loaded was loaded from an application cache and
+    the URI of that application cache's manifest is the same as the manifest
+    URI with which the algorithm was invoked
+
+   <dd>
+    <p>Associate the <code>Document</code> with the cache from which it was
+     loaded. Invoke the <a href="#application1">application cache update
+     process</a>.</p>
+
+   <dt>If the resource being loaded was loaded from an application cache and
+    the URI of that application cache's manifest is <em>not</em> the same as
+    the manifest URI with which the algorithm was invoked
+
+   <dd>
+    <p>Mark the entry for this resource in the application cache from which
+     it was loaded as <a href="#foreign"
+     title=concept-appcache-foreign>foreign</a>.</p>
+
+    <p>Restart the current navigation from the top of the <a href="#navigate"
+     title=navigate>navigation algorithm</a>, undoing any changes that were
+     made as part of the initial load (changes can be avoided by ensuring
+     that the step to <a href="#update2">update the session history with the
+     new page</a> is only ever completed <em>after</em> the application cache
+     selection algorithm is run, though this is not required).</p>
+
+    <p class=note>The navigation will not result in the same resource being
+     loaded, because "foreign" entries are never picked during navigation.</p>
+
+    <p>User agents may notify the user of the inconsistency between the cache
+     manifest and the resource's own metadata, to aid in application
+     development.</p>
+
+   <dt>If the resource being loaded was not loaded from an application cache,
+    but it was loaded using HTTP GET or equivalent
+
+   <dd>
+    <ol>
+     <li>
+      <p>If the manifest URI does not have the <a
+       href="#same-schemehostport">same scheme/host/port</a> as the
+       resource's own URI, then invoke the <a href="#application3"
+       title=concept-appcache-init-no-attribute>application cache selection
+       algorithm</a> again, but without a manifest, and abort these steps.
+
+     <li>
+      <p>If there is already an <a href="#application0">application cache</a>
+       identified by this manifest URI, and that <a
+       href="#application0">application cache</a> contains a resource with
+       the URI of the manifest, and that resource is categorised as a <a
+       href="#the-manifest" title=concept-appcache-manifest>manifest</a>,
+       then: store the resource in the matching cache with the most up to
+       date version, categorised as an <a href="#implicit"
+       title=concept-appcache-implicit>implicit entry</a>, associate the
+       <code>Document</code> with that cache, invoke the <a
+       href="#application1">application cache update process</a>, and abort
+       these steps.
+
+     <li id=flagAsCandidateForCache>
+      <p>Flag the resource's <code>Document</code> as a candidate for this
+       manifest URI's caches.
+
+     <li>
+      <p>If there is already an <a href="#application0">application cache</a>
+       identified by this manifest URI, then that <a
+       href="#application0">application cache</a> does not yet contain a
+       resource with the URI of the manifest, or it does but that resource is
+       not yet categorised as a <a href="#the-manifest"
+       title=concept-appcache-manifest>manifest</a>: store the resource in
+       that cache, categorised as an <a href="#implicit"
+       title=concept-appcache-implicit>implicit entry</a> (replacing the
+       file's previous contents if it was already in the cache, but not
+       removing any other categories it might have), and abort these steps.
+
+     <li>
+      <p>Otherwise, there is no matching <a href="#application0">application
+       cache</a>: create a new application cache identified by this manifest
+       URI, store the resource in that cache, categorised as an <a
+       href="#implicit" title=concept-appcache-implicit>implicit entry</a>,
+       and then invoke the <a href="#application1">application cache update
+       process</a>.
+    </ol>
+
+   <dt>Otherwise
+
+   <dd>
+    <p>Invoke the <a href="#application3"
+     title=concept-appcache-init-no-attribute>application cache selection
+     algorithm</a> again, but without a manifest.</p>
+  </dl>
+
+  <p>When the <dfn id=application3
+   title=concept-appcache-init-no-attribute>application cache selection
+   algorithm</dfn> is invoked <em>without</em> a manifest, then: if the
+   resource is being loaded as part of navigation of a <a
+   href="#top-level">top-level browsing context</a>, and the resource was
+   fetched from a particular <a href="#application0">application cache</a>,
+   then the user agent must associate the <code>Document</code> with that
+   application cache and invoke the <a href="#application1">application cache
+   update process</a> for that cache; otherwise, nothing special happens with
+   respect to application caches.
+
+  <h5 id=changes><span class=secno>4.6.5.1. </span>Changes to the networking
+   model</h5>
+
+  <p>When a browsing context is associated with an <a
+   href="#application0">application cache</a>, any and all resource loads
+   must go through the following steps instead of immediately invoking the
+   mechanisms appropriate to that resource's scheme:
+
+  <ol>
+   <li>
+    <p>If the resource is not to be fetched using the HTTP GET mechanism or
+     equivalent, then fetch the resource normally and abort these steps.
+
+   <li>
+    <p>If the resource's URI, ignoring its fragment identifier if any, is
+     listed in the <a href="#application0">application cache</a>'s <a
+     href="#online" title=concept-appcache-onlinewhitelist>online
+     whitelist</a>, then fetch the resource normally and abort these steps.
+
+   <li>
+    <p>If the resource's URI is <a href="#implicit"
+     title=concept-appcache-implicit>an implicit entry</a>, <a
+     href="#the-manifest" title=concept-appcache-manifest>the manifest</a>,
+     <a href="#explicit" title=concept-appcache-explicit>an explicit
+     entry</a>, <a href="#fallback0" title=concept-appcache-fallback>a
+     fallback entry</a>, <a href="#opportunistically"
+     title=concept-appcache-oppcache>an opportunistically cached entry</a>,
+     or a <a href="#dynamic3" title=concept-appcache-dynamic>dynamic
+     entry</a> in the <a href="#application0">application cache</a>, then
+     fetch the resource from the cache and abort these steps.
+
+   <li>
+    <p>If the resource's URI has the <a href="#same-schemehostport">same
+     scheme/host/port</a> as the manifest's URI, and the start of the
+     resource's URI's <path> component is exactly matched by the
+     <path> component of an <a href="#opportunistic"
+     title=concept-appcache-oppcache-ns>opportunistic caching namespace</a>
+     in the <a href="#application0">application cache</a>, then:
+
+    <p>Fetch the resource normally. If this results 4xx or 5xx status codes
+     or equivalent, or if there were network errors, then instead fetch, from
+     the cache, the resource of the <a href="#fallback0"
+     title=concept-appcache-fallback>fallback entry</a> corresponding to the
+     namespace with the longest matching <path> component. Abort these
+     steps.</p>
+
+   <li>
+    <p>Fail the resource load.
+  </ol>
+
+  <p class=note>The above algorithm ensures that resources that are not
+   present in the manifest will always fail to load (at least, after the
+   cache has been primed the first time), making the testing of offline
+   applications simpler.
+
+  <h4 id=application><span class=secno>4.6.6. </span>Application cache API</h4>
+
+  <pre class=idl>interface <dfn id=applicationcache>ApplicationCache</dfn> {
+
+  // <a href="#update0" title=concept-appcache-status>update status</a>
+  const unsigned short <a href="#uncached" title=dom-appcache-UNCACHED>UNCACHED</a> = 0;
+  const unsigned short <a href="#idle" title=dom-appcache-IDLE>IDLE</a> = 1;
+  const unsigned short <a href="#checking" title=dom-appcache-CHECKING>CHECKING</a> = 2;
+  const unsigned short <a href="#downloading" title=dom-appcache-DOWNLOADING>DOWNLOADING</a> = 3;
+  const unsigned short <a href="#updateready" title=dom-appcache-UPDATEREADY>UPDATEREADY</a> = 4;
+  readonly attribute unsigned short <a href="#status0" title=dom-appcache-status>status</a>;
+
+  // updates
+  void <a href="#update1" title=dom-appcache-update>update</a>();
+  void <a href="#swapcache" title=dom-appcache-swapCache>swapCache</a>();
+
+  // dynamic entries
+  readonly attribute unsigned long <a href="#length6" title=dom-appcache-length>length</a>;
+  DOMString <a href="#itemindex4" title=dom-appcache-item>item</a>(in unsigned long index);
+  void <a href="#adduri" title=dom-appcache-add>add</a>(in DOMString uri);
+  void <a href="#remove1" title=dom-appcache-remove>remove</a>(in DOMString uri);
+
+  // events
+           attribute <span>EventListener</span> <a href="#onchecking" title=handler-appcache-onchecking>onchecking</a>;
+           attribute <span>EventListener</span> <a href="#onerror0" title=handler-appcache-onerror>onerror</a>;
+           attribute <span>EventListener</span> <a href="#onnoupdate" title=handler-appcache-onnoupdate>onnoupdate</a>;
+           attribute <span>EventListener</span> <a href="#ondownloading" title=handler-appcache-ondownloading>ondownloading</a>;
+           attribute <span>EventListener</span> <a href="#onprogress" title=handler-appcache-onprogress>onprogress</a>;
+           attribute <span>EventListener</span> <a href="#onupdateready" title=handler-appcache-onupdateready>onupdateready</a>;
+           attribute <span>EventListener</span> <a href="#oncached" title=handler-appcache-oncached>oncached</a>;
+
+};</pre>
+
+  <p>Objects implementing the <code><a
+   href="#applicationcache">ApplicationCache</a></code> interface must also
+   implement the <code>EventTarget</code> interface.
+
+  <p>There is a one-to-one mapping from <code>Document</code> objects to
+   <code><a href="#applicationcache">ApplicationCache</a></code> objects. The
+   <dfn id=applicationcache0
+   title=dom-applicationCache><code>applicationCache</code></dfn> attribute
+   on <code><a href="#window">Window</a></code> objects must return the
+   <code><a href="#applicationcache">ApplicationCache</a></code> object
+   associated with the <a href="#active">active document</a> of the <code><a
+   href="#window">Window</a></code>'s <a href="#browsing0">browsing
+   context</a>.
+
+  <p>An <code><a href="#applicationcache">ApplicationCache</a></code> object
+   might be associated with an <a href="#application0">application cache</a>.
+   When the <code>Document</code> object that the <code><a
+   href="#applicationcache">ApplicationCache</a></code> object maps to is
+   associated with an application cache, then that is the application cache
+   with which the <code><a
+   href="#applicationcache">ApplicationCache</a></code> object is associated.
+   Otherwise, the <code><a
+   href="#applicationcache">ApplicationCache</a></code> object is associated
+   with the application cache that the <code>Document</code> object's <a
+   href="#browsing0">browsing context</a> is associated with, if any.
+
+  <p>The <dfn id=status0 title=dom-appcache-status><code>status</code></dfn>
+   attribute, on getting, must return the current state of the <a
+   href="#application0">application cache</a> <code><a
+   href="#applicationcache">ApplicationCache</a></code> object is associated
+   with, if any. This must be the appropriate value from the following list:
+
+  <dl>
+   <dt><dfn id=uncached
+    title=dom-appcache-UNCACHED><code>UNCACHED</code></dfn> (numeric value 0)
+
+   <dd>
+    <p>The <code><a href="#applicationcache">ApplicationCache</a></code>
+     object is not associated with an <a href="#application0">application
+     cache</a> at this time.
+
+   <dt><dfn id=idle title=dom-appcache-IDLE><code>IDLE</code></dfn> (numeric
+    value 1)
+
+   <dd>
+    <p>The <code><a href="#applicationcache">ApplicationCache</a></code>
+     object is associated with an <a href="#application0">application
+     cache</a> whose group is in the <i>idle</i> <span
+     title=concept-appcache-states>update status</span>.
+
+   <dt><dfn id=checking
+    title=dom-appcache-CHECKING><code>CHECKING</code></dfn> (numeric value 2)
+
+   <dd>
+    <p>The <code><a href="#applicationcache">ApplicationCache</a></code>
+     object is associated with an <a href="#application0">application
+     cache</a> whose group is in the <i>checking</i> <span
+     title=concept-appcache-states>update status</span>.
+
+   <dt><dfn id=downloading
+    title=dom-appcache-DOWNLOADING><code>DOWNLOADING</code></dfn> (numeric
+    value 3)
+
+   <dd>
+    <p>The <code><a href="#applicationcache">ApplicationCache</a></code>
+     object is associated with an <a href="#application0">application
+     cache</a> whose group is in the <i>downloading</i> <span
+     title=concept-appcache-states>update status</span>.
+
+   <dt><dfn id=updateready
+    title=dom-appcache-UPDATEREADY><code>UPDATEREADY</code></dfn> (numeric
+    value 4)
+
+   <dd>
+    <p>The <code><a href="#applicationcache">ApplicationCache</a></code>
+     object is associated with an <a href="#application0">application
+     cache</a> whose group is in the <i>update ready</i> <span
+     title=concept-appcache-states>update status</span>.
+  </dl>
+
+  <p>The <dfn id=length6 title=dom-appcache-length><code>length</code></dfn>
+   attribute must return the number of entries in the <a
+   href="#application0">application cache</a> with which the <code><a
+   href="#applicationcache">ApplicationCache</a></code> object is associated,
+   if any, and zero the object is not associated with any application cache.
+
+  <p>The <a href="#dynamic3" title=concept-appcache-dynamic>dynamic
+   entries</a> in the <a href="#application0">application cache</a> are
+   ordered in the same order as they were added to the cache by the <code
+   title=dom-appcache-add><a href="#adduri">add()</a></code> method, with the
+   oldest entry being the zeroth entry, and the most recently added entry
+   having the index <span><code title=dom-appcache-length><a
+   href="#length6">length</a></code>-1</span>.
+
+  <p>The <dfn id=itemindex4 title=dom-appcache-item><code>item(<var
+   title="">index</var>)</code></dfn> method must return the <a
+   href="#dynamic3" title=concept-appcache-dynamic>dynamic entries</a> with
+   index <var title="">index</var> from the <a
+   href="#application0">application cache</a>, if one is associated with the
+   <code><a href="#applicationcache">ApplicationCache</a></code> object. If
+   the object is not associated with any application cache, or if the <var
+   title="">index</var> argument is lower than zero or greater than
+   <span><code title=dom-appcache-length><a
+   href="#length6">length</a></code>-1</span>, the method must instead raise
+   an <code>INDEX_SIZE_ERR</code> exception.
+
+  <p>The <dfn id=adduri title=dom-appcache-add><code>add(<var
+   title="">uri</var>)</code></dfn> method must run the following steps:
+
+  <ol>
+   <li>
+    <p>If the <code><a href="#applicationcache">ApplicationCache</a></code>
+     object is not associated with any application cache, then raise an
+     <code>INVALID_STATE_ERR</code> exception and abort these steps.
+
+   <li>
+    <p>If there is already a resource in in the <a
+     href="#application0">application cache</a> with which the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object is
+     associated that has the address <var title="">uri</var>, then ensure
+     that entry is categorised as a <a href="#dynamic3"
+     title=concept-appcache-dynamic>dynamic entry</a> and return and abort
+     these steps.
+
+   <li>
+    <p>Return, but do not abort these steps.
+
+   <li>
+    <p>Fetch the resource referenced by <var title="">uri</var>.
+
+   <li>
+    <p>If this results 4xx or 5xx status codes or equivalent, or if there
+     were network errors, then abort these steps.
+
+   <li>
+    <p>Wait for there to be no running scripts, or at least no running
+     scripts that can reach an <code><a
+     href="#applicationcache">ApplicationCache</a></code> object associated
+     with the <a href="#application0">application cache</a> with which this
+     <code><a href="#applicationcache">ApplicationCache</a></code> object is
+     associated.</p>
+
+    <p>Add the fetched resource to the <a href="#application0">application
+     cache</a> and categorise it as a <a href="#dynamic3"
+     title=concept-appcache-dynamic>dynamic entry</a> before letting any such
+     scripts resume.</p>
+  </ol>
+
+  <p class=big-issue>We can make the add() API more usable (i.e. make it
+   possible to detect progress and distinguish success from errors without
+   polling and timeouts) if we have the method return an object that is a
+   target of Progress Events, much like the <a
+   href="http://dev.w3.org/cvsweb/~checkout~/2006/webapi/XMLHttpRequest-2/Overview.html?content-type=text/html;%20charset=utf-8#xmlhttprequesteventtarget-interface">XMLHttpRequestEventTarget</a>
+   interface. This would also make this far more complex to spec and
+   implement.
+
+  <p>The <dfn id=remove1 title=dom-appcache-remove><code>remove(<var
+   title="">uri</var>)</code></dfn> method must remove the <a
+   href="#dynamic3" title=concept-appcache-dynamic>dynamic entry</a>
+   categorisation of any entry with the address <var title="">uri</var> in
+   the <a href="#application0">application cache</a> with which the <code><a
+   href="#applicationcache">ApplicationCache</a></code> object is associated.
+   If this removes the last categorisation of an entry in that cache, then
+   the entry must be removed entirely (such that if it is re-added, it will
+   be loaded from the network again). If the <code><a
+   href="#applicationcache">ApplicationCache</a></code> object is not
+   associated with any application cache, then the method must raise an
+   <code>INVALID_STATE_ERR</code> exception instead.
+
+  <p>If the <dfn id=update1
+   title=dom-appcache-update><code>update()</code></dfn> method is invoked,
+   the user agent must invoke the <a href="#application1">application cache
+   update process</a>, in the background, for the <a
+   href="#application0">application cache</a> with which the <code><a
+   href="#applicationcache">ApplicationCache</a></code> object is associated.
+   If there is no such application cache, then the method must raise an
+   <code>INVALID_STATE_ERR</code> exception instead.
+
+  <p>If the <dfn id=swapcache
+   title=dom-appcache-swapCache><code>swapCache()</code></dfn> method is
+   invoked, the user agent must run the following steps:
+
+  <ol>
+   <li>
+    <p>Let <var title="">document</var> be the <code>Document</code> with
+     which the <code><a href="#applicationcache">ApplicationCache</a></code>
+     object is associated.
+
+   <li>
+    <p>Check that <var title="">document</var> is associated with an <a
+     href="#application0">application cache</a>. If it is not, then raise an
+     <code>INVALID_STATE_ERR</code> exception and abort these steps.</p>
+
+    <p class=note>This is not the same thing as the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object being itself
+     associated with an <a href="#application0">application cache</a>! In
+     particular, this can only happen if <var title="">document</var> is in a
+     <a href="#top-level">top-level browsing context</a>.</p>
+
+   <li>
+    <p>Let <var title="">cache</var> be the <a
+     href="#application0">application cache</a> with which the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object is
+     associated. (By definition, this is the same as the one that was found
+     in the previous step.)
+
+   <li>
+    <p>Check that there is an application cache in the same group as <var
+     title="">cache</var> which has an entry categorised as a <a
+     href="#the-manifest" title=concept-appcache-manifest>manifest</a> that
+     has is newer than <var title="">cache</var>. If there is not, then raise
+     an <code>INVALID_STATE_ERR</code> exception and abort these steps.
+
+   <li>
+    <p>Let <var title="">new cache</var> be the newest <a
+     href="#application0">application cache</a> in the same group as <var
+     title="">cache</var> which has an entry categorised as a <a
+     href="#the-manifest" title=concept-appcache-manifest>manifest</a>.
+
+   <li>
+    <p>Unassociate <var title="">document</var> from <var
+     title="">cache</var> and instead associate it with <var title="">new
+     cache</var>.
+  </ol>
+
+  <p>The following are the <a href="#event3">event handler DOM attributes</a>
+   that must be supported by objects implementing the <code><a
+   href="#applicationcache">ApplicationCache</a></code> interface:
+
+  <dl>
+   <dt><dfn id=onchecking
+    title=handler-appcache-onchecking><code>onchecking</code></dfn>
+
+   <dd>
+    <p>Must be invoked whenever an <code title=event-checking>checking</code>
+     event is targeted at or bubbles through the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object.
+
+   <dt><dfn id=onerror0
+    title=handler-appcache-onerror><code>onerror</code></dfn>
+
+   <dd>
+    <p>Must be invoked whenever an <code title=event-error><a
+     href="#error1">error</a></code> event is targeted at or bubbles through
+     the <code><a href="#applicationcache">ApplicationCache</a></code>
+     object.
+
+   <dt><dfn id=onnoupdate
+    title=handler-appcache-onnoupdate><code>onnoupdate</code></dfn>
+
+   <dd>
+    <p>Must be invoked whenever an <code title=event-noupdate>noupdate</code>
+     event is targeted at or bubbles through the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object.
+
+   <dt><dfn id=ondownloading
+    title=handler-appcache-ondownloading><code>ondownloading</code></dfn>
+
+   <dd>
+    <p>Must be invoked whenever an <code
+     title=event-downloading>downloading</code> event is targeted at or
+     bubbles through the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object.
+
+   <dt><dfn id=onprogress
+    title=handler-appcache-onprogress><code>onprogress</code></dfn>
+
+   <dd>
+    <p>Must be invoked whenever an <code title=event-progress><a
+     href="#progress0">progress</a></code> event is targeted at or bubbles
+     through the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object.
+
+   <dt><dfn id=onupdateready
+    title=handler-appcache-onupdateready><code>onupdateready</code></dfn>
+
+   <dd>
+    <p>Must be invoked whenever an <code
+     title=event-updateready>updateready</code> event is targeted at or
+     bubbles through the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object.
+
+   <dt><dfn id=oncached
+    title=handler-appcache-oncached><code>oncached</code></dfn>
+
+   <dd>
+    <p>Must be invoked whenever a <code title=event-cached>cached</code>
+     event is targeted at or bubbles through the <code><a
+     href="#applicationcache">ApplicationCache</a></code> object.
+  </dl>
+
+  <h4 id=browser0><span class=secno>4.6.7. </span>Browser state</h4>
+
+  <p>The <dfn id=navigator.online
+   title=dom-navigator-onLine><code>navigator.onLine</code></dfn> attribute
+   must return false if the user agent will not contact the network when the
+   user follows links or when a script requests a remote page (or knows that
+   such an attempt would fail), and must return true otherwise.
+
+  <p>When the value that would be returned by the <code
+   title=dom-navigator-onLine><a
+   href="#navigator.online">navigator.onLine</a></code> attribute of the
+   <code><a href="#window">Window</a></code> changes from true to false, the
+   user agent must <a href="#firing2">fire a simple event</a> called <dfn
+   id=offline0 title=event-offline><code>offline</code></dfn> at <a
+   href="#the-body0">the body element</a>.
+
+  <p>On the other hand, when the value that would be returned by the <code
+   title=dom-navigator-onLine><a
+   href="#navigator.online">navigator.onLine</a></code> attribute of the
+   <code><a href="#window">Window</a></code> changes from false to true, the
+   user agent must <a href="#firing2">fire a simple event</a> called <dfn
+   id=online0 title=event-online><code>online</code></dfn> at <a
+   href="#the-body0">the body element</a>.</p>
+  <!-- XXX ononline onoffline need to be defined -->
+
+  <h3 id=history><span class=secno>4.7. </span>Session history and navigation</h3>
+
+  <h4 id=the-session><span class=secno>4.7.1. </span>The session history of
    browsing contexts</h4>
 
   <p>The sequence of <code>Document</code>s in a <a
@@ -25856,11 +27278,11 @@
    there are no state object entries for that <code>Document</code> object
    then no entries are removed.
 
-  <h4 id=the-history><span class=secno>4.6.2. </span>The <code><a
+  <h4 id=the-history><span class=secno>4.7.2. </span>The <code><a
    href="#history1">History</a></code> interface</h4>
 
   <pre class=idl>interface <dfn id=history1>History</dfn> {
-  readonly attribute long <a href="#length6" title=dom-history-length>length</a>;
+  readonly attribute long <a href="#length7" title=dom-history-length>length</a>;
   void <a href="#godelta" title=dom-history-go>go</a>(in long delta);
   void <a href="#go" title=dom-history-go-0>go</a>();
   void <a href="#back" title=dom-history-back>back</a>();
@@ -25870,7 +27292,7 @@
   void <a href="#clearstate" title=dom-history-clearState>clearState</a>();
 };</pre>
 
-  <p>The <dfn id=length6 title=dom-history-length><code>length</code></dfn>
+  <p>The <dfn id=length7 title=dom-history-length><code>length</code></dfn>
    attribute of the <code><a href="#history1">History</a></code> interface
    must return the number of entries in this <a href="#session">session
    history</a>.
@@ -25883,7 +27305,7 @@
 
   <p>If the index of the <a href="#current0">current entry</a> plus <var
    title="">delta</var> is less than zero or greater than or equal to the <a
-   href="#length6" title=dom-history-length>number of items in the session
+   href="#length7" title=dom-history-length>number of items in the session
    history</a>, then the user agent must do nothing.
 
   <p>If the <var title="">delta</var> is zero, then the user agent must act
@@ -25898,7 +27320,8 @@
    title="">delta</var>.
 
   <p>When a user agent is required to <dfn id=traverse>traverse the
-   history</dfn> to a specified entry, the user agent must act as follows:
+   history</dfn><!-- (traversal) --> to a specified entry, the user agent
+   must act as follows:
 
   <ol>
    <li>If there is no longer a <code>Document</code> object for the entry in
@@ -25962,9 +27385,13 @@
         href="#browsing1">browsing context name</a> must be unset.
       </ol>
 
-     <li>The user agent must make the <a href="#specified">specified
-      entry</a>'s <code>Document</code> object the <a href="#active">active
-      document</a> of the <a href="#browsing0">browsing context</a>.
+     <li id=appcache-history-2>The user agent must make the <a
+      href="#specified">specified entry</a>'s <code>Document</code> object
+      the <a href="#active">active document</a> of the <a
+      href="#browsing0">browsing context</a>. (If it is a <a
+      href="#top-level">top-level browsing context</a>, this might <a
+      href="#appcache-history-1">change which <span>application cache</span>
+      it is associated with.)</a>
 
      <li>If the <a href="#specified">specified entry</a> has a <a
       href="#browsing1">browsing context name</a> stored with it, then the
@@ -26061,17 +27488,16 @@
   <p>When this method is invoked, the user agent must first check the third
    argument. If a third argument is specified, then the user agent must
    verify that the third argument is a valid URI or IRI (as defined by RFC
-   3986 and 3987, and as modified by RFC 2732), and if so, that, after
-   resolving it to an absolute URI, it is either identical to the document's
-   URI, or that it differs from the document's URI only in the <query>,
-   <abs_path>, and/or <fragment> parts, as applicable (the
-   <query> and <abs_path> parts can only be the same if the
-   document's URI uses a hierarchical <scheme>). If the verification
-   fails (either because the argument is syntactically incorrect, or differs
-   in a way not described as acceptable in the previous sentence) then the
-   user agent must raise a <a href="#security8">security exception</a>. <a
-   href="#refsRFC3986">[RFC3986]</a> <a href="#refsRFC3987">[RFC3987]</a> <a
-   href="#refsRFC2732">[RFC2732]</a>
+   3986 and 3987), and if so, that, after resolving it to an absolute URI, it
+   is either identical to the document's URI, or that it differs from the
+   document's URI only in the <query>, <abs_path>, and/or
+   <fragment> parts, as applicable (the <query> and
+   <abs_path> parts can only be the same if the document's URI uses a
+   hierarchical <scheme>). If the verification fails (either because
+   the argument is syntactically incorrect, or differs in a way not described
+   as acceptable in the previous sentence) then the user agent must raise a
+   <a href="#security8">security exception</a>. <a
+   href="#refsRFC3986">[RFC3986]</a> <a href="#refsRFC3987">[RFC3987]</a>
 
   <p>If the third argument passes its verification step, or if the third
    argument was omitted, then the user agent must remove from the <a
@@ -26118,7 +27544,7 @@
    the last entry for that <code>Document</code> object in the session
    history.
 
-  <h4 id=activating><span class=secno>4.6.3. </span><dfn id=activating0
+  <h4 id=activating><span class=secno>4.7.3. </span><dfn id=activating0
    title="activate the state object">Activating state objects</dfn></h4>
 
   <p>When a state object in the session history is activated (which happens
@@ -26153,7 +27579,7 @@
   <p class=big-issue>Should we coalesce these events if they occur while the
    page is away? (e.g. during traversal -- see above)
 
-  <h4 id=the-location><span class=secno>4.6.4. </span>The <code><a
+  <h4 id=the-location><span class=secno>4.7.4. </span>The <code><a
    href="#location2">Location</a></code> interface</h4>
 
   <p>Each <code>Document</code> object in a browsing context's session
@@ -26275,7 +27701,7 @@
 user reload must be equivalent to .reload()
 -->
 
-  <h5 id=security4><span class=secno>4.6.4.1. </span>Security</h5>
+  <h5 id=security4><span class=secno>4.7.4.1. </span>Security</h5>
 
   <p>User agents must raise a <a href="#security8">security exception</a>
    whenever any of the members of a <code><a
@@ -26293,7 +27719,7 @@
    title=dom-location-href><a href="#href5">href</a></code> attribute's
    setter.
 
-  <h4 id=history-notes><span class=secno>4.6.5. </span>Implementation notes
+  <h4 id=history-notes><span class=secno>4.7.5. </span>Implementation notes
    for session history</h4>
 
   <p><em>This section is non-normative.</em>
@@ -26332,7 +27758,7 @@
    that are invoked on a timer, or from event handlers that do not represent
    a clear user action, or that are invoked in rapid succession.
 
-  <h3 id=navigating><span class=secno>4.7. </span>Navigating across documents</h3>
+  <h3 id=navigating><span class=secno>4.8. </span>Navigating across documents</h3>
 
   <p>Certain actions cause the <a href="#browsing0">browsing context</a> to
    <dfn id=navigate>navigate</dfn>. For example, <a href="#following0"
@@ -26363,8 +27789,9 @@
      of the supported protocols, or an inline prompt to allow the user to
      select <a href="#registerprotocolhandler"
      title=dom-navigator-registerProtocolHandler>a registered handler</a> for
-     the given scheme, then <a href="#display" title="display a user agent
-     page inline">display the inline content</a> and abort these steps.
+     the given scheme, then <a href="#page-load4"
+     title=navigate-ua-inline>display the inline content</a> and abort these
+     steps.
 
    <li>
     <p>If the new resource is to be handled using a mechanism that does not
@@ -26372,12 +27799,40 @@
      that mechanism instead.
 
    <li>
-    <p>Start fetching the specified resource, as appropriate (e.g. performing
-     an HTTP GET or POST operation, or reading the file from disk, or
-     executing script in the case of a <a href="#the-javascript"
-     title="javascript protocol"><code title="">javascript:</code> URI</a>).
-     If this results in a redirect, return to step 2 with the new resource.
+    <p>If the new resource is to be fetched using HTTP GET or equivalent, and
+     if the browsing context being navigated is a <a
+     href="#top-level">top-level browsing context</a>, then check if there
+     are any <a href="#application0" title="application cache">application
+     caches</a> that have a <a href="#the-manifest"
+     title=concept-appcache-manifest>manifest</a> with the <a
+     href="#same-schemehostport">same scheme/host/port</a> as the URI in
+     question, and that have this URI as one of their entries (excluding
+     entries marked as <a href="#foreign"
+     title=concept-appcache-foreign>manifest</a>), and that already contain
+     their manifest, categorised as a <a href="#the-manifest"
+     title=concept-appcache-manifest>manifest</a>. If so, then the user agent
+     must then fetch the resource from the <a href="#select0"
+     title=concept-appcache-selection>most appropriate application cache</a>
+     of those that match.</p>
 
+    <p>Otherwise, start fetching the specified resource in the appropriate
+     manner (e.g. performing an HTTP GET or POST operation, or reading the
+     file from disk, or executing script in the case of a <a
+     href="#the-javascript" title="javascript protocol"><code
+     title="">javascript:</code> URI</a>). If this results in a redirect,
+     return to step 2 with the new resource.</p>
+
+    <p class=example>For example, imagine an HTML page with an associated
+     application cache displaying an image and a form, where the image is
+     also used by several other application caches. If the user right-clicks
+     on the image and chooses "View Image", then the user agent could decide
+     to show the image from any of those caches, but it is likely that the
+     most useful cache for the user would be the one that was used for the
+     aforementioned HTML page. On the other hand, if the user submits the
+     form, and the form does a POST submission, then the user agent will not
+     use an application cache at all; the submission will be made to the
+     network.</p>
+
    <li>
     <p>Wait for one or more bytes to be available or for the user agent to
      establish that the resource in question is empty. During this time, the
@@ -26385,6 +27840,39 @@
      other navigation attempts.
 
    <li>
+    <p>If the resource was not fetched from an <a
+     href="#application0">application cache</a>, and was to be fetched using
+     HTTP GET or equivalent, and its URI <a href="#matches"
+     title=concept-appcache-matches-oppcache>matches the opportunistic
+     caching namespace</a> of one or more application caches, then:</p>
+
+    <dl class=switch>
+     <dt>If the file was successfully downloaded
+
+     <dd>The user agent must cache the resource in all those application
+      caches, categorised as <a href="#opportunistically"
+      title=concept-appcache-oppcache>opportunistically cached entries</a>.
+
+     <dt>If the server returned a 4xx or 5xx status code or equivalent, or
+      there were network errors
+
+     <dd>If the browsing context being navigated is a <a
+      href="#top-level">top-level browsing context</a>, then the user agent
+      must discard the failed load and instead use the <a href="#fallback0"
+      title=concept-appcache-fallback>fallback resource</a> specified for the
+      opportunistic caching namespace in question. If multiple application
+      caches match, the user agent must use the fallback of the <a
+      href="#select0" title=concept-appcache-selection>most appropriate
+      application cache</a> of those that match. For the purposes of session
+      history (and features that depend on session history, e.g. bookmarking)
+      the user agent must use the URI of the resource that was requested (the
+      one that matched the opportunistic caching namespace), not the fallback
+      resource. However, the user agent may indicate to the user that the
+      original page load failed, that the page used was a fallback resource,
+      and what the URI of the fallback resource actually is.
+    </dl>
+
+   <li>
     <p>If the document's out-of-band metadata (e.g. HTTP headers), not
      counting any <a href="#content-type8" title=Content-Type>type
      information</a> (such as the Content-Type HTTP header), requires some
@@ -26458,8 +27946,9 @@
      supported, or an inline prompt to allow the user to select <a
      href="#registercontenthandler"
      title=dom-navigator-registerContentHandler>a registered handler</a> for
-     the given type, then <a href="#display" title="display a user agent page
-     inline">display the inline content</a> and abort these steps.
+     the given type, then <a href="#page-load4"
+     title=navigate-ua-inline>display the inline content</a> and abort these
+     steps.
 
    <li>
     <p>Otherwise, the document's <var title="">type</var> is such that the
@@ -26469,7 +27958,7 @@
   </ol>
 
   <p>Some of the sections below, to which the above algorithm defers in
-   certain cases, require the user agent to <dfn id=update0>update the
+   certain cases, require the user agent to <dfn id=update2>update the
    session history with the new page</dfn>. When a user agent is required to
    do this, it must follows the set of steps given below that is appropriate
    for the situation at hand. From the point of view of any script, these
@@ -26533,7 +28022,7 @@
     </dl>
   </ol>
 
-  <h4 id=read-html><span class=secno>4.7.1. </span><dfn id=page-load
+  <h4 id=read-html><span class=secno>4.8.1. </span><dfn id=page-load
    title=navigate-html>Page load processing model for HTML files</dfn></h4>
 
   <p>When an HTML document is to be loaded in a <a href="#browsing0">browsing
@@ -26544,10 +28033,11 @@
    the <a href="#input0">input stream</a> for that parser.
 
   <p class=note>The <a href="#input0">input stream</a> converts bytes into
-   characters for use in the <span>tokeniser</span>. This process relies, in
-   part, on character encoding information found in the real <a
-   href="#content-type8" title=Content-Type>Content-Type metadata</a> of the
-   resource; the "sniffed type" is not used for this purpose.</p>
+   characters for use in the <span>tokeniser</span><!-- XXX xref
+  -->. This
+   process relies, in part, on character encoding information found in the
+   real <a href="#content-type8" title=Content-Type>Content-Type metadata</a>
+   of the resource; the "sniffed type" is not used for this purpose.</p>
   <!-- next two paragraphs are nearly identical to the navigate-text
   section, keep them in sync -->
 
@@ -26557,9 +28047,13 @@
 
   <p>After creating the <code>Document</code> object, but potentially before
    the page has finished parsing, the user agent must <a
-   href="#update0">update the session history with the new page</a>.
+   href="#update2">update the session history with the new page</a>.
 
-  <h4 id=read-xml><span class=secno>4.7.2. </span><dfn id=page-load0
+  <p class=note><a href="#application2"
+   title=concept-appcache-init-with-attribute>Application cache selection</a>
+   happens <a href="#parser-appcache">in the HTML parser</a>.
+
+  <h4 id=read-xml><span class=secno>4.8.2. </span><dfn id=page-load0
    title=navigate-xml>Page load processing model for XML files</dfn></h4>
 
   <p>When faced with displaying an XML file inline, user agents must first
@@ -26574,6 +28068,30 @@
    that must be used when determining the character encoding according to the
    rules given in the above specifications.
 
+  <p>If the root element, as parsed according to the XML specifications cited
+   above, is found to be an <code><a href="#html">html</a></code> element
+   with an attribute <code title=attr-html-application>application</code>,
+   then, as soon as the element is inserted into the DOM, the user agent must
+   run the <a href="#application2"
+   title=concept-appcache-init-with-attribute>application cache selection
+   algorithm</a> with the value of that attribute as the manifest URI.
+   Otherwise, as soon as the root element is inserted into the DOM, the user
+   agent must run the <a href="#application3"
+   title=concept-appcache-init-no-attribute>application cache selection
+   algorithm</a> with no manifest.
+
+  <p class=note>Because the processing of the <code
+   title=attr-html-application>application</code> attribute happens only once
+   the root element is parsed, any URIs referenced by processing instructions
+   before the root element (such as <code
+   title=""><?xml-styleesheet?></code> and <code
+   title=""><?xbl?></code> PIs) will be fetched from the network and
+   cannot be cached.</p>
+  <!-- XXX any ideas for avoiding this, that
+  aren't a PI themselves? We can't delay the processing, since the
+  whole point of the <?xbl?> PI is to have the XBL sheet loaded before
+  the root element... -->
+
   <p>User agents may examine the namespace of the root <code>Element</code>
    node of this <code>Document</code> object to perform namespace-based
    dispatch to alternative processing tools, e.g. determining that the
@@ -26583,14 +28101,14 @@
    href="#navigate">navigate</a> steps above.
 
   <p>Otherwise, then, with the newly created <code>Document</code>, the user
-   agents must <a href="#update0">update the session history with the new
+   agents must <a href="#update2">update the session history with the new
    page</a>. User agents may do this before the complete document has been
    parsed (thus achieving <i>incremental rendering</i>).
 
   <p>Error messages from the parse process (e.g. namespace well-formedness
    errors) may be reported inline by mutating the <code>Document</code>.
 
-  <h4 id=read-text><span class=secno>4.7.3. </span><dfn id=page-load1
+  <h4 id=read-text><span class=secno>4.8.3. </span><dfn id=page-load1
    title=navigate-text>Page load processing model for text files</dfn></h4>
 
   <p>When a plain text document is to be loaded in a <a
@@ -26606,9 +28124,14 @@
   <p>The rules for how to convert the bytes of the plain text document into
    actual characters are defined in RFC 2046, RFC 2646, and subsequent
    versions thereof. <a href="#refsRFC2046">[RFC2046]</a> <a
-   href="#refsRFC2046">[RFC2646]</a></p>
+   href="#refsRFC2046">[RFC2646]</a>
+
+  <p>Upon creation of the <code>Document</code> object, the user agent must
+   run the <a href="#application3"
+   title=concept-appcache-init-no-attribute>application cache selection
+   algorithm</a> with no manifest.</p>
   <!-- next two paragraphs are nearly identical to the navigate-html
-  section and similar to the "non-DOM-inline-content" section, and the
+  section and similar to the "navigate-ua-inline" section, and the
   next three are similar to the navigate-image and navigate-plugin
   sections; keep them all in sync -->
 
@@ -26618,14 +28141,14 @@
 
   <p>After creating the <code>Document</code> object, but potentially before
    the page has finished parsing, the user agent must <a
-   href="#update0">update the session history with the new page</a>.
+   href="#update2">update the session history with the new page</a>.
 
   <p>User agents may add content to the <code><a href="#head">head</a></code>
    element of the <code>Document</code>, e.g. linking to stylesheet or an XBL
    binding, providing script, giving the document a <code><a
    href="#title1">title</a></code>, etc.
 
-  <h4 id=read-image><span class=secno>4.7.4. </span><dfn id=page-load2
+  <h4 id=read-image><span class=secno>4.8.4. </span><dfn id=page-load2
    title=navigate-image>Page load processing model for images</dfn></h4>
 
   <p>When an image resource is to be loaded in a <a
@@ -26646,9 +28169,14 @@
   <p>Then, the user agent must act as if it had <a href="#stops" title="stop
    parsing">stopped parsing</a>.
 
+  <p>Upon creation of the <code>Document</code> object, the user agent must
+   run the <a href="#application3"
+   title=concept-appcache-init-no-attribute>application cache selection
+   algorithm</a> with no manifest.
+
   <p>After creating the <code>Document</code> object, but potentially before
    the page has finished fully loading, the user agent must <a
-   href="#update0">update the session history with the new page</a>.
+   href="#update2">update the session history with the new page</a>.
 
   <p>User agents may add content to the <code><a href="#head">head</a></code>
    element of the <code>Document</code>, or attributes to the <code><a
@@ -26656,7 +28184,7 @@
    binding, to provide a script, to give the document a <code><a
    href="#title1">title</a></code>, etc.
 
-  <h4 id=read-plugin><span class=secno>4.7.5. </span><dfn id=page-load3
+  <h4 id=read-plugin><span class=secno>4.8.5. </span><dfn id=page-load3
    title=navigate-plugin>Page load processing model for content that uses
    plugins</dfn></h4>
 
@@ -26678,9 +28206,14 @@
   <p>Then, the user agent must act as if it had <a href="#stops" title="stop
    parsing">stopped parsing</a>.
 
+  <p>Upon creation of the <code>Document</code> object, the user agent must
+   run the <a href="#application3"
+   title=concept-appcache-init-no-attribute>application cache selection
+   algorithm</a> with no manifest.
+
   <p>After creating the <code>Document</code> object, but potentially before
    the page has finished fully loading, the user agent must <a
-   href="#update0">update the session history with the new page</a>.
+   href="#update2">update the session history with the new page</a>.
 
   <p>User agents may add content to the <code><a href="#head">head</a></code>
    element of the <code>Document</code>, or attributes to the <code><a
@@ -26688,28 +28221,34 @@
    XBL binding, or to give the document a <code><a
    href="#title1">title</a></code>.
 
-  <h4 id=non-DOM-inline-content><span class=secno>4.7.6. </span>Page load
-   processing model for inline content that doesn't have a DOM</h4>
+  <h4 id=read-ua-inline><span class=secno>4.8.6. </span><dfn id=page-load4
+   title=navigate-ua-inline>Page load processing model for inline content
+   that doesn't have a DOM</dfn></h4>
 
-  <p>When the user agent is to <dfn id=display>display a user agent page
-   inline</dfn> in a <a href="#browsing0">browsing context</a>, the user
-   agent should create a <code>Document</code> object, mark it as being an <a
-   href="#html-" title="HTML documents">HTML document</a>, and then either
-   associate that <code>Document</code> with a custom rendering that is not
-   rendered using the normal <code>Document</code> rendering rules, or mutate
-   that <code>Document</code> until it represents the content the user agent
-   wants to render.</p>
+  <p>When the user agent is to display a user agent page inline in a <a
+   href="#browsing0">browsing context</a>, the user agent should create a
+   <code>Document</code> object, mark it as being an <a href="#html-"
+   title="HTML documents">HTML document</a>, and then either associate that
+   <code>Document</code> with a custom rendering that is not rendered using
+   the normal <code>Document</code> rendering rules, or mutate that
+   <code>Document</code> until it represents the content the user agent wants
+   to render.</p>
   <!-- next two paragraphs are similar to the navigate-text section,
   keep them in sync -->
 
   <p>Once the page has been set up, the user agent must act as if it had <a
    href="#stops" title="stop parsing">stopped parsing</a>.
 
+  <p>Upon creation of the <code>Document</code> object, the user agent must
+   run the <a href="#application3"
+   title=concept-appcache-init-no-attribute>application cache selection
+   algorithm</a> with no manifest.
+
   <p>After creating the <code>Document</code> object, but potentially before
    the page has been completely set up, the user agent must <a
-   href="#update0">update the session history with the new page</a>.
+   href="#update2">update the session history with the new page</a>.
 
-  <h4 id=scroll-to-fragid><span class=secno>4.7.7. </span><dfn id=scrolling0
+  <h4 id=scroll-to-fragid><span class=secno>4.8.7. </span><dfn id=scrolling0
    title=navigate-fragid>Scrolling to a fragment identifier</dfn></h4>
 
   <p>When a user agent is supposed to scroll for a fragment identifier, then
@@ -26717,7 +28256,7 @@
 
   <ol>
    <li>
-    <p>First, <a href="#update0">update the session history with the new
+    <p>First, <a href="#update2">update the session history with the new
      page</a>, where "the new page" has the same <code>Document</code> as
      before but with the URI having the newly specified fragment identifier.
 
@@ -26731,7 +28270,7 @@
    the document</dfn>" from a frag id -- id="", name="", XPointer, etc;
    missing IDs (e.g. the infamous "#top")
 
-  <h3 id=content-type-sniffing><span class=secno>4.8. </span>Determining the
+  <h3 id=content-type-sniffing><span class=secno>4.9. </span>Determining the
    type of a new resource in a browsing context</h3>
 
   <p class=warning>It is imperative that the rules in this section be
@@ -26828,7 +28367,7 @@
      type</var>.
   </ol>
 
-  <h4 id=content-type0><span class=secno>4.8.1. </span><dfn
+  <h4 id=content-type0><span class=secno>4.9.1. </span><dfn
    id=content-type4>Content-Type sniffing: text or binary</dfn></h4>
 
   <ol>
@@ -26918,7 +28457,7 @@
     <p>Otherwise, the sniffed type of the resource is "text/plain".
   </ul>
 
-  <h4 id=content-type1><span class=secno>4.8.2. </span><dfn
+  <h4 id=content-type1><span class=secno>4.9.2. </span><dfn
    id=content-type5>Content-Type sniffing: unknown type</dfn></h4>
 
   <ol>
@@ -27170,7 +28709,7 @@
    determine that content is not HTML and thus safe from XSS attacks, but
    then a user agent detects it as HTML anyway and allows script to execute).
 
-  <h4 id=content-type2><span class=secno>4.8.3. </span><dfn
+  <h4 id=content-type2><span class=secno>4.9.3. </span><dfn
    id=content-type6>Content-Type sniffing: image</dfn></h4>
 
   <p>If the first bytes of the file match one of the byte sequences in the
@@ -27232,7 +28771,7 @@
   <p>Otherwise, the <i>sniffed type</i> of the resource is the same as its
    <var title="">official type</var>.
 
-  <h4 id=content-type3><span class=secno>4.8.4. </span><dfn
+  <h4 id=content-type3><span class=secno>4.9.4. </span><dfn
    id=content-type7>Content-Type sniffing: feed or HTML</dfn></h4>
   <!-- mostly based on:
    http://blogs.msdn.com/rssteam/articles/PublishersGuide.aspx
@@ -27402,7 +28941,7 @@
    this algorithm and the algorithm for detecting the character encoding of
    HTML documents in parallel.
 
-  <h4 id=content-type><span class=secno>4.8.5. </span>Content-Type metadata</h4>
+  <h4 id=content-type><span class=secno>4.9.5. </span>Content-Type metadata</h4>
 
   <p>What explicit <dfn id=content-type8 title=Content-Type>Content-Type
    metadata</dfn> is associated with the resource (the resource's type
@@ -27486,10 +29025,10 @@
     </dl>
   </ol>
 
-  <h3 id=storage><span class=secno>4.9. </span>Client-side session and
+  <h3 id=storage><span class=secno>4.10. </span>Client-side session and
    persistent storage of name/value pairs</h3>
 
-  <h4 id=introduction1><span class=secno>4.9.1. </span>Introduction</h4>
+  <h4 id=introduction2><span class=secno>4.10.1. </span>Introduction</h4>
 
   <p><em>This section is non-normative.</em>
 
@@ -27597,12 +29136,12 @@
    To store structured data in a storage area, you must first convert it to a
    string.
 
-  <h4 id=the-storage><span class=secno>4.9.2. </span>The <code><a
+  <h4 id=the-storage><span class=secno>4.10.2. </span>The <code><a
    href="#storage2">Storage</a></code> interface</h4>
 
   <pre class=idl>
 interface <dfn id=storage2>Storage</dfn> {
-  readonly attribute unsigned long <a href="#length7" title=dom-Storage-length>length</a>;
+  readonly attribute unsigned long <a href="#length8" title=dom-Storage-length>length</a>;
   DOMString <a href="#keyn" title=dom-Storage-key>key</a>(in unsigned long index);
   <a href="#storageitem">StorageItem</a> <a href="#getitem" title=dom-Storage-getItem>getItem</a>(in DOMString key);
   void <a href="#setitem" title=dom-Storage-setItem>setItem</a>(in DOMString key, in DOMString data);
@@ -27634,16 +29173,17 @@
    the script in question is running in a <span>secure browsing
    context</span><!-- XXX xref -->.
 
-  <p>The <dfn id=length7 title=dom-Storage-length><code>length</code></dfn>
+  <p>The <dfn id=length8 title=dom-Storage-length><code>length</code></dfn>
    attribute must return the number of key/value pairs currently present and
    <a href="#accessible" title="accessible keys">accessible</a> in the list
    associated with the object.
 
   <p>The <dfn id=keyn title=dom-Storage-key><code>key(<var
    title="">n</var>)</code></dfn> method must return the name of the <var
-   title="">n</var>th <span>accessible</span> key in the list. The order of
-   keys is user-agent defined, but must be consistent within an object
-   between changes to the number of keys. (Thus, <a href="#setitem"
+   title="">n</var>th <a href="#accessible" title="accessible
+   keys">accessible</a> key in the list. The order of keys is user-agent
+   defined, but must be consistent within an object between changes to the
+   number of keys. (Thus, <a href="#setitem"
    title=dom-Storage-setItem>adding</a> or <a href="#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.)
@@ -27660,12 +29200,14 @@
    href="#storageitem">StorageItem</a></code> object representing the
    key/value pair with the given <var title="">key</var>. If the given <var
    title="">key</var> does not exist in the list associated with the object,
-   or is not <span>accessible</span>, then this method must return null.
-   Subsequent calls to this method with the same key from scripts running in
-   the same <span>security context</span> must return the same instance of
-   the <code><a href="#storageitem">StorageItem</a></code> interface. (Such
-   instances must not be shared across security contexts, though.)</p>
-  <!-- XXX define security context -->
+   or is not <a href="#accessible" title="accessible keys">accessible</a>,
+   then this method must return null. Subsequent calls to this method with
+   the same key from scripts running in the same <span>security
+   context</span> must return the same instance of the <code><a
+   href="#storageitem">StorageItem</a></code> interface. (Such instances must
+   not be shared across security contexts, though.)</p>
+  <!-- XXX define
+  security context -->
 
   <p>The <dfn id=setitem title=dom-Storage-setItem><code>setItem(<var
    title="">key</var>, <var title="">value</var>)</code></dfn> method must
@@ -27683,12 +29225,13 @@
    "safe for both secure and insecure content".
 
   <p>If the given <var title="">key</var> <em>does</em> exist in the list,
-   then, if the key/value pair with the given <var title="">key</var> is
-   <span>accessible</span>, it must have its value updated so that any
-   current or future <code><a href="#storageitem">StorageItem</a></code>
-   objects referring to this key/value pair will return the value given in
-   the <var title="">value</var> argument. If it is <em>not</em>
-   <span>accessible</span>, the method must raise a <a
+   then, if the key/value pair with the given <var title="">key</var> is <a
+   href="#accessible" title="accessible keys">accessible</a>, it must have
+   its value updated so that any current or future <code><a
+   href="#storageitem">StorageItem</a></code> objects referring to this
+   key/value pair will return the value given in the <var
+   title="">value</var> argument. If it is <em>not</em> <a href="#accessible"
+   title="accessible keys">accessible</a>, the method must raise a <a
    href="#security8">security exception</a>.
 
   <p>When the <code title=dom-Storage-setItem><a
@@ -27708,10 +29251,11 @@
    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 and is <span>accessible</span>. If no item
-   with that key exists, the method must do nothing. If an item with that key
-   exists but is not <span>accessible</span>, the method must raise a <a
-   href="#security8">security exception</a>.
+   with the object, if it exists and is <a href="#accessible"
+   title="accessible keys">accessible</a>. If no item with that key exists,
+   the method must do nothing. If an item with that key exists but is not <a
+   href="#accessible" title="accessible keys">accessible</a>, the method must
+   raise a <a href="#security8">security exception</a>.
 
   <p>The <code title=dom-Storage-setItem><a
    href="#setitem">setItem()</a></code> and <code
@@ -27722,20 +29266,21 @@
 
   <p>In the ECMAScript DOM binding, enumerating a <code><a
    href="#storage2">Storage</a></code> object must enumerate through the
-   currently stored and <span>accessible</span> keys in the list the object
-   is associated with. (It must not enumerate the values or the actual
-   members of the interface). In the ECMAScript DOM binding, <code><a
-   href="#storage2">Storage</a></code> objects must support dereferencing
-   such that getting a property that is not a member of the object (i.e. is
-   neither a member of the <code><a href="#storage2">Storage</a></code>
-   interface nor of <code title=dom-Object>Object</code>) must invoke the
-   <code title=dom-Storage-getItem><a href="#getitem">getItem()</a></code>
-   method with the property's name as the argument, and setting such a
-   property must invoke the <code title=dom-Storage-setItem><a
+   currently stored and <a href="#accessible" title="accessible
+   keys">accessible</a> keys in the list the object is associated with. (It
+   must not enumerate the values or the actual members of the interface). In
+   the ECMAScript DOM binding, <code><a href="#storage2">Storage</a></code>
+   objects must support dereferencing such that getting a property that is
+   not a member of the object (i.e. is neither a member of the <code><a
+   href="#storage2">Storage</a></code> interface nor of <code
+   title=dom-Object>Object</code>) must invoke the <code
+   title=dom-Storage-getItem><a href="#getitem">getItem()</a></code> method
+   with the property's name as the argument, and setting such a property must
+   invoke the <code title=dom-Storage-setItem><a
    href="#setitem">setItem()</a></code> method with the property's name as
    the first argument and the given value as the second argument.
 
-  <h4 id=the-storageitem><span class=secno>4.9.3. </span>The <code><a
+  <h4 id=the-storageitem><span class=secno>4.10.3. </span>The <code><a
    href="#storageitem">StorageItem</a></code> interface</h4>
 
   <p>Items in <code><a href="#storage2">Storage</a></code> objects are
@@ -27801,7 +29346,7 @@
    the key/value pair would no longer appear in the appropriate <code><a
    href="#storage2">Storage</a></code> object.
 
-  <h4 id=the-sessionstorage><span class=secno>4.9.4. </span>The <code
+  <h4 id=the-sessionstorage><span class=secno>4.10.4. </span>The <code
    title=dom-sessionStorage><a
    href="#sessionstorage">sessionStorage</a></code> attribute</h4>
 
@@ -27874,7 +29419,7 @@
    title=event-storage><a href="#storage3">storage</a></code> event must be
    fired, as <a href="#storage3" title=event-storage>described below</a>.
 
-  <h4 id=the-globalstorage><span class=secno>4.9.5. </span>The <code
+  <h4 id=the-globalstorage><span class=secno>4.10.5. </span>The <code
    title=dom-globalStorage><a href="#globalstorage">globalStorage</a></code>
    attribute</h4>
 
@@ -28033,7 +29578,7 @@
     global storage area is notified of the change.</p>
   </div>
 
-  <h4 id=the-storage0><span class=secno>4.9.6. </span>The <code
+  <h4 id=the-storage0><span class=secno>4.10.6. </span>The <code
    title=event-storage><a href="#storage3">storage</a></code> event</h4>
 
   <p>The <dfn id=storage3 title=event-storage><code>storage</code></dfn>
@@ -28090,10 +29635,10 @@
    "<code>#session</code>" if it was a session storage area.</p>
   <!-- XXX onstorage should be defined -->
 
-  <h4 id=miscellaneous0><span class=secno>4.9.7. </span>Miscellaneous
+  <h4 id=miscellaneous0><span class=secno>4.10.7. </span>Miscellaneous
    implementation requirements for storage areas</h4>
 
-  <h5 id=disk-space><span class=secno>4.9.7.1. </span>Disk space</h5>
+  <h5 id=disk-space><span class=secno>4.10.7.1. </span>Disk space</h5>
 
   <p>User agents should limit the total amount of space allowed for a domain
    based on the domain of the page setting the value.
@@ -28125,14 +29670,14 @@
    Implementation feedback is welcome and will be used to update this
    suggestion in future.
 
-  <h5 id=threads0><span class=secno>4.9.7.2. </span>Threads</h5>
+  <h5 id=threads0><span class=secno>4.10.7.2. </span>Threads</h5>
 
   <p>Multiple browsing contexts must be able to access the global storage
    areas simultaneously in a predictable manner. Scripts must not be able to
    detect any concurrent script execution.
 
   <p>This is required to guarentee that the <code title=dom-Storage-length><a
-   href="#length7">length</a></code> attribute of a <code><a
+   href="#length8">length</a></code> attribute of a <code><a
    href="#storage2">Storage</a></code> object never changes while a script is
    executing, other than in a way that is predictable by the script itself.
 
@@ -28149,9 +29694,9 @@
    specification does not require any particular implementation strategy, so
    long as the requirement above is met.
 
-  <h4 id=security5><span class=secno>4.9.8. </span>Security and privacy</h4>
+  <h4 id=security5><span class=secno>4.10.8. </span>Security and privacy</h4>
 
-  <h5 id=user-tracking><span class=secno>4.9.8.1. </span>User tracking</h5>
+  <h5 id=user-tracking><span class=secno>4.10.8.1. </span>User tracking</h5>
 
   <p>A third-party advertiser (or any entity capable of getting content
    distributed to multiple sites) could use a unique identifier stored in its
@@ -28285,7 +29830,7 @@
    headers and configuration settings) to combine separate sessions into
    coherent user profiles.
 
-  <h5 id=cookie><span class=secno>4.9.8.2. </span>Cookie resurrection</h5>
+  <h5 id=cookie><span class=secno>4.10.8.2. </span>Cookie resurrection</h5>
 
   <p>If the user interface for persistent storage presents data in the
    persistent storage feature separately from data in HTTP session cookies,
@@ -28293,7 +29838,7 @@
    allow sites to use the two features as redundant backup for each other,
    defeating a user's attempts to protect his privacy.
 
-  <h5 id=integrity><span class=secno>4.9.8.3. </span>Integrity of "public"
+  <h5 id=integrity><span class=secno>4.10.8.3. </span>Integrity of "public"
    storage areas</h5>
 
   <p>Since the "<a href="#public0" title="public storage area">public</a>"
@@ -28307,7 +29852,7 @@
    must not trust information stored in "<a href="#public0" title="public
    storage area">public</a>" global storage areas.
 
-  <h5 id=cross-protocol><span class=secno>4.9.8.4. </span>Cross-protocol and
+  <h5 id=cross-protocol><span class=secno>4.10.8.4. </span>Cross-protocol and
    cross-port attacks</h5>
 
   <p>This API makes no distinction between content served over HTTP, FTP, or
@@ -28347,7 +29892,7 @@
    with no further interaction. How about putting the port number at the end
    of the string being compared? (Implicitly.)
 
-  <h5 id=dns-spoofing><span class=secno>4.9.8.5. </span>DNS spoofing attacks</h5>
+  <h5 id=dns-spoofing><span class=secno>4.10.8.5. </span>DNS spoofing attacks</h5>
 
   <p>Because of the potential for DNS spoofing attacks, one cannot guarentee
    that a host claiming to be in a certain domain really is from that domain.
@@ -28361,7 +29906,7 @@
    condition, data stored by scripts in secure contexts default to being
    marked as "safe only for secure content".)
 
-  <h5 id=cross-directory><span class=secno>4.9.8.6. </span>Cross-directory
+  <h5 id=cross-directory><span class=secno>4.10.8.6. </span>Cross-directory
    attacks</h5>
 
   <p>Different authors sharing one host name, for example users hosting
@@ -28375,7 +29920,7 @@
    usual DOM scripting security model would make it trivial to bypass this
    protection and access the data from any path.
 
-  <h5 id=public><span class=secno>4.9.8.7. </span>Public storage areas
+  <h5 id=public><span class=secno>4.10.8.7. </span>Public storage areas
    corresponding to hosts</h5>
 
   <p>If a "<a href="#public0" title="public storage area">public</a>" global
@@ -28391,9 +29936,9 @@
    to "<a href="#public0" title="public storage area">public</a>" global
    storage areas from accessing any storage areas other than their own.
 
-  <h5 id=storage0><span class=secno>4.9.8.8. </span>Storage areas in the face
-   of untrusted higher-level domains that do not correspond to public storage
-   areas</h5>
+  <h5 id=storage0><span class=secno>4.10.8.8. </span>Storage areas in the
+   face of untrusted higher-level domains that do not correspond to public
+   storage areas</h5>
 
   <p>Authors should not store sensitive data using the global storage APIs if
    there are hosts with fully-qualified domain names that are subsets of
@@ -28403,8 +29948,8 @@
    storage area if he does not trust the host that runs
    <code>example.net</code>.
 
-  <h5 id=storage1><span class=secno>4.9.8.9. </span>Storage areas in the face
-   of untrusted subdomains</h5>
+  <h5 id=storage1><span class=secno>4.10.8.9. </span>Storage areas in the
+   face of untrusted subdomains</h5>
 
   <p>If an author publishing content on one host, e.g.
    <code>example.com</code>, wishes to use the <code
@@ -28415,7 +29960,7 @@
    accessible only to that host (and its parent domains), and not to any of
    the real subdomains (e.g. <code>upload.example.com</code>).
 
-  <h5 id=implementation><span class=secno>4.9.8.10. </span>Implementation
+  <h5 id=implementation><span class=secno>4.10.8.10. </span>Implementation
    risks</h5>
 
   <p>The two primary risks when implementing this persistent storage feature
@@ -28455,13 +30000,13 @@
    list of "<a href="#public0" title="public storage area">public</a>"
    domains, and apply the restrictions described above.
 
-  <h3 id=sql><span class=secno>4.10. </span>Client-side database storage</h3>
+  <h3 id=sql><span class=secno>4.11. </span>Client-side database storage</h3>
 
-  <h4 id=introduction2><span class=secno>4.10.1. </span>Introduction</h4>
+  <h4 id=introduction3><span class=secno>4.11.1. </span>Introduction</h4>
 
   <p class=big-issue>...
 
-  <h4 id=databases><span class=secno>4.10.2. </span>Databases</h4>
+  <h4 id=databases><span class=secno>4.11.2. </span>Databases</h4>
 
   <p>Each <i><a href="#origin0">origin</a></i> has an associated set of
    databases. Each database has a name and a current version. There is no way
@@ -28538,7 +30083,7 @@
    version that differs from the new version will start failing at this
    point. Finally, the method must return true.
 
-  <h4 id=executing><span class=secno>4.10.3. </span>Executing SQL statements</h4>
+  <h4 id=executing><span class=secno>4.11.3. </span>Executing SQL statements</h4>
 
   <p>Once a <code><a href="#database0">Database</a></code> object has been
    obtained, an author can interact with the database using the <code
@@ -28672,7 +30217,7 @@
   <p class=note>A future version of this specification may define the exact
    SQL subset required in more detail.
 
-  <h4 id=database><span class=secno>4.10.4. </span>Database query results</h4>
+  <h4 id=database><span class=secno>4.11.4. </span>Database query results</h4>
 
   <p>The <code title=dom-database-executeSql><a
    href="#executesql">executeSql()</a></code> method invokes its callback
@@ -28756,7 +30301,7 @@
    language, describing the error encountered by the last statement. If there
    was no error, the attribute's value must be the empty string.
 
-  <h4 id=privacy><span class=secno>4.10.5. </span>Privacy</h4>
+  <h4 id=privacy><span class=secno>4.11.5. </span>Privacy</h4>
 
   <p>In contrast with the <code title=dom-globalStorage><a
    href="#globalstorage">globalStorage</a></code> feature, which
@@ -28771,9 +30316,9 @@
    way as cookies for the purposes of user interfaces, to reduce the risk of
    using this feature for cookie resurrection.
 
-  <h4 id=security6><span class=secno>4.10.6. </span>Security</h4>
+  <h4 id=security6><span class=secno>4.11.6. </span>Security</h4>
 
-  <h5 id=user-agents><span class=secno>4.10.6.1. </span>User agents</h5>
+  <h5 id=user-agents><span class=secno>4.11.6.1. </span>User agents</h5>
 
   <p>User agent implementors are strongly encouraged to audit all their
    supported SQL statements for security implications. For example, <code
@@ -28786,7 +30331,7 @@
    disk representation of the data, as all data in ECMAScript is implicitly
    UTF-16.
 
-  <h5 id=sql-injection><span class=secno>4.10.6.2. </span>SQL injection</h5>
+  <h5 id=sql-injection><span class=secno>4.11.6.2. </span>SQL injection</h5>
 
   <p>Authors are strongly recommended to make use of the <code
    title="">?</code> placeholder feature of the <code
@@ -28794,9 +30339,9 @@
    href="#executesql">executeSql()</a></code> method, and to never construct
    SQL statements on the fly.
 
-  <h3 id=links><span class=secno>4.11. </span>Links</h3>
+  <h3 id=links><span class=secno>4.12. </span>Links</h3>
 
-  <h4 id=hyperlink><span class=secno>4.11.1. </span>Hyperlink elements</h4>
+  <h4 id=hyperlink><span class=secno>4.12.1. </span>Hyperlink elements</h4>
 
   <p>The <code><a href="#a">a</a></code>, <code><a
    href="#area">area</a></code>, and <code><a href="#link">link</a></code>
@@ -28873,7 +30418,7 @@
    fetching the resource, user agents must not use metadata included in the
    link to the resource to determine its type.
 
-  <h4 id=following><span class=secno>4.11.2. </span><dfn
+  <h4 id=following><span class=secno>4.12.2. </span><dfn
    id=following0>Following hyperlinks</dfn></h4>
 
   <p>When a user <em>follows a hyperlink</em>, the user agent must <a
@@ -28928,7 +30473,7 @@
   <p>Otherwise, the browsing context that must be navigated is the same
    browsing context as the one which the hyperlink element itself is in.
 
-  <h5 id=hyperlink0><span class=secno>4.11.2.1. </span>Hyperlink auditing</h5>
+  <h5 id=hyperlink0><span class=secno>4.12.2.1. </span>Hyperlink auditing</h5>
 
   <p>If an <code><a href="#a">a</a></code> or <code><a
    href="#area">area</a></code> hyperlink element has a <code
@@ -28995,7 +30540,7 @@
    it sounds kooky. -->
    </div>
 
-  <h4 id=linkTypes><span class=secno>4.11.3. </span>Link types</h4>
+  <h4 id=linkTypes><span class=secno>4.12.3. </span>Link types</h4>
 
   <p>The following table summarises the link types that are defined by this
    specification. This table is non-normative; the actual definitions for the
@@ -29304,7 +30849,7 @@
 
     -->
 
-  <h5 id=link-type><span class=secno>4.11.3.1. </span>Link type "<dfn
+  <h5 id=link-type><span class=secno>4.12.3.1. </span>Link type "<dfn
    id=alternate title=rel-alternate><code>alternate</code></dfn>"</h5>
 
   <p>The <code title=rel-alternate><a href="#alternate">alternate</a></code>
@@ -29381,7 +30926,7 @@
    document, it is also implying that those two documents are alternative
    representations of each other.
 
-  <h5 id=link-type0><span class=secno>4.11.3.2. </span>Link type "<dfn
+  <h5 id=link-type0><span class=secno>4.12.3.2. </span>Link type "<dfn
    id=archives title=rel-archives><code>archives</code></dfn>"</h5>
 
   <p>The <code title=rel-archives><a href="#archives">archives</a></code>
@@ -29401,7 +30946,7 @@
    treat the keyword "<code title="">archive</code>" like the <code
    title=rel-archives><a href="#archives">archives</a></code> keyword.
 
-  <h5 id=link-type1><span class=secno>4.11.3.3. </span>Link type "<dfn
+  <h5 id=link-type1><span class=secno>4.12.3.3. </span>Link type "<dfn
    id=author title=rel-author><code>author</code></dfn>"</h5>
 
   <p>The <code title=rel-author><a href="#author">author</a></code> keyword
@@ -29433,7 +30978,7 @@
    "<code>made</code>" as having the <code title=rel-author><a
    href="#author">author</a></code> keyword specified as a link relationship.
 
-  <h5 id=link-type2><span class=secno>4.11.3.4. </span>Link type "<dfn
+  <h5 id=link-type2><span class=secno>4.12.3.4. </span>Link type "<dfn
    id=bookmark title=rel-bookmark><code>bookmark</code></dfn>"</h5>
 
   <p>The <code title=rel-bookmark><a href="#bookmark">bookmark</a></code>
@@ -29474,7 +31019,7 @@
  ...</pre>
   </div>
 
-  <h5 id=link-type3><span class=secno>4.11.3.5. </span>Link type "<dfn
+  <h5 id=link-type3><span class=secno>4.12.3.5. </span>Link type "<dfn
    id=contact title=rel-contact><code>contact</code></dfn>"</h5>
 
   <p>The <code title=rel-contact><a href="#contact">contact</a></code>
@@ -29499,7 +31044,7 @@
    that the referenced document provides further contact information for the
    page as a whole.
 
-  <h5 id=link-type4><span class=secno>4.11.3.6. </span>Link type "<dfn
+  <h5 id=link-type4><span class=secno>4.12.3.6. </span>Link type "<dfn
    id=external title=rel-external><code>external</code></dfn>"</h5>
 
   <p>The <code title=rel-external><a href="#external">external</a></code>
@@ -29510,7 +31055,7 @@
    keyword indicates that the link is leading to a document that is not part
    of the site that the current document forms a part of.
 
-  <h5 id=link-type5><span class=secno>4.11.3.7. </span>Link type "<dfn
+  <h5 id=link-type5><span class=secno>4.12.3.7. </span>Link type "<dfn
    id=feed title=rel-feed><code>feed</code></dfn>"</h5>
 
   <p>The <code title=rel-feed><a href="#feed">feed</a></code> keyword may be
@@ -29554,7 +31099,7 @@
  </ul></pre>
   </div>
 
-  <h5 id=link-type6><span class=secno>4.11.3.8. </span>Link type "<dfn
+  <h5 id=link-type6><span class=secno>4.12.3.8. </span>Link type "<dfn
    id=help title=rel-help><code>help</code></dfn>"</h5>
 
   <p>The <code title=rel-help><a href="#help">help</a></code> keyword may be
@@ -29582,7 +31127,7 @@
    title=rel-help><a href="#help">help</a></code> keyword indicates that the
    referenced document provides help for the page as a whole.
 
-  <h5 id=link-type7><span class=secno>4.11.3.9. </span>Link type "<dfn
+  <h5 id=link-type7><span class=secno>4.12.3.9. </span>Link type "<dfn
    id=icon3 title=rel-icon><code>icon</code></dfn>"</h5>
 
   <p>The <code title=rel-icon><a href="#icon3">icon</a></code> keyword may be
@@ -29599,7 +31144,7 @@
    appropriate icon according to the <code title=attr-link-media><a
    href="#media0">media</a></code> attribute.
 
-  <h5 id=link-type8><span class=secno>4.11.3.10. </span>Link type "<dfn
+  <h5 id=link-type8><span class=secno>4.12.3.10. </span>Link type "<dfn
    id=license title=rel-license><code>license</code></dfn>"</h5>
 
   <p>The <code title=rel-license><a href="#license">license</a></code>
@@ -29616,7 +31161,7 @@
    treat the keyword "<code title="">copyright</code>" like the <code
    title=rel-license><a href="#license">license</a></code> keyword.
 
-  <h5 id=link-type9><span class=secno>4.11.3.11. </span>Link type "<dfn
+  <h5 id=link-type9><span class=secno>4.12.3.11. </span>Link type "<dfn
    id=nofollow title=rel-nofollow><code>nofollow</code></dfn>"</h5>
 
   <p>The <code title=rel-nofollow><a href="#nofollow">nofollow</a></code>
@@ -29627,7 +31172,7 @@
    keyword indicates that the link is not endorsed by the original author or
    publisher of the page.
 
-  <h5 id=link-type10><span class=secno>4.11.3.12. </span>Link type "<dfn
+  <h5 id=link-type10><span class=secno>4.12.3.12. </span>Link type "<dfn
    id=pingback title=rel-pingback><code>pingback</code></dfn>"</h5>
 
   <p>The <code title=rel-pingback><a href="#pingback">pingback</a></code>
@@ -29639,7 +31184,7 @@
    href="#pingback">pingback</a></code> keyword, see the Pingback 1.0
    specification. <a href="#refsPINGBACK">[PINGBACK]</a>
 
-  <h5 id=link-type11><span class=secno>4.11.3.13. </span>Link type "<dfn
+  <h5 id=link-type11><span class=secno>4.12.3.13. </span>Link type "<dfn
    id=prefetch title=rel-prefetch><code>prefetch</code></dfn>"</h5>
 
   <p>The <code title=rel-prefetch><a href="#prefetch">prefetch</a></code>
@@ -29652,7 +31197,7 @@
    resource is likely to be beneficial, as it is highly likely that the user
    will require this resource.
 
-  <h5 id=link-type12><span class=secno>4.11.3.14. </span>Link type "<dfn
+  <h5 id=link-type12><span class=secno>4.12.3.14. </span>Link type "<dfn
    id=search0 title=rel-search><code>search</code></dfn>"</h5>
 
   <p>The <code title=rel-search><a href="#search0">search</a></code> keyword
@@ -29670,7 +31215,7 @@
    href="#search0">search</a></code> link type to enable user agents to
    autodiscover search interfaces.
 
-  <h5 id=link-type13><span class=secno>4.11.3.15. </span>Link type "<dfn
+  <h5 id=link-type13><span class=secno>4.12.3.15. </span>Link type "<dfn
    id=stylesheet title=rel-stylesheet><code>stylesheet</code></dfn>"</h5>
 
   <p>The <code title=rel-stylesheet><a
@@ -29688,7 +31233,7 @@
    <code><a href="#link">link</a></code> element, then the link is an
    alternative stylesheet.
 
-  <h5 id=link-type14><span class=secno>4.11.3.16. </span>Link type "<dfn
+  <h5 id=link-type14><span class=secno>4.12.3.16. </span>Link type "<dfn
    id=sidebar title=rel-sidebar><code>sidebar</code></dfn>"</h5>
 
   <p>The <code title=rel-sidebar><a href="#sidebar">sidebar</a></code>
@@ -29708,7 +31253,7 @@
    specified is a <dfn id=sidebar0 title=rel-sidebar-hyperlink>sidebar
    hyperlink</dfn>.
 
-  <h5 id=link-type15><span class=secno>4.11.3.17. </span>Link type "<dfn
+  <h5 id=link-type15><span class=secno>4.12.3.17. </span>Link type "<dfn
    id=tag title=rel-tag><code>tag</code></dfn>"</h5>
 
   <p>The <code title=rel-tag><a href="#tag">tag</a></code> keyword may be
@@ -29721,7 +31266,7 @@
    that the <em>tag</em> that the referenced document represents applies to
    the current document.
 
-  <h5 id=hierarchical><span class=secno>4.11.3.18. </span>Hierarchical link
+  <h5 id=hierarchical><span class=secno>4.12.3.18. </span>Hierarchical link
    types</h5>
 
   <p>Some documents form part of a hierarchical structure of documents.
@@ -29734,7 +31279,7 @@
    <em>previous sibling</em>, and the one that follows it is its <em>next
    sibling</em>. A document with no parent forms the top of the hierarchy.
 
-  <h6 id=link-type16><span class=secno>4.11.3.18.1. </span>Link type "<dfn
+  <h6 id=link-type16><span class=secno>4.12.3.18.1. </span>Link type "<dfn
    id=first title=rel-first><code>first</code></dfn>"</h6>
 
   <p>The <code title=rel-first><a href="#first">first</a></code> keyword may
@@ -29753,7 +31298,7 @@
    title="">start</code>" like the <code title=rel-first><a
    href="#first">first</a></code> keyword.
 
-  <h6 id=link-type17><span class=secno>4.11.3.18.2. </span>Link type "<dfn
+  <h6 id=link-type17><span class=secno>4.12.3.18.2. </span>Link type "<dfn
    id=index title=rel-index><code>index</code></dfn>"</h6>
 
   <p>The <code title=rel-index><a href="#index">index</a></code> keyword may
@@ -29771,7 +31316,7 @@
    title="">contents</code>", and "<code title="">toc</code>" like the <code
    title=rel-index><a href="#index">index</a></code> keyword.
 
-  <h6 id=link-type18><span class=secno>4.11.3.18.3. </span>Link type "<dfn
+  <h6 id=link-type18><span class=secno>4.12.3.18.3. </span>Link type "<dfn
    id=last title=rel-last><code>last</code></dfn>"</h6>
 
   <p>The <code title=rel-last><a href="#last">last</a></code> keyword may be
@@ -29789,7 +31334,7 @@
    treat the keyword "<code title="">end</code>" like the <code
    title=rel-last><a href="#last">last</a></code> keyword.
 
-  <h6 id=link-type19><span class=secno>4.11.3.18.4. </span>Link type "<dfn
+  <h6 id=link-type19><span class=secno>4.12.3.18.4. </span>Link type "<dfn
    id=next title=rel-next><code>next</code></dfn>"</h6>
 
   <p>The <code title=rel-next><a href="#next">next</a></code> keyword may be
@@ -29803,7 +31348,7 @@
    the link is leading to the document that is the next sibling of the
    current document.
 
-  <h6 id=link-type20><span class=secno>4.11.3.18.5. </span>Link type "<dfn
+  <h6 id=link-type20><span class=secno>4.12.3.18.5. </span>Link type "<dfn
    id=prev title=rel-prev><code>prev</code></dfn>"</h6>
 
   <p>The <code title=rel-prev><a href="#prev">prev</a></code> keyword may be
@@ -29821,7 +31366,7 @@
    treat the keyword "<code title="">previous</code>" like the <code
    title=rel-prev><a href="#prev">prev</a></code> keyword.
 
-  <h6 id=link-type21><span class=secno>4.11.3.18.6. </span>Link type "<dfn
+  <h6 id=link-type21><span class=secno>4.12.3.18.6. </span>Link type "<dfn
    id=up title=rel-up><code>up</code></dfn>"</h6>
 
   <p>The <code title=rel-up><a href="#up">up</a></code> keyword may be used
@@ -29845,7 +31390,7 @@
      </nav>
    -->
 
-  <h5 id=other0><span class=secno>4.11.3.19. </span>Other link types</h5>
+  <h5 id=other0><span class=secno>4.12.3.19. </span>Other link types</h5>
 
   <p>Other than the types defined above, only types defined as extensions in
    the <a href="http://wiki.whatwg.org/wiki/RelExtensions">WHATWG Wiki
@@ -29975,7 +31520,7 @@
   <p>This specification does not define how new values will get approved. It
    is expected that the Wiki will have a community that addresses this.
 
-  <h3 id=interfaces><span class=secno>4.12. </span>Interfaces for URI
+  <h3 id=interfaces><span class=secno>4.13. </span>Interfaces for URI
    manipulation</h3>
 
   <p>An interface that has a complement of <dfn id=uri-decomposition>URI
@@ -30028,9 +31573,8 @@
    action</a> with the value of <var title="">output</var>.
 
   <p>The rules for parsing and constructing URIs are described in RFC 3986
-   and RFC 3987, as modified by RFC 2732. <a
-   href="#refsRFC3986">[RFC3986]</a> <a href="#refsRFC3987">[RFC3987]</a> <a
-   href="#refsRFC2732">[RFC2732]</a>
+   and RFC 3987. <a href="#refsRFC3986">[RFC3986]</a> <a
+   href="#refsRFC3987">[RFC3987]</a>
 
   <table>
    <thead>
@@ -30070,7 +31614,7 @@
     <tr>
      <td><dfn id=host0 title=dom-uda-host><code>host</code></dfn>
 
-     <td><hostport>
+     <td><a href="#lthostportgt"><hostport></a>
 
      <td><a href="#input" title=concept-uda-input>input</a> is hierarchical
       and uses a server-based naming authority
@@ -30087,7 +31631,7 @@
      <td><dfn id=hostname0 title=dom-uda-hostname><code>hostname</code></dfn>
       
 
-     <td><host>
+     <td><host>/<ihost>
 
      <td><a href="#input" title=concept-uda-input>input</a> is hierarchical
       and uses a server-based naming authority
@@ -30168,6 +31712,12 @@
 
      <td>—
   </table>
+
+  <p>The <dfn id=lthostportgt><hostport></dfn> component is defined as
+   being the <host>/<ihost> component, followed by a colon and
+   the <port> component, but with the colon and <port> component
+   omitted if the given port matches the default port for the protocol given
+   by the <scheme> component.</p>
   <!--
   http://www.hixie.ch/tests/adhoc/dom/level0/location/components/
   http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsLocation.cpp
@@ -31627,11 +33177,11 @@
 
   <pre class=idl>interface <dfn id=undomanager>UndoManager</dfn> {
   unsigned long <a href="#adddata" title=dom-UndoManager-add>add</a>(in DOMObject data, in DOMStrong title);
-  void <a href="#remove1" title=dom-UndoManager-remove>remove</a>(in unsigned long index);
+  void <a href="#remove2" title=dom-UndoManager-remove>remove</a>(in unsigned long index);
   void <a href="#clearundo" title=dom-UndoManager-clearUndo>clearUndo</a>();
   void <a href="#clearredo" title=dom-UndoManager-clearRedo>clearRedo</a>();
   DOMObject <a href="#itemn" title=dom-UndoManager-item>item</a>(in unsigned long index);
-  readonly attribute unsigned long <a href="#length8" title=dom-UndoManager-length>length</a>;
+  readonly attribute unsigned long <a href="#length9" title=dom-UndoManager-length>length</a>;
   readonly attribute unsigned long <a href="#position0" title=dom-UndoManager-position>position</a>;
 };</pre>
 
@@ -31656,7 +33206,7 @@
    entries are absent from the <a href="#undo-transaction">undo transaction
    history</a>.
 
-  <p>The <dfn id=length8
+  <p>The <dfn id=length9
    title=dom-UndoManager-length><code>length</code></dfn> attribute must
    return the number of <a href="#undo-object">undo object</a> entries in the
    <a href="#undo-transaction">undo transaction history</a>.
@@ -31680,7 +33230,7 @@
    nearest to the <a href="#current3">undo position</a>, on the "redo" side.
    If there are no <a href="#undo-object">undo object</a> entries on the
    "redo" side, then the attribute must return the same as the <code
-   title=dom-UndoManager-length><a href="#length8">length</a></code>
+   title=dom-UndoManager-length><a href="#length9">length</a></code>
    attribute. If there are no <a href="#undo-object">undo object</a> entries
    on the "undo" side of the <a href="#current3">undo position</a>, the <code
    title=dom-UndoManager-position><a href="#position0">position</a></code>
@@ -31722,12 +33272,12 @@
    expire server-held state when the server limitations come into play.</p>
   <!-- XXX note on expiring undo in case server can only do one level undo -->
 
-  <p>The <dfn id=remove1 title=dom-UndoManager-remove><code>remove(<var
+  <p>The <dfn id=remove2 title=dom-UndoManager-remove><code>remove(<var
    title="">index</var>)</code></dfn> method must remove the <a
    href="#undo-object">undo object</a> entry with the specified <var
    title="">index</var>. If the index is less than zero or greater than or
    equal to <code title=dom-UndoManager-length><a
-   href="#length8">length</a></code> then the method must raise an
+   href="#length9">length</a></code> then the method must raise an
    <code>INDEX_SIZE_ERR</code> exception. <a href="#dom-changes">DOM
    changes</a> entries are unaffected by this method.
 
@@ -32333,7 +33883,7 @@
    members in their DOM interfaces for handling their text selection:
 
   <pre
-   class=idl>  void <a href="#select0" title="dom-textarea/input-select">select</a>();
+   class=idl>  void <a href="#select1" title="dom-textarea/input-select">select</a>();
            attribute unsigned long <a href="#selectionstart" title="dom-textarea/input-selectionStart">selectionStart</a>;
            attribute unsigned long <a href="#selectionend" title="dom-textarea/input-selectionEnd">selectionEnd</a>;
   void <a href="#setselectionrange" title="dom-textarea/input-setSelectionRange">setSelectionRange</a>(in unsigned long start, in unsigned long end);</pre>
@@ -32342,7 +33892,7 @@
   <p>These methods and attributes expose and control the selection of
    <code>input</code> and <code>textarea</code> text fields.
 
-  <p>The <dfn id=select0
+  <p>The <dfn id=select1
    title="dom-textarea/input-select"><code>select()</code></dfn> method must
    cause the contents of the text field to be fully selected.
 
@@ -32622,7 +34172,7 @@
 
   <p>For non-HTTP protocols, UAs should act in equivalent ways.
 
-  <h4 id=parsing0><span class=secno>6.2.3. </span>Parsing an event stream</h4>
+  <h4 id=parsing1><span class=secno>6.2.3. </span>Parsing an event stream</h4>
 
   <p>This event stream format's MIME type is
    <code>application/x-dom-event-stream</code>.
@@ -33882,7 +35432,7 @@
    to communicate with each other regardless of their source domain, in a way
    designed to not enable cross-site scripting attacks.
 
-  <h4 id=processing2><span class=secno>6.4.1. </span>Processing model</h4>
+  <h4 id=processing3><span class=secno>6.4.1. </span>Processing model</h4>
 
   <p>When a script invokes the <dfn id=postmessage
    title=dom-window-postMessage><code>postMessage(<var
@@ -33976,7 +35526,7 @@
 
   <h2 id=syntax><span class=secno>8. </span>The HTML syntax</h2>
 
-  <h3 id=writing><span class=secno>8.1. </span>Writing HTML documents</h3>
+  <h3 id=writing0><span class=secno>8.1. </span>Writing HTML documents</h3>
 
   <p><em>This section only applies to documents, authoring tools, and markup
    generators. In particular, it does not apply to conformance checkers;
@@ -34743,7 +36293,7 @@
 
   <p>This specification defines the parsing rules for HTML documents, whether
    they are syntactically valid or not. Certain points in the parsing
-   algorithm are said to be <dfn id=parse title="parse error">parse
+   algorithm are said to be <dfn id=parse0 title="parse error">parse
    errors</dfn>. The error handling for parse errors is well-defined: user
    agents must either act as described below when encountering such problems,
    or must abort processing at the first error that they encounter for which
@@ -35294,7 +36844,7 @@
 
   <p>All U+0000 NULL characters in the input must be replaced by U+FFFD
    REPLACEMENT CHARACTERs. Any occurrences of such characters is a <a
-   href="#parse">parse error</a>.
+   href="#parse0">parse error</a>.
 
   <p>U+000D CARRIAGE RETURN (CR) characters, and U+000A LINE FEED (LF)
    characters, are treated specially. Any CR characters that are followed by
@@ -35320,7 +36870,7 @@
    representing the end of the <a href="#input0">input stream</a>. If the
    parser is a <a href="#script-created">script-created parser</a>, then the
    end of the <a href="#input0">input stream</a> is reached when an <dfn
-   id=explicit>explicit "EOF" character</dfn> (inserted by the <code
+   id=explicit0>explicit "EOF" character</dfn> (inserted by the <code
    title=dom-document-close><a href="#close">document.close()</a></code>
    method) is consumed. Otherwise, the "EOF" character is not a real
    character in the stream, but rather the lack of any further characters.
@@ -35411,7 +36961,7 @@
    flag</a> must be switched to the PCDATA state.
 
   <p>When an end tag token is emitted with attributes, that is a <a
-   href="#parse">parse error</a>.
+   href="#parse0">parse error</a>.
 
   <p>A <dfn id=permitted>permitted slash</dfn> is a U+002F SOLIDUS character
    that is immediately followed by a U+003E GREATER-THAN SIGN, if, and only
@@ -35569,18 +37119,18 @@
 
        <dt>U+003E GREATER-THAN SIGN (>)
 
-       <dd><a href="#parse">Parse error</a>. Emit a U+003C LESS-THAN SIGN
+       <dd><a href="#parse0">Parse error</a>. Emit a U+003C LESS-THAN SIGN
         character token and a U+003E GREATER-THAN SIGN character token.
         Switch to the <a href="#data-state">data state</a>.
 
        <dt>U+003F QUESTION MARK (?)
 
-       <dd><a href="#parse">Parse error</a>. Switch to the <a
+       <dd><a href="#parse0">Parse error</a>. Switch to the <a
         href="#bogus">bogus comment state</a>.
 
        <dt>Anything else
 
-       <dd><a href="#parse">Parse error</a>. Emit a U+003C LESS-THAN SIGN
+       <dd><a href="#parse0">Parse error</a>. Emit a U+003C LESS-THAN SIGN
         character token and reconsume the current input character in the <a
         href="#data-state">data state</a>.
       </dl>
@@ -35642,18 +37192,18 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse">Parse error</a>. Switch to the <a
+     <dd><a href="#parse0">Parse error</a>. Switch to the <a
       href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit a U+003C LESS-THAN SIGN
+     <dd><a href="#parse0">Parse error</a>. Emit a U+003C LESS-THAN SIGN
       character token and a U+002F SOLIDUS character token. Reconsume the EOF
       character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse">Parse error</a>. Switch to the <a
+     <dd><a href="#parse0">Parse error</a>. Switch to the <a
       href="#bogus">bogus comment state</a>.
     </dl>
 
@@ -35690,13 +37240,13 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse">Parse error</a> unless this is a <a
+     <dd><a href="#parse0">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Switch to the <a
       href="#before">before attribute name state</a>.
 
@@ -35740,13 +37290,13 @@
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse">Parse error</a> unless this is a <a
+     <dd><a href="#parse0">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Stay in the <a
       href="#before">before attribute name state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
@@ -35794,13 +37344,13 @@
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse">Parse error</a> unless this is a <a
+     <dd><a href="#parse0">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Switch to the <a
       href="#before">before attribute name state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
@@ -35814,7 +37364,7 @@
      emitting the tag token, if appropriate), the complete attribute's name
      must be compared to the other attributes on the same token; if there is
      already an attribute on the token with the exact same name, then this is
-     a <a href="#parse">parse error</a> and the new attribute must be
+     a <a href="#parse0">parse error</a> and the new attribute must be
      dropped, along with the value that gets associated with it (if any).</p>
 
    <dt><dfn id=after>After attribute name state</dfn>
@@ -35855,13 +37405,13 @@
 
      <dt>U+002F SOLIDUS (/)
 
-     <dd><a href="#parse">Parse error</a> unless this is a <a
+     <dd><a href="#parse0">Parse error</a> unless this is a <a
       href="#permitted">permitted slash</a>. Switch to the <a
       href="#before">before attribute name state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
@@ -35913,7 +37463,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
       Reconsume the character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -35940,7 +37490,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
       Reconsume the character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -35967,7 +37517,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
       Reconsume the character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -36008,7 +37558,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the current tag token.
+     <dd><a href="#parse0">Parse error</a>. Emit the current tag token.
       Reconsume the character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -36066,7 +37616,7 @@
      word "DOCTYPE", then consume those characters and switch to the <a
      href="#doctype0">DOCTYPE state</a>.</p>
 
-    <p>Otherwise, is is a <a href="#parse">parse error</a>. Switch to the <a
+    <p>Otherwise, is is a <a href="#parse0">parse error</a>. Switch to the <a
      href="#bogus">bogus comment state</a>. The next character that is
      consumed, if any, is the first character that will be in the comment.</p>
 
@@ -36082,12 +37632,12 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse">Parse error</a>. Emit the comment token. Switch to
+     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Switch to
       the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -36108,12 +37658,12 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse">Parse error</a>. Emit the comment token. Switch to
+     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Switch to
       the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.
 
      <dt>Anything else
@@ -36135,7 +37685,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.</dd>
      <!-- For
      security reasons: otherwise, hostile user could put a <script> in
@@ -36161,7 +37711,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.</dd>
      <!-- For
      security reasons: otherwise, hostile user could put a <script> in
@@ -36189,13 +37739,13 @@
 
      <dt>U+002D HYPHEN-MINUS (-)
 
-     <dd><a href="#parse">Parse error</a>. Append a U+002D HYPHEN-MINUS (-)
+     <dd><a href="#parse0">Parse error</a>. Append a U+002D HYPHEN-MINUS (-)
       character to the comment token's data. Stay in the <a
       href="#comment3">comment end state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Emit the comment token. Reconsume
+     <dd><a href="#parse0">Parse error</a>. Emit the comment token. Reconsume
       the EOF character in the <a href="#data-state">data state</a>.</dd>
      <!-- For
      security reasons: otherwise, hostile user could put a <script> in
@@ -36205,9 +37755,9 @@
 
      <dt>Anything else
 
-     <dd><a href="#parse">Parse error</a>. Append two U+002D HYPHEN-MINUS (-)
-      characters and the input character to the comment token's data. Switch
-      to the <a href="#comment">comment state</a>.
+     <dd><a href="#parse0">Parse error</a>. Append two U+002D HYPHEN-MINUS
+      (-) characters and the input character to the comment token's data.
+      Switch to the <a href="#comment">comment state</a>.
     </dl>
 
    <dt><dfn id=doctype0>DOCTYPE state</dfn>
@@ -36231,8 +37781,8 @@
 
      <dt>Anything else
 
-     <dd><a href="#parse">Parse error</a>. Reconsume the current character in
-      the <a href="#before1">before DOCTYPE name state</a>.
+     <dd><a href="#parse0">Parse error</a>. Reconsume the current character
+      in the <a href="#before1">before DOCTYPE name state</a>.
     </dl>
 
    <dt><dfn id=before1>Before DOCTYPE name state</dfn>
@@ -36256,13 +37806,13 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse">Parse error</a>. Create a new DOCTYPE token. Set
+     <dd><a href="#parse0">Parse error</a>. Create a new DOCTYPE token. Set
       its correctness flag to <i>incorrect</i>. Emit the token. Switch to the
       <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Create a new DOCTYPE token. Set
+     <dd><a href="#parse0">Parse error</a>. Create a new DOCTYPE token. Set
       its correctness flag to <i>incorrect</i>. Emit the token. Reconsume the
       EOF character in the <a href="#data-state">data state</a>.
 
@@ -36299,7 +37849,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -36336,7 +37886,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -36354,7 +37904,7 @@
        the word "SYSTEM", then consume those characters and switch to the <a
        href="#before3">before DOCTYPE system identifier state</a>.</p>
 
-      <p>Otherwise, this is the <a href="#parse">parse error</a>. Switch to
+      <p>Otherwise, this is the <a href="#parse0">parse error</a>. Switch to
        the <a href="#bogus0">bogus DOCTYPE state</a>.</p>
     </dl>
 
@@ -36392,20 +37942,20 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token. Switch
       to the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse">Parse error</a>. Switch to the <a
+     <dd><a href="#parse0">Parse error</a>. Switch to the <a
       href="#bogus0">bogus DOCTYPE state</a>.
     </dl>
 
@@ -36422,7 +37972,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -36447,7 +37997,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -36498,14 +38048,14 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse">Parse error</a>. Switch to the <a
+     <dd><a href="#parse0">Parse error</a>. Switch to the <a
       href="#bogus0">bogus DOCTYPE state</a>.
     </dl>
 
@@ -36543,20 +38093,20 @@
 
      <dt>U+003E GREATER-THAN SIGN (>)
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token. Switch
       to the <a href="#data-state">data state</a>.
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse">Parse error</a>. Switch to the <a
+     <dd><a href="#parse0">Parse error</a>. Switch to the <a
       href="#bogus0">bogus DOCTYPE state</a>.
     </dl>
 
@@ -36573,7 +38123,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -36598,7 +38148,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -36637,14 +38187,14 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
 
      <dt>Anything else
 
-     <dd><a href="#parse">Parse error</a>. Switch to the <a
+     <dd><a href="#parse0">Parse error</a>. Switch to the <a
       href="#bogus0">bogus DOCTYPE state</a>.
     </dl>
 
@@ -36661,7 +38211,7 @@
 
      <dt>EOF
 
-     <dd><a href="#parse">Parse error</a>. Set the DOCTYPE token's
+     <dd><a href="#parse0">Parse error</a>. Set the DOCTYPE token's
       correctness flag to <i>incorrect</i>. Emit that DOCTYPE token.
       Reconsume the EOF character in the <a href="#data-state">data
       state</a>.
@@ -36743,18 +38293,18 @@
 
     <p>If no characters match the range, then don't consume any characters
      (and unconsume the U+0023 NUMBER SIGN character and, if appropriate, the
-     X character). This is a <a href="#parse">parse error</a>; nothing is
+     X character). This is a <a href="#parse0">parse error</a>; nothing is
      returned.</p>
 
     <p>Otherwise, if the next character is a U+003B SEMICOLON, consume that
-     too. If it isn't, there is a <a href="#parse">parse error</a>.</p>
+     too. If it isn't, there is a <a href="#parse0">parse error</a>.</p>
 
     <p>If one or more characters match the range, then take them all and
      interpret the string of characters as a number (either hexadecimal or
      decimal as appropriate).</p>
 
     <p>If that number is one of the numbers in the first column of the
-     following table, then this is a <a href="#parse">parse error</a>. Find
+     following table, then this is a <a href="#parse0">parse error</a>. Find
      the row with that number in the first column, and return a character
      token for the Unicode character given in the second column of that row.</p>
 
@@ -37000,7 +38550,7 @@
 
     <p>Otherwise, if the number is zero, if the number is higher than
      0x10FFFF, or if it's one of the surrogate characters (characters in the
-     range 0xD800 to 0xDFFF), then this is a <a href="#parse">parse
+     range 0xD800 to 0xDFFF), then this is a <a href="#parse0">parse
      error</a>; return a character token for the U+FFFD REPLACEMENT CHARACTER
      character instead.</p>
 
@@ -37014,11 +38564,11 @@
      characters case-sensitively matching one of the identifiers in the first
      column of the <a href="#entities0">entities</a> table.</p>
 
-    <p>If no match can be made, then this is a <a href="#parse">parse
+    <p>If no match can be made, then this is a <a href="#parse0">parse
      error</a>. No characters are consumed, and nothing is returned.</p>
 
     <p>If the last character matched is not a U+003B SEMICOLON (<code
-     title="">;</code>), there is a <a href="#parse">parse error</a>.</p>
+     title="">;</code>), there is a <a href="#parse0">parse error</a>.</p>
 
     <p>If the entity is being consumed <a href="#entity0" title="entity in
      attribute value state">as part of an attribute</a>, and the last
@@ -37116,7 +38666,7 @@
     <p>If the DOCTYPE token's <code title="">name</code> does not
      case-insensitively match the string "<code title="">HTML</code>", or if
      the token's public identifier is not missing, or if the token's system
-     identifier is not missing, then there is a <a href="#parse">parse
+     identifier is not missing, then there is a <a href="#parse0">parse
      error</a>. Conformance checkers may, instead of reporting this error,
      switch to a conformance checking mode for another language (e.g. based
      on the DOCTYPE token a conformance checker could recognise that the
@@ -37399,7 +38949,7 @@
    <dt>An end-of-file token
 
    <dd>
-    <p><a href="#parse">Parse error</a>.</p>
+    <p><a href="#parse0">Parse error</a>.</p>
 
     <p>Set the document to <a href="#quirks">quirks mode</a>.</p>
 
@@ -37418,7 +38968,7 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
    <dt>A comment token
 
@@ -37445,6 +38995,15 @@
    <dt>An end-of-file token
 
    <dd>
+    <p id=parser-appcache>If the token is a start tag token with the tag name
+     "html", and it has an attribute "application", then run the <a
+     href="#application2"
+     title=concept-appcache-init-with-attribute>application cache selection
+     algorithm</a> with the value of that attribute as the manifest URI.
+     Otherwise, run the <a href="#application3"
+     title=concept-appcache-init-no-attribute>application cache selection
+     algorithm</a> with no manifest.</p>
+
     <p>Create an <code><a href="#htmlelement">HTMLElement</a></code> node
      with the tag name <code><a href="#html">html</a></code>, in the <a
      href="#html-namespace0">HTML namespace</a>. Append it to the
@@ -37797,7 +39356,7 @@
 
    <li>
     <p>If the next token is an end tag token with the same tag name as the
-     start tag token, ignore it. Otherwise, this is a <a href="#parse">parse
+     start tag token, ignore it. Otherwise, this is a <a href="#parse0">parse
      error</a>.
   </ol>
 
@@ -38023,13 +39582,13 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
    <dt>A start tag whose tag name is "html"
 
    <dd>
     <p>If this start tag token was not the first start tag token, then it is
-     a <a href="#parse">parse error</a>.</p>
+     a <a href="#parse0">parse error</a>.</p>
 
     <p>For each attribute on the token, check to see if the attribute is
      already present on the top element of the <a href="#stack">stack of open
@@ -38044,14 +39603,14 @@
     <p>If there are more than two nodes on the <a href="#stack">stack of open
      elements</a>, or if there are two nodes but the second node is not a
      <code><a href="#body0">body</a></code> node, this is a <a
-     href="#parse">parse error</a>.</p>
+     href="#parse0">parse error</a>.</p>
 
     <p>Otherwise, if the parser was originally created as part of the <a
      href="#html-fragment0">HTML fragment parsing algorithm</a>, and there's
      more than one element in the <a href="#stack">stack of open
      elements</a>, and the second node on the <a href="#stack">stack of open
      elements</a> is not a <code><a href="#body0">body</a></code> node, then
-     this is a <a href="#parse">parse error</a>. (<a
+     this is a <a href="#parse0">parse error</a>. (<a
      href="#fragment">fragment case</a>)</p>
 
     <p><a href="#stops">Stop parsing.</a></p>
@@ -38127,7 +39686,7 @@
        <dt>Any other end tag
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
         <p class=big-issue>Do we really want to ignore end tags here?</p>
 
@@ -38260,7 +39819,7 @@
          have switched back to the PCDATA state.</p>
 
         <p>If the next token is not an end tag token with the tag name
-         "script", then this is a <a href="#parse">parse error</a>; mark the
+         "script", then this is a <a href="#parse0">parse error</a>; mark the
          <code><a href="#script0">script</a></code> element as <a
          href="#already">"already executed"</a>. Otherwise, the token is the
          <code><a href="#script0">script</a></code> element's end tag, so
@@ -38376,7 +39935,7 @@
        <dt>Any other end tag
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>Anything else
 
@@ -38431,12 +39990,12 @@
        <dt>Any other end tag
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>Anything else
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Act as if an end tag with the
+        <p><a href="#parse0">Parse error</a>. Act as if an end tag with the
          tag name "noscript" had been seen and reprocess the current token.</p>
       </dl>
 
@@ -38486,7 +40045,7 @@
         "meta", "script", "style", "title"
 
        <dd>
-        <p><a href="#parse">Parse error</a>.</p>
+        <p><a href="#parse0">Parse error</a>.</p>
 
         <p>Push the node pointed to by the <a href="#head-element"><code
          title="">head</code> element pointer</a> onto the <a
@@ -38544,14 +40103,14 @@
        <dt>A start tag whose tag name is "title"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Process the token as if the <a
+        <p><a href="#parse0">Parse error</a>. Process the token as if the <a
          href="#insertion0">insertion mode</a> had been "<a href="#in-head"
          title="insertion mode: in head">in head</a>".</p>
 
        <dt>A start tag whose tag name is "body"
 
        <dd>
-        <p><a href="#parse">Parse error</a>.</p>
+        <p><a href="#parse0">Parse error</a>.</p>
 
         <p>If the second element on the <a href="#stack">stack of open
          elements</a> is not a <code><a href="#body0">body</a></code>
@@ -38570,7 +40129,7 @@
        <dd>
         <p>If the second element in the <a href="#stack">stack of open
          elements</a> is not a <code><a href="#body0">body</a></code>
-         element, this is a <a href="#parse">parse error</a>. Ignore the
+         element, this is a <a href="#parse0">parse error</a>. Ignore the
          token. (<a href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise, if there is a node in the <a href="#stack">stack of
@@ -38586,7 +40145,7 @@
          href="#tr">tr</a></code> element, the <code><a
          href="#body0">body</a></code> element, or the <code><a
          href="#html">html</a></code> element, then this is a <a
-         href="#parse">parse error</a>.
+         href="#parse0">parse error</a>.
 
         <p>Change the <a href="#insertion0">insertion mode</a> to "<a
          href="#after4" title="insertion mode: after body">after body</a>".</p>
@@ -38634,7 +40193,7 @@
        <dd>
         <p>If the <a href="#form-element"><code title=form>form</code>
          element pointer</a> is not null, ignore the token with a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>Otherwise:</p>
 
@@ -38669,7 +40228,7 @@
            <a href="#current4">current node</a> up to <var
            title="">node</var>, including <var title="">node</var>, then stop
            this algorithm. If more than one node is popped, then this is a <a
-           href="#parse">parse error</a>.
+           href="#parse0">parse error</a>.
 
          <li>
           <p>If <var title="">node</var> is not in the <a
@@ -38719,7 +40278,7 @@
            href="#current4">current node</a> up to <var title="">node</var>,
            including <var title="">node</var>, then stop this algorithm. If
            more than one node is popped, then this is a <a
-           href="#parse">parse error</a>.
+           href="#parse0">parse error</a>.
 
          <li>
           <p>If <var title="">node</var> is not in the <a
@@ -38778,7 +40337,7 @@
 
         <p>Now, if the <a href="#current4">current node</a> is not an element
          with the same tag name as that of the token, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>If the <a href="#stack">stack of open elements</a> <a
          href="#have-an">has an element in scope</a> with the same tag name
@@ -38800,7 +40359,7 @@
 
         <p>Now, if the <a href="#current4">current node</a> is not an element
          with the same tag name as that of the token, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>Otherwise, if the <a href="#current4">current node</a> is an
          element with the same tag name as that of the token pop that element
@@ -38819,7 +40378,7 @@
 
         <p>If the <a href="#current4">current node</a> is not a <code><a
          href="#p">p</a></code> element, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>If the <a href="#stack">stack of open elements</a> <a
          href="#have-an" title="has an element in scope">has a <code>p</code>
@@ -38842,7 +40401,7 @@
 
         <p>If the <a href="#current4">current node</a> is not an element with
          the same tag name as the token, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>If the <a href="#stack">stack of open elements</a> <a
          href="#have-an">has an element in scope</a> whose tag name matches
@@ -38883,7 +40442,7 @@
 
         <p>Now, if the <a href="#current4">current node</a> is not an element
          with the same tag name as that of the token, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>If the <a href="#stack">stack of open elements</a> <a
          href="#have-an" title="has an element in scope">has in scope</a> an
@@ -38907,7 +40466,7 @@
          contains an element whose tag name is "a" between the end of the
          list and the last marker on the list (or the start of the list if
          there is no marker on the list), then this is a <a
-         href="#parse">parse error</a>; act as if an end tag with the tag
+         href="#parse0">parse error</a>; act as if an end tag with the tag
          name "a" had been seen, then remove that element from the <a
          href="#list-of4">list of active formatting elements</a> and the <a
          href="#stack">stack of open elements</a> if the end tag didn't
@@ -38952,7 +40511,7 @@
         <p>If the <a href="#stack">stack of open elements</a> <a
          href="#have-an" title="has an element in scope">has a
          <code>nobr</code> element in scope</a>, then this is a <a
-         href="#parse">parse error</a>. Act as if an end tag with the tag
+         href="#parse0">parse error</a>. Act as if an end tag with the tag
          name <code>nobr</code> had been seen, then once again <a
          href="#reconstruct">reconstruct the active formatting elements</a>,
          if any.</p>
@@ -38984,12 +40543,12 @@
           <p>If there is no such node, or, if that node is also in the <a
            href="#stack">stack of open elements</a> but the element is not <a
            href="#have-an" title="has an element in scope">in scope</a>, then
-           this is a <a href="#parse">parse error</a>. Abort these steps. The
-           token is ignored.</p>
+           this is a <a href="#parse0">parse error</a>. Abort these steps.
+           The token is ignored.</p>
 
           <p>Otherwise, if there is such a node, but that node is not in the
            <a href="#stack">stack of open elements</a>, then this is a <a
-           href="#parse">parse error</a>; remove the element from the list,
+           href="#parse0">parse error</a>; remove the element from the list,
            and abort these steps.</p>
 
           <p>Otherwise, there is a <var title="">formatting element</var> and
@@ -38997,7 +40556,7 @@
            elements">the stack</a> and is <a href="#have-an" title="has an
            element in scope">in scope</a>. If the element is not the <a
            href="#current4">current node</a>, this is a <a
-           href="#parse">parse error</a>. In any case, proceed with the
+           href="#parse0">parse error</a>. In any case, proceed with the
            algorithm as written in the following steps.</p>
 
          <li>
@@ -39128,7 +40687,7 @@
         <p>If the <a href="#stack">stack of open elements</a> <a
          href="#have-an" title="has an element in scope">has a
          <code>button</code> element in scope</a>, then this is a <a
-         href="#parse">parse error</a>; act as if an end tag with the tag
+         href="#parse0">parse error</a>; act as if an end tag with the tag
          name "button" had been seen, then reprocess the token.</p>
 
         <p>Otherwise:</p>
@@ -39163,7 +40722,7 @@
 
         <p>Now, if the <a href="#current4">current node</a> is not an element
          with the same tag name as the token, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>Now, if the <a href="#stack">stack of open elements</a> <a
          href="#have-an">has an element in scope</a> whose tag name matches
@@ -39223,7 +40782,7 @@
        <dt>A start tag whose tag name is "image"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Change the token's tag name to
+        <p><a href="#parse0">Parse error</a>. Change the token's tag name to
          "img" and reprocess it. (Don't ask.)</p>
         <!-- As of
         2005-12, studies showed that around 0.2% of pages used the
@@ -39252,7 +40811,7 @@
        <dt id=isindex>A start tag whose tag name is "isindex"
 
        <dd>
-        <p><a href="#parse">Parse error</a>.</p>
+        <p><a href="#parse0">Parse error</a>.</p>
 
         <p>If the <a href="#form-element"><code title="">form</code> element
          pointer</a> is not null, then ignore the token.</p>
@@ -39353,7 +40912,7 @@
          have switched back to the PCDATA state.</p>
 
         <p>If the next token is an end tag token with the tag name
-         "textarea", ignore it. Otherwise, this is a <a href="#parse">parse
+         "textarea", ignore it. Otherwise, this is a <a href="#parse0">parse
          error</a>.</p>
 
        <dt>A start tag whose tag name is one of: "iframe", "noembed",
@@ -39381,8 +40940,8 @@
        <dt>An end tag whose tag name is "br"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Act as if a start tag token with
-         the tag name "br" had been seen. Ignore the end tag token.</p>
+        <p><a href="#parse0">Parse error</a>. Act as if a start tag token
+         with the tag name "br" had been seen. Ignore the end tag token.</p>
 
        <dt>A start or end tag whose tag name is one of: "caption", "col",
         "colgroup", "frame", "frameset", "head", "option", "optgroup",
@@ -39398,7 +40957,7 @@
         href="#scripting2">scripting is enabled</a>:
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>A start or end tag whose tag name is one of: "event-source",
         "section", "nav", "article", "aside", "header", "footer", "datagrid",
@@ -39448,7 +41007,7 @@
            <li>
             <p>If the tag name of the end tag token does not match the tag
              name of the <a href="#current4">current node</a>, this is a <a
-             href="#parse">parse error</a>.
+             href="#parse0">parse error</a>.
 
            <li>
             <p>Pop all the nodes from the <a href="#current4">current
@@ -39460,7 +41019,7 @@
           <p>Otherwise, if <var title="">node</var> is in neither the <a
            href="#formatting">formatting</a> category nor the <a
            href="#phrasing">phrasing</a> category, then this is a <a
-           href="#parse">parse error</a>. Stop this algorithm. The end tag
+           href="#parse0">parse error</a>. Stop this algorithm. The end tag
            token is ignored.
 
          <li>
@@ -39545,7 +41104,7 @@
        <dt>A start tag whose tag name is "table"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Act as if an end tag token with
+        <p><a href="#parse0">Parse error</a>. Act as if an end tag token with
          the tag name "table" had been seen, then, if that token wasn't
          ignored, reprocess the current token.</p>
 
@@ -39558,7 +41117,7 @@
         <p>If the <a href="#stack">stack of open elements</a> does not <a
          href="#have-an0" title="has an element in table scope">have an
          element in table scope</a> with the same tag name as the token, this
-         is a <a href="#parse">parse error</a>. Ignore the token. (<a
+         is a <a href="#parse0">parse error</a>. Ignore the token. (<a
          href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise:</p>
@@ -39567,7 +41126,7 @@
 
         <p>Now, if the <a href="#current4">current node</a> is not a <code><a
          href="#table">table</a></code> element, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>Pop elements from this stack until a <code><a
          href="#table">table</a></code> element has been popped from the
@@ -39579,12 +41138,12 @@
         "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>Anything else
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Process the token as if the <a
+        <p><a href="#parse0">Parse error</a>. Process the token as if the <a
          href="#insertion0">insertion mode</a> was "<a href="#in-body"
          title="insertion mode: in body">in body</a>", with the following
          exception:</p>
@@ -39635,7 +41194,7 @@
        href="#table">table</a></code> element or an <code><a
        href="#html">html</a></code> element, pop elements from the <a
        href="#stack">stack of open elements</a>. If this causes any elements
-       to be popped from the stack, then this is a <a href="#parse">parse
+       to be popped from the stack, then this is a <a href="#parse0">parse
        error</a>.</p>
 
       <p class=note>The <a href="#current4">current node</a> being an
@@ -39654,7 +41213,7 @@
         <p>If the <a href="#stack">stack of open elements</a> does not <a
          href="#have-an0" title="has an element in table scope">have an
          element in table scope</a> with the same tag name as the token, this
-         is a <a href="#parse">parse error</a>. Ignore the token. (<a
+         is a <a href="#parse0">parse error</a>. Ignore the token. (<a
          href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise:</p>
@@ -39663,7 +41222,7 @@
 
         <p>Now, if the <a href="#current4">current node</a> is not a <code><a
          href="#caption0">caption</a></code> element, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>Pop elements from this stack until a <code><a
          href="#caption0">caption</a></code> element has been popped from the
@@ -39681,7 +41240,7 @@
        <dt>An end tag whose tag name is "table"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Act as if an end tag with the
+        <p><a href="#parse0">Parse error</a>. Act as if an end tag with the
          tag name "caption" had been seen, then, if that token wasn't
          ignored, reprocess the current token.</p>
 
@@ -39692,7 +41251,7 @@
         "html", "tbody", "td", "tfoot", "th", "thead", "tr"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>Anything else
 
@@ -39737,7 +41296,7 @@
        <dd>
         <p>If the <a href="#current4">current node</a> is the root <code><a
          href="#html">html</a></code> element, then this is a <a
-         href="#parse">parse error</a>, ignore the token. (<a
+         href="#parse0">parse error</a>, ignore the token. (<a
          href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise, pop the <a href="#current4">current node</a> (which
@@ -39749,7 +41308,7 @@
        <dt>An end tag whose tag name is "col"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>Anything else
 
@@ -39781,7 +41340,7 @@
        <dt>A start tag whose tag name is one of: "th", "td"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Act as if a start tag with the
+        <p><a href="#parse0">Parse error</a>. Act as if a start tag with the
          tag name "tr" had been seen, then reprocess the current token.</p>
 
        <dt>An end tag whose tag name is one of: "tbody", "tfoot", "thead"
@@ -39790,7 +41349,7 @@
         <p>If the <a href="#stack">stack of open elements</a> does not <a
          href="#have-an0" title="has an element in table scope">have an
          element in table scope</a> with the same tag name as the token, this
-         is a <a href="#parse">parse error</a>. Ignore the token.</p>
+         is a <a href="#parse0">parse error</a>. Ignore the token.</p>
 
         <p>Otherwise:</p>
 
@@ -39811,7 +41370,7 @@
         <p>If the <a href="#stack">stack of open elements</a> does not <a
          href="#have-an0" title="has an element in table scope">have a
          <code>tbody</code>, <code>thead</code>, or <code>tfoot</code>
-         element in table scope</a>, this is a <a href="#parse">parse
+         element in table scope</a>, this is a <a href="#parse0">parse
          error</a>. Ignore the token. (<a href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise:</p>
@@ -39827,7 +41386,7 @@
         "colgroup", "html", "td", "th", "tr"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>Anything else
 
@@ -39845,7 +41404,7 @@
        href="#thead0">thead</a></code>, or <code><a
        href="#html">html</a></code> element, pop elements from the <a
        href="#stack">stack of open elements</a>. If this causes any elements
-       to be popped from the stack, then this is a <a href="#parse">parse
+       to be popped from the stack, then this is a <a href="#parse0">parse
        error</a>.</p>
 
       <p class=note>The <a href="#current4">current node</a> being an
@@ -39877,7 +41436,7 @@
         <p>If the <a href="#stack">stack of open elements</a> does not <a
          href="#have-an0" title="has an element in table scope">have an
          element in table scope</a> with the same tag name as the token, this
-         is a <a href="#parse">parse error</a>. Ignore the token. (<a
+         is a <a href="#parse0">parse error</a>. Ignore the token. (<a
          href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise:</p>
@@ -39909,7 +41468,7 @@
         <p>If the <a href="#stack">stack of open elements</a> does not <a
          href="#have-an0" title="has an element in table scope">have an
          element in table scope</a> with the same tag name as the token, this
-         is a <a href="#parse">parse error</a>. Ignore the token.</p>
+         is a <a href="#parse0">parse error</a>. Ignore the token.</p>
 
         <p>Otherwise, act as if an end tag with the tag name "tr" had been
          seen, then reprocess the current token.</p>
@@ -39918,7 +41477,7 @@
         "colgroup", "html", "td", "th"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>Anything else
 
@@ -39934,7 +41493,7 @@
        href="#tr">tr</a></code> element or an <code><a
        href="#html">html</a></code> element, pop elements from the <a
        href="#stack">stack of open elements</a>. If this causes any elements
-       to be popped from the stack, then this is a <a href="#parse">parse
+       to be popped from the stack, then this is a <a href="#parse0">parse
        error</a>.</p>
 
       <p class=note>The <a href="#current4">current node</a> being an
@@ -39952,8 +41511,8 @@
         <p>If the <a href="#stack">stack of open elements</a> does not <a
          href="#have-an0" title="has an element in table scope">have an
          element in table scope</a> with the same tag name as that of the
-         token, then this is a <a href="#parse">parse error</a> and the token
-         must be ignored.</p>
+         token, then this is a <a href="#parse0">parse error</a> and the
+         token must be ignored.</p>
 
         <p>Otherwise:</p>
 
@@ -39962,7 +41521,7 @@
 
         <p>Now, if the <a href="#current4">current node</a> is not an element
          with the same tag name as the token, then this is a <a
-         href="#parse">parse error</a>.</p>
+         href="#parse0">parse error</a>.</p>
 
         <p>Pop elements from this stack until an element with the same tag
          name as the token has been popped from the stack.</p>
@@ -39982,7 +41541,7 @@
         <p>If the <a href="#stack">stack of open elements</a> does
          <em>not</em> <a href="#have-an0" title="has an element in table
          scope">have a <code>td</code> or <code>th</code> element in table
-         scope</a>, then this is a <a href="#parse">parse error</a>; ignore
+         scope</a>, then this is a <a href="#parse0">parse error</a>; ignore
          the token. (<a href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise, <a href="#close2">close the cell</a> (see below) and
@@ -39992,7 +41551,7 @@
         "colgroup", "html"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
        <dt>An end tag whose tag name is one of: "table", "tbody", "tfoot",
         "thead", "tr"
@@ -40003,7 +41562,7 @@
          element in table scope</a> with the same tag name as that of the
          token (which can only happen for "tbody", "tfoot" and "thead", or,
          in the <a href="#fragment">fragment case</a>), then this is a <a
-         href="#parse">parse error</a> and the token must be ignored.</p>
+         href="#parse0">parse error</a> and the token must be ignored.</p>
 
         <p>Otherwise, <a href="#close2">close the cell</a> (see below) and
          reprocess the current token.</p>
@@ -40096,7 +41655,7 @@
         <p>If the <a href="#current4">current node</a> is an
          <code>optgroup</code> element, then pop that node from the <a
          href="#stack">stack of open elements</a>. Otherwise, this is a <a
-         href="#parse">parse error</a>, ignore the token.</p>
+         href="#parse0">parse error</a>, ignore the token.</p>
 
        <dt>An end tag whose tag name is "option"
 
@@ -40104,7 +41663,7 @@
         <p>If the <a href="#current4">current node</a> is an
          <code>option</code> element, then pop that node from the <a
          href="#stack">stack of open elements</a>. Otherwise, this is a <a
-         href="#parse">parse error</a>, ignore the token.</p>
+         href="#parse0">parse error</a>, ignore the token.</p>
 
        <dt>An end tag whose tag name is "select"
 
@@ -40112,7 +41671,7 @@
         <p>If the <a href="#stack">stack of open elements</a> does not <a
          href="#have-an0" title="has an element in table scope">have an
          element in table scope</a> with the same tag name as the token, this
-         is a <a href="#parse">parse error</a>. Ignore the token. (<a
+         is a <a href="#parse0">parse error</a>. Ignore the token. (<a
          href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise:</p>
@@ -40125,14 +41684,14 @@
        <dt>A start tag whose tag name is "select"
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Act as if the token had been an
+        <p><a href="#parse0">Parse error</a>. Act as if the token had been an
          end tag with the tag name "select" instead.</p>
 
        <dt>An end tag whose tag name is one of: "caption", "table", "tbody",
         "tfoot", "thead", "tr", "td", "th"
 
        <dd>
-        <p><a href="#parse">Parse error</a>.</p>
+        <p><a href="#parse0">Parse error</a>.</p>
 
         <p>If the <a href="#stack">stack of open elements</a> <a
          href="#have-an0">has an element in table scope</a> with the same tag
@@ -40143,7 +41702,7 @@
        <dt>Anything else
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
       </dl>
 
      <dt id=parsing-main-afterbody>If the <a href="#insertion0">insertion
@@ -40177,7 +41736,7 @@
        <dd>
         <p>If the parser was originally created as part of the <a
          href="#html-fragment0">HTML fragment parsing algorithm</a>, this is
-         a <a href="#parse">parse error</a>; ignore the token. (The element
+         a <a href="#parse0">parse error</a>; ignore the token. (The element
          will be an <code><a href="#html">html</a></code> element in this
          case.) (<a href="#fragment">fragment case</a>)</p>
 
@@ -40187,7 +41746,7 @@
        <dt>Anything else
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Set the <a
+        <p><a href="#parse0">Parse error</a>. Set the <a
          href="#insertion0">insertion mode</a> to "<a href="#in-body"
          title="insertion mode: in body">in body</a>" and reprocess the
          token.</p>
@@ -40228,7 +41787,7 @@
        <dd>
         <p>If the <a href="#current4">current node</a> is the root <code><a
          href="#html">html</a></code> element, then this is a <a
-         href="#parse">parse error</a>; ignore the token. (<a
+         href="#parse0">parse error</a>; ignore the token. (<a
          href="#fragment">fragment case</a>)</p>
 
         <p>Otherwise, pop the <a href="#current4">current node</a> from the
@@ -40259,7 +41818,7 @@
        <dt>Anything else
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
       </dl>
 
      <dt id=parsing-main-afterframeset>If the <a href="#insertion0">insertion
@@ -40301,7 +41860,7 @@
        <dt>Anything else
 
        <dd>
-        <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+        <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
       </dl>
     </dl>
   </dl>
@@ -40321,7 +41880,7 @@
    <dt>A DOCTYPE token
 
    <dd>
-    <p><a href="#parse">Parse error</a>. Ignore the token.</p>
+    <p><a href="#parse0">Parse error</a>. Ignore the token.</p>
 
    <dt>A comment token
 
@@ -40352,7 +41911,7 @@
    <dt>An end tag token
 
    <dd>
-    <p><a href="#parse">Parse error</a>. Switch back to <a
+    <p><a href="#parse0">Parse error</a>. Switch back to <a
      href="#the-main0">the main phase</a> and reprocess the token.</p>
 
    <dt>An end-of-file token
@@ -40642,7 +42201,7 @@
    element's <span title=syntax-start-tag>start tag</span> would imply the
    end tag for the <code><a href="#p">p</a></code>).
 
-  <h3 id=parsing1><span class=secno>8.5. </span>Parsing HTML fragments</h3>
+  <h3 id=parsing2><span class=secno>8.5. </span>Parsing HTML fragments</h3>
 
   <p>The following steps form the <dfn id=html-fragment0>HTML fragment
    parsing algorithm</dfn>. The algorithm takes as input a DOM

Modified: source
===================================================================
--- source	2007-09-25 09:54:15 UTC (rev 1036)
+++ source	2007-10-08 19:28:51 UTC (rev 1037)
@@ -221,6 +221,12 @@
   specification. <a href="#refsRFC2119">[RFC2119]</a></p>
   <!-- XXX but they should be marked up -->
 
+  <p>Requirements phrased in the imperative as part of algorithms
+  (such as "strip any leading space characters" or "return false and
+  abort these steps") are to be interpreted with the meaning of the
+  key word ("must", "should", "may", etc) used in introducing the
+  algorithm.</p>
+
   <p>This specification describes the conformance criteria for user
   agents (relevant to implementors) and documents (relevant to
   authors and authoring tool implementors).</p>
@@ -705,11 +711,10 @@
 
   <p>For readability, the term URI is used to refer to both ASCII URIs
   and Unicode IRIs, as those terms are defined by RFC 3986 and RFC
-  3987 respectively, and as modified by RFC 2732. On the rare
-  occasions where IRIs are not allowed but ASCII URIs are, this is
-  called out explicitly. <a href="#refsRFC3986">[RFC3986]</a> <a
-  href="#refsRFC3987">[RFC3987]</a> <a
-  href="#refsRFC2732">[RFC2732]</a></p>
+  3987 respectively. On the rare occasions where IRIs are not allowed
+  but ASCII URIs are, this is called out explicitly. <a
+  href="#refsRFC3986">[RFC3986]</a> <a
+  href="#refsRFC3987">[RFC3987]</a></p>
 
   <p>The term <dfn>root element</dfn>, when not qualified to
   explicitly refer to the document's root element, means the furthest
@@ -1007,7 +1012,7 @@
   <p>If the <code>Document</code> object's <span title="the document's
   address">address</span><!-- XXX xref --> is hierarchical and uses a
   server-based naming authority, then its <dfn title="document's
-  domain">domain</dfn> is the <hostname> part of that
+  domain">domain</dfn> is the <host>/<ihost> part of that
   address. Otherwise, it has no domain.</p>
 
   <p class="note">The <code title="dom-document-domain">domain</code>
@@ -1015,6 +1020,8 @@
   access each others' DOMs<span class="big-issue">, though this is not
   yet defined by this specification</span>.</p><!-- XXX xref -->
 
+  <p class="big-issue">we should handle IP addresses here</p>
+
   <!--XXX
     http://lxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp
     search for ::GetDomain ::SetDomain
@@ -22265,6 +22272,8 @@
   <p>Access to certain APIs is granted or denied to scripts based on
   the <dfn>origin</dfn> of the script and the API being accessed.</p>
 
+  <p>The origin of a script depends on the context of that script:</p>
+
   <dl>
 
    <dt>If a script is in a <code>script</code> element</dt>
@@ -22333,15 +22342,14 @@
   <p>The origin of a <code>Document</code> or image that was served
   over the network and whose address uses a URI scheme with a
   server-based naming authority is the tuple consisting of the
-  <scheme>, <host>, and <port> parts of the
-  <code>Document</code>'s full URI. <a
+  <scheme>, <host>/<ihost>, and <port> parts
+  of the <code>Document</code>'s full URI. <a
   href="#refsRFC3986">[RFC3986]</a> <a
-  href="#refsRFC3987">[RFC3987]</a> <a
-  href="#refsRFC2732">[RFC2732]</a></p>
+  href="#refsRFC3987">[RFC3987]</a></p>
 
   <p>The origin of a <code>Document</code> or image that was generated
   from a <code>data:</code> URI found in another <code>Document</code>
-  or in a script is the origin of the that <code>Document</code> or
+  or in a script is the origin of the <code>Document</code> or
   script.</p>
 
   <p>The origin of a <code>Document</code> or image that was generated
@@ -22373,6 +22381,100 @@
   not to include the IP in the origin for a host?</p>
 
 
+  <h4>Unscripted same-origin checks</h4>
+
+  <p>When two URIs are to be compared to determine if they have the
+  <dfn>same scheme/host/port</dfn>, it means that the following
+  algorithm must be invoked, where <var title="">uri<sub
+  title="">1</sub></var> and <var title="">uri<sub
+  title="">2</sub></var> are the two URIs.</p>
+
+  <ol>
+
+   <li>
+
+    <p>First, both <var title="">uri<sub title="">1</sub></var> and
+    <var title="">uri<sub title="">2</sub></var> must be normalized to
+    obtain the two tuples (<var title="">scheme<sub
+    title="">1</sub></var>, <var title="">host<sub
+    title="">1</sub></var>, <var title="">port<sub
+    title="">1</sub></var>) and (<var title="">scheme<sub
+    title="">2</sub></var>, <var title="">host<sub
+    title="">2</sub></var>, <var title="">port<sub
+    title="">2</sub></var>), by applying the following subalgorithm to
+    each URI:</p>
+
+    <ol>
+
+     <li><p>Let <var title="">uri</var> be the URI being normalized.</p></li>
+
+     <li><p>Parse <var title="">uri</var> according to the rules
+     described in RFC 3986 and RFC 3987. <a
+     href="#refsRFC3986">[RFC3986]</a> <a
+     href="#refsRFC3987">[RFC3987]</a></p></li>
+
+     <li><p>If <var title="">uri</var> does not use a server-based
+     naming authority, then fail the overall algorithm — the two
+     URIs do not have the same scheme/host/port.</p></li>
+
+     <li><p>Let <var title="">scheme</var> be the <scheme>
+     component of the URI. If the UA doesn't support the given
+     protocol, then fail the overall algorithm — the two URIs do
+     not have the same scheme/host/port<!-- (this should not be
+     possible, since this algorithm is only invoked with URIs that
+     have been actually fetched) -->.</p></li>
+
+     <li><p>Let <var title="">host</var> be the
+     <host>/<ihost> component of the URI.</p></li>
+
+     <li>
+
+      <p>Apply the IDNA ToASCII algorithm to <var title="">host</var>,
+      with both the AllowUnassigned and UseSTD3ASCIIRules flags
+      set. Let <var title="">host</var> be the result of the ToASCII
+      algorithm.</p>
+
+      <p>If ToASCII fails to convert one of the components of the
+      string, e.g. because it is too long or because it contains
+      invalid characters, then fail the overall algorithm — the
+      two URIs do not have the same scheme/host/port. <a
+      href="#refsRFC3490">[RFC3490]</a></p>
+
+     </li>
+
+     <li><p>If no port is explicitly listed, then let <var
+     title="">port</var> be the default port for the protocol given by
+     <var title="">scheme</var>. Otherwise, let <var
+     title="">port</var> be the <port> component of the
+     URI.</p></li>
+
+     <li><p>Return the tuple (<var title="">scheme</var>, <var
+     title="">host</var>, <var title="">port</var>).</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>If <var title="">scheme<sub title="">1</sub></var> is not
+   case-insensitively<!-- XXX ascii case matching --> identical to
+   <var title="">scheme<sub title="">2</sub></var>, or if <var
+   title="">host<sub title="">1</sub></var> is not
+   case-insensitively<!-- XXX ascii case matching --> identical to
+   <var title="">host<sub title="">2</sub></var>, or if <var
+   title="">port<sub title="">1</sub></var> is not identical to <var
+   title="">port<sub title="">2</sub></var>, then fail the overall
+   algorithm — the two URIs do not have the same
+   scheme/host/port.</p></li>
+
+   <li><p>Otherwise, the two URIs do have the same
+   scheme/host/port.</p></li>
+
+  </ol>
+
+  
+
+
+
   <h4>Security exceptions</h4>
 
   <p class="big-issue">Define <dfn>security exception</dfn>.</p>
@@ -22523,6 +22625,7 @@
   as DOM attributes:</p>
 
   <dl>
+   <!-- XXX should change 'the element' below to 'the object' or something -->
 
    <dt><dfn title="handler-onabort"><code>onabort</code></dfn></dt>
 
@@ -23025,33 +23128,6 @@
 <!-- XXX there are other attributes! -->};</pre>
 <!-- also, see window.external.AddSearchProvider() and similar DOM APIs from IE -->
 
-  <h4 id="offline">Offline Web applications</h4>
-
-  <p>The <dfn
-  title="dom-navigator-onLine"><code>navigator.onLine</code></dfn>
-  attribute must return false if the user agent will not contact the
-  network when the user follows links or when a script requests a
-  remote page (or knows that such an attempt would fail), and must
-  return true otherwise.</p>
-
-  <p>The <dfn title="event-offline"><code>offline</code></dfn> event
-  must be fired when the value of the <code
-  title="dom-navigator-onLine">navigator.onLine</code> attribute of
-  the <code>Window</code> changes from true to false.</p>
-
-  <p>The <dfn title="event-online"><code>online</code></dfn> event
-  must be fired when the value of the <code
-  title="dom-navigator-onLine">navigator.onLine</code> attribute of
-  the <code>Window</code> changes from false to true.</p>
-
-  <p>These events are in no namespace, do bubble, are not cancelable,
-  have no default action, and use the normal <code>Event</code>
-  interface. They must be fired on <span>the body element</span>. (As
-  the events bubble, they will reach the <code>Window</code>
-  object.)</p>
-
-  <!-- XXX ononline onoffline need to be defined -->
-
   <h4 id="custom-handlers">Custom protocol and content handlers</h4>
 
   <p>The <dfn
@@ -23201,10 +23277,10 @@
   arguments in an ECMAScript implementation).</p>
 
   <p>This section does not define how the pages registered by these
-  methods are used, beyond the requirements on how to process the
-  <var title="">uri</var> value (see above). To some extent, the <span
-  title="navigating across documents">processing model for navigating
-  across documents</span> defines some cases where these methods are
+  methods are used, beyond the requirements on how to process the <var
+  title="">uri</var> value (see above). To some extent, the <span
+  title="navigate">processing model for navigating across
+  documents</span> defines some cases where these methods are
   relevant, but in general UAs may use this information wherever they
   would otherwise consider handing content to native plugins or helper
   applications.</p>
@@ -23383,6 +23459,1372 @@
 
 
 
+
+  <h3 id="offline">Offline Web applications</h3>
+
+  <h4>Introduction</h4>
+
+  <p class="big-issue">...</p>
+
+
+  <h4 id="appcache">Application caches</h4>
+
+  <p>An <dfn>application cache</dfn> is a collection of resources. An
+  application cache is identified by the URI of a resource
+  manifest which is used to populate the cache.</p>
+
+  <p>Application caches are versioned, and there can be different
+  instances of caches for the same manifest URI, each having a
+  different version.</p>
+
+  <p>Each group of application caches for the same manifest URI have a
+  common <dfn title="concept-appcache-status">update status</dfn>,
+  which is one of the following: <i>idle</i>, <i>checking</i>,
+  <i>downloading</i>, <i>update ready</i>.</p>
+
+  <p id="#appcache-history-1">A <span>browsing context</span> can be
+  associated with an application cache. A <span>child browsing
+  context</span> is always associated with the same browsing context
+  as its <span>parent browsing context</span>, if any. A
+  <span>top-level browsing context</span> is associated with the
+  application cache appropriate for its <span>active
+  document</span>. (A browsing context's associated cache thus can <a
+  href="#appcache-history-2">change</a> during <span title="traverse
+  the history">session history traversal</span>.)</p>
+
+  <p>A <code>Document</code> initially has no appropriate cache, but
+  steps <a href="#parser-appcache">in the parser</a> and in the <span
+  title="navigate">navigation</span> sections cause <span
+  title="concept-appcache-init-with-attribute">cache selection</span>
+  to occur early in the page load process.</p>
+
+  <p>An application cache consists of:</p>
+
+  <ul>
+
+   <li>
+
+    <p>One of more resources (including their out-of-band metadata,
+    such as HTTP headers, if any), identified by URIs, each falling
+    into one (or more) of the following categories:</p>
+
+    <dl>
+ 
+     <dt><dfn title="concept-appcache-implicit">Implicit entries</dfn>
+
+     <dd>Resources that were added to the cache because a
+     <span>top-level browsing context</span> was <span
+     title="navigate">navigated</span> to that document and the
+     document indicated that this was its cache, using the <code
+     title="attr-html-application">application</code> attribute.
+
+ 
+     <dt><dfn title="concept-appcache-manifest">The manifest</dfn>
+
+     <dd>The resource corresponding to the URI that was given in an
+     implicit entry's <code>html</code> element's <code
+     title="attr-html-application">application</code> attribute. The
+     manifest is downloaded and processed during the <span>application
+     cache update process</span>. All the <span
+     title="concept-appcache-implicit">implicit entries</span> have
+     the <span>same scheme/host/port</span> as the manifest.
+
+ 
+     <dt><dfn title="concept-appcache-explicit">Explicit entries</dfn>
+
+     <dd>Resources that were listed in the cache's <span
+     title="concept-appcache-manifest">manifest</span>. Explicit
+     entries can also be marked as <dfn
+     title="concept-appcache-foreign">foreign</dfn>, which means that they
+     have an <code title="attr-html-application">application</code>
+     attribute but that it doesn't point at this cache's <span
+     title="concept-appcache-manifest">manifest</span>.
+
+ 
+     <dt><dfn title="concept-appcache-fallback">Fallback entries</dfn>
+
+     <dd>Resources that were listed in the cache's <span
+     title="concept-appcache-manifest">manifest</span> as fallback
+     entries.
+
+ 
+     <dt><dfn title="concept-appcache-oppcache">Opportunistically cached entries</dfn>
+
+     <dd>Resources whose URIs <span
+     title="concept-appcache-matches-oppcache">matched</span> an <span
+     title="concept-appcache-oppcache-ns">opportunistic caching
+     namespace</span> when they were fetched, and were therefore
+     cached in the application cache.
+
+ 
+     <dt><dfn title="concept-appcache-dynamic">Dynamic entries</dfn>
+
+     <dd>Resources that were added to the cache by the <code
+     title="dom-appcache-add">add()</code> method.
+
+    </dl>
+
+   <li>Zero or more <dfn
+   title="concept-appcache-oppcache-ns">opportunistic caching
+   namespaces</dfn>: URIs, used as <span
+   title="concept-appcache-matches-oppcache">prefix match
+   patterns</span>, each of which is mapped to a <span
+   title="concept-appcache-fallback">fallback entry</span>. Each
+   namespace URI prefix, when parsed as a URI, has the <span>same
+   scheme/host/port</span> as <span
+   title="concept-appcache-manifest">the manifest</span>.</li>
+
+   <li>Zero or more URIs that form the <dfn
+   title="concept-appcache-onlinewhitelist">online whitelist</dfn>.
+
+  </ul>
+
+  <p>Multiple application caches can contain the same resource,
+  e.g. if their manifests all reference that resource. If the user
+  agent is to <dfn title="concept-appcache-selection">select an
+  application cache</dfn> from a list of caches that contain a
+  resource, that the user agent must use the application cache that
+  the user most likely wants to see the resource from, taking into
+  account the following:</p>
+
+  <ul>
+
+   <li>which application cache was most recently updated,
+
+   <li>which application cache was being used to display the
+   resource from which the user decided to look at the new resource,
+   and
+
+   <li>which application cache the user prefers.</li>
+
+  </ul>
+
+
+  <h4 id="manifests">The cache manifest syntax</h4>
+
+  <h5>Writing cache manifests</h5>
+
+  <p>Manifests must be served using the <code
+  title="">text/cache-manifest</code> MIME type. All resources served
+  using the <code title="">text/cache-manifest</code> MIME type must
+  follow the syntax of application cache manifests, as described in
+  this section.</p>
+
+  <p>An application cache manifest is a text file, whose text is
+  encoded using UTF-8. Data in application cache manifests is
+  line-based. Newlines must be represented by U+000A LINE FEED (LF)
+  characters, U+000D CARRIAGE RETURN (CR) characters, or U+000D
+  CARRIAGE RETURN (CR) U+000A LINE FEED (LF) pairs.</p>
+
+  <p class="note">This is a willful double violation of RFC2046.</p>
+
+  <p>The first line of an application cache manifest must consist of
+  the string "CACHE", a single U+0020 SPACE character, the string
+  "MANIFEST", and zero or more U+0020 SPACE and U+0009 CHARACTER
+  TABULATION (tab) characters. If any other text is found on the first
+  line, the user agent will ignore the entire file. The first line may
+  optionally be preceded by a U+FEFF BYTE ORDER MARK (BOM)
+  character.</p>
+
+  <p>Subsequent lines, if any, must all be one of the following:</p>
+
+  <dl>
+   <dt>A blank line
+   <dd>
+    <p>Blank lines must consist of zero or more U+0020 SPACE and
+    U+0009 CHARACTER TABULATION (tab) characters only.</p>
+
+   <dt>A comment
+   <dd>
+    <p>Comment lines must consist of zero or more U+0020 SPACE and
+    U+0009 CHARACTER TABULATION (tab) characters, followed by a single
+    U+0023 NUMBER SIGN (#) character, followed by zero or more
+    characters other than U+000A LINE FEED (LF) and U+000D CARRIAGE
+    RETURN (CR) characters.</p>
+
+    <p class="note">Comments must be on a line on their own. If they
+    were to be included on a line with a URI, the "#" would be
+    mistaken for part of a fragment identifier.</p>
+
+   <dt>A section header
+   <dd>
+    <p>Section headers change the current section. There are three
+    possible section headers:
+
+    <dl>
+
+     <dt><code>CACHE:</code>
+     <dd>Switches to the explicit section.
+
+     <dt><code>FALLBACK:</code>
+     <dd>Switches to the fallback section.
+
+     <dt><code>NETWORK:</code>
+     <dd>Switches to the online whitelist section.
+
+    </dl>
+
+    <p>Section header lines must consist of zero or more U+0020 SPACE
+    and U+0009 CHARACTER TABULATION (tab) characters, followed by one
+    of the names above (including the U+003A COLON (:) character)
+    followed by zero or more U+0020 SPACE and U+0009 CHARACTER
+    TABULATION (tab) characters.</p>
+
+    <p>Ironically, by default, the current section is the explicit
+    section.</p>
+
+   <dt>Data for the current section
+   <dd>
+    <p>The format that data lines must take depends on the current
+    section.</p>
+
+    <p>When the current section is the explicit section or the online
+    whitelist section, data lines must consist of zero or more U+0020
+    SPACE and U+0009 CHARACTER TABULATION (tab) characters, a valid
+    URI reference or IRI reference, and then zero or more U+0020 SPACE
+    and U+0009 CHARACTER TABULATION (tab) characters. <a
+    href="#refsRFC3986">[RFC3986]</a> <a
+    href="#refsRFC3987">[RFC3987]</a></p>
+
+    <p>When the current section is the fallback section, data lines
+    must consist of zero or more U+0020 SPACE and U+0009 CHARACTER
+    TABULATION (tab) characters, a valid URI reference or IRI
+    reference, one or more U+0020 SPACE and U+0009 CHARACTER
+    TABULATION (tab) characters, another valid URI reference or IRI
+    reference, and then zero or more U+0020 SPACE and U+0009 CHARACTER
+    TABULATION (tab) characters. <a href="#refsRFC3986">[RFC3986]</a>
+    <a href="#refsRFC3987">[RFC3987]</a></p>
+
+  </dl>
+
+  <p>Manifests may contain sections more than once. Sections may be
+  empty.</p>
+
+  <p>Manifests must specify all the URIs that are to be cached. URIs
+  that are to be fallback pages associated with <span
+  title="concept-appcache-oppcache-ns">opportunistic caching
+  namespaces</span>, and those namespaces themselves, must be given in
+  fallback sections, with the namespace being the first URI of the
+  data line, and the corresponding fallback page being the second
+  URI. All the other pages to be cached must be listed in explicit
+  sections.</p>
+
+  <p>Relative URIs must be given relative to the manifest's own
+  URI.</p>
+
+  <p>URIs in manifests must not have fragment identifiers.</p>
+
+  <p><span title="concept-appcache-oppcache-ns">Opportunistic caching
+  namespaces</span> must have the <span>same scheme/host/port</span>
+  as the manifest itself.</p>
+
+  <p>An opportunistic caching namespace must not be listed more than
+  once.</p>
+
+  <p>URIs that the user agent is to put into the <span
+  title="concept-appcache-onlinewhitelist">online whitelist</span>
+  must all be specified in online whitelist sections. (This is needed
+  for any URI that the page is intending to use to communicate back to
+  the server.)</p>
+
+  <p>URIs in the online whitelist section must not also be listed in
+  explicit section, and must not be listed as fallback entries in the
+  fallback section. (URIs in the online whitelist section may match
+  opportunistic caching namespaces, however.)</p>
+
+
+  <h5>Parsing cache manifests</h5>
+
+  <p>When a user agent is to <dfn>parse a manifest</dfn>, it means
+  that the user agent must run the following steps:</p>
+
+  <ol>
+   
+   <li><p>The user agent must decode the bytestream corresponding with
+   the manifest to be parsed, treating it as UTF-8. Bytes or sequences
+   of bytes that are not valid UTF-8 sequences must be interpreted as
+   a U+FFFD REPLACEMENT CHARACTER. All U+0000 NULL characters must be
+   replaced by U+FFFD REPLACEMENT CHARACTERs.</p></li>
+
+   <li><p>Let <var title="">explicit URIs</var> be an initially empty
+   list of <span title="concept-appcache-explicit">explicit
+   entries</span>.</p></li>
+
+   <li><p>Let <var title="">fallback URIs</var> be an initially empty
+   mapping of <span title="concept-appcache-oppcache-ns">opportunistic
+   caching namespaces</span> to <span
+   title="concept-appcache-fallback">fallback entries</span>.</p></li>
+
+   <li><p>Let <var title="">online whitelist URIs</var> be an
+   initially empty list of URIs for a <span
+   title="concept-appcache-onlinewhitelist">online
+   whitelist</span>.</p></li>
+
+   <li><p>Let <var title="">input</var> be the decoded text of the
+   manifest's bytestream.</p></li>
+
+   <li><p>Let <var title="">position</var> be a pointer into <var
+   title="">input</var>, initially pointing at the first
+   character.</p></li>
+
+   <li><p>If <var title="">position</var> is pointing at a U+FEFF BYTE
+   ORDER MARK (BOM) character, then advance <var
+   title="">position</var> to the next character.</p></li>
+
+   <li><p>If the characters starting from <var title="">position</var>
+   are "CACHE", followed by a U+0020 SPACE character, followed by
+   "MANIFEST", then advance <var title="">position</var> to the next
+   character after those. Otherwise, this isn't a cache manifest;
+   abort this algorithm with a failure while checking for the magic
+   signature.</p></li>
+
+   <li><p>If <var title="">position</var> is not past the end of <var
+   title="">input</var> and the character at <var
+   title="">position</var> is neither a U+000A LINE FEED (LF)
+   characters nor a U+000D CARRIAGE RETURN (CR) character, then this
+   isn't a cache manifest; abort this algorithm with a failure while
+   checking for the magic signature.</p></li>
+
+   <li><p>This is a cache manifest. The algorithm cannot fail beyond
+   this point (though bogus lines can get ignored).</p></li>
+
+   <li><p>Let <var title="">mode</var> be "explicit".</p></li>
+
+   <li><p><em>Start of line</em>: If <var title="">position</var> is
+   past the end of <var title="">input</var>, then jump to the last
+   step. Otherwise, <span>collect a sequence of characters</span> that
+   are U+000A LINE FEED (LF), U+000D CARRIAGE RETURN (CR), U+0020
+   SPACE, or U+0009 CHARACTER TABULATION (tab) characters.</p></li>
+
+   <li><p>Now, <span>collect a sequence of characters</span> that are
+   <em>not</em> U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)
+   characters, and let the result be <var
+   title="">line</var>.</p></li>
+
+   <li><p>If the first character in <var title="">line</var> is a
+   U+0023 NUMBER SIGN (#) character, then jump back to the step
+   labelled "start of line".</p></li>
+
+   <li><p>Drop any trailing U+0020 SPACE, or U+0009 CHARACTER
+   TABULATION (tab) characters at the end of <var
+   title="">line</var>.</p></li>
+
+   <li><p>If <var title="">line</var> equals "CACHE:" (the word
+   "CACHE" followed by a U+003A COLON (:) character), then set <var
+   title="">mode</var> to "explicit" and jump back to the step
+   labelled "start of line".</p></li>
+
+   <li><p>If <var title="">line</var> equals "FALLBACK:" (the word
+   "FALLBACK" followed by a U+003A COLON (:) character), then set <var
+   title="">mode</var> to "fallback" and jump back to the step
+   labelled "start of line".</p></li>
+
+   <li><p>If <var title="">line</var> equals "NETWORK:" (the word
+   "NETWORK" followed by a U+003A COLON (:) character), then set <var
+   title="">mode</var> to "online whitelist" and jump back to the step
+   labelled "start of line".</p></li>
+
+   <li>
+
+    <p>This is either a data line or it is syntactically incorrect.</p>
+
+    <dl class="switch">
+
+     <dt>If <var title="">mode</var> is "explicit"</dt>
+
+     <dd>
+
+      <p>If <var title="">line</var> is not a syntactically valid URI
+      reference or IRI reference, then jump back to the step labelled
+      "start of line".</p>
+
+      <p>Otherwise, resolve the URI reference or IRI reference to an
+      absolute URI or IRI, drop any fragment identifier, and add this
+      URI to the <var title="">explicit URIs</var>.</p>
+
+     </dd>
+
+     <dt>If <var title="">mode</var> is "fallback"</dt>
+
+     <dd>
+
+      <p>If <var title="">line</var> does not contain at least one
+      U+0020 SPACE or U+0009 CHARACTER TABULATION (tab) character,
+      then jump back to the step labelled "start of line".</p>
+
+      <p>Otherwise, let everything before the first U+0020 SPACE or
+      U+0009 CHARACTER TABULATION (tab) character in <var
+      title="">line</var> be <var title="">part one</var>, and let
+      everything after the first U+0020 SPACE or U+0009 CHARACTER
+      TABULATION (tab) character in <var title="">line</var> be <var
+      title="">part two</var>.</p>
+
+      <p>Strip any leading U+0020 SPACE or U+0009 CHARACTER TABULATION
+      (tab) characters in <var title="">part two</var>.</p>
+
+      <p>If <var title="">part one</var> and <var title="">part
+      two</var> are not both syntactically valid URI or IRI
+      references, then jump back to the step labelled "start of
+      line".</p>
+
+      <p>Resolve the URI or IRI references in <var title="">part
+      one</var> and <var title="">part two</var> to absolute URIs or
+      IRIs.</p>
+
+      <p>If the absolute URI or IRI corresponding to <var
+      title="">part one</var> is already in the <var title="">fallback
+      URIs</var> mapping as an <span
+      title="concept-appcache-oppcache-ns">opportunistic caching
+      namespaces</span>, then jump back to the step labelled "start of
+      line".</p>
+
+      <p>If the absolute URI or IRI corresponding to <var
+      title="">part one</var> does not have the <span>same
+      scheme/host/port</span> as the manifest's URI, then jump back to
+      the step labelled "start of line".</p> <!-- SECURITY -->
+
+      <p>Otherwise, add the absolute URI or IRI corresponding to <var
+      title="">part one</var> to the <var title="">fallback URIs</var>
+      mapping as an <span
+      title="concept-appcache-oppcache-ns">opportunistic caching
+      namespaces</span>, mapped to the absolute URI corresponding to
+      <var title="">part two</var> as the <span
+      title="concept-appcache-fallback">fallback entry</span>.</p>
+
+     </dd>
+
+     <dt>If <var title="">mode</var> is "online whitelist"</dt>
+
+     <dd>
+
+      <p>If <var title="">line</var> is not a syntactically valid URI
+      reference or IRI reference, then jump back to the step labelled
+      "start of line".</p>
+
+      <p>Otherwise, resolve the URI reference or IRI reference to an
+      absolute URI or IRI, drop any fragment identifier, and add this
+      URI to the <var title="">online whitelist URIs</var>.</p>
+
+     </dd>
+
+    </dl>
+
+   </li>
+
+   <li><p>Jump back to the step labelled "start of line". (That step
+   jumps to the next, and last, step when the end of the file is
+   reached.)</p></li>
+
+   <li><p>Return the <var title="">explicit URIs</var> list, the <var
+   title="">fallback URIs</var> mapping, and the <var title="">online
+   URIs</var>.</p></li>
+
+  </ol>
+
+  <p>Relative URI references and IRI references resolved to absolute
+  URIs or IRIs in the above algorithm must use the manifest's URI as
+  the Base URI from the Retrieval URI for the purposes reference
+  resolution as defined by RFC 3986. <a
+  href="#refsRFC3986">[RFC3986]</a></p>
+
+
+  <h4>Updating an application cache</h4>
+
+  <p>When the user agent is required (by other parts of this
+  specification) to start the <dfn>application cache update
+  process</dfn>, the user agent must run the following steps:</p>
+
+  <p class="big-issue">the event stuff needs to be more consistent --
+  something about showing every step of the ui or no steps or
+  something; and we need to deal with showing ui for browsing contexts
+  that open when an update is already in progress, and we may need to
+  give applications control over the ui the first time they cache
+  themselves (right now the original cache is done without
+  notifications to the browsing contexts)</p>
+
+  <ol>
+
+   <li><p>Let <var title="">manifest URI</var> be the URI of the <span
+   title="concept-appcache-manifest">manifest</span> of the cache to
+   be updated.</p></li>
+
+   <li><p>Let <var title="">cache group</var> be the group of <span
+   title="application cache">application caches</span> identified by
+   <var title="">manifest URI</var>.</p></li>
+
+   <li><p>Let <var title="">cache</var> be the most recently updated
+   <span>application cache</span> identified by <var title="">manifest
+   URI</var> (that is, the newest version found in <var title="">cache
+   group</var>).</p></li>
+
+   <li><p>If the <span title="concept-appcache-status">status</span>
+   of the <var title="">cache group</var> is either <i>checking</i> or
+   <i>downloading</i>, then abort these steps, as an update is already
+   in progress for them. Otherwise, set the <span title="concept-appcache-status">status</span> of this group of
+   caches to <i>checking</i>. This entire step must be performed as
+   one atomic operation so as to avoid race conditions.</p></li>
+
+   <li>
+
+    <p>If there is already a resource with the URI of <var
+    title="">manifest URI</var> in <var title="">cache</var>, and
+    that resource is categorised as a <span
+    title="concept-appcache-manifest">manifest</span>, then this is an
+    <dfn title="concept-appcache-upgrade">upgrade
+    attempt</dfn>. Otherwise, this is a <dfn
+    title="concept-appcache-cache">cache attempt</dfn>.</p>
+
+    <p class="note">If this is a <span
+    title="concept-appcache-cache">cache attempt</span>, then <var
+    title="">cache</var> is forcibly the only application cache in
+    <var title="">cache group</var>, and it hasn't ever been populated
+    from its manifest (i.e. this update is an attempt to download the
+    application for the first time). It also can't have any browsing
+    contexts associated with it.</p>
+
+   </li>
+
+   <li>
+
+    <p><span>Fire a simple event</span> called <code
+    title="event-checking">checking</code> at the
+    <code>ApplicationCache</code> singleton of each <span>top-level
+    browsing context</span> that is associated with a cache in <var
+    title="">cache group</var>. The default action of this event
+    should be the display of some sort of user interface indicating to
+    the user that the user agent is checking for the availability of
+    updates.</p>
+
+   </li>
+
+   <li>
+
+    <p>Fetch the resource from <var title="">manifest URI</var>, and
+    let <var title="">manifest</var> be that resource.</p>
+
+    <p>If the resource is labelled with the MIME type <code
+    title="">text/cache-manifest</code>, parse <var
+    title="">manifest</var> according to the <span title="parse a
+    manifest">rules for parsing manifests</span>, obtaining a list of
+    <span title="concept-appcache-explicit">explicit entries</span>,
+    <span title="concept-appcache-fallback">fallback entries</span>
+    and the <span title="concept-appcache-oppcache-ns">opportunistic
+    caching namespaces</span> that map to them, and entries for the
+    <span title="concept-appcache-onlinewhitelist">online
+    whitelist</span>.</p>
+
+   </li>
+
+   <li>
+
+    <p>If the previous step fails (e.g. the server returns a 4xx or
+    5xx response or equivalent, or there is a DNS error, or the
+    connection times out, or the parser for manifests fails when
+    checking the magic signature), or if the resource is labelled with
+    a MIME type other than <code title="">text/cache-manifest</code>,
+    then run these substeps:</p>
+
+    <ol>
+
+     <li><p><span>Fire a simple event</span> called <code
+     title="event-error">error</code> at the
+     <code>ApplicationCache</code> singleton of each <span>top-level
+     browsing context</span> that is associated with a cache in <var
+     title="">cache group</var>. The default action of this event
+     should be the display of some sort of user interface indicating
+     to the user that the user agent failed to save the application
+     for offline use.</p></li>
+
+     <li><p>If this is a <span title="concept-appcache-cache">cache
+     attempt</span>, then discard <var title="">cache</var> and abort
+     the update process, optionally alerting the user to the
+     failure.</p></li>
+
+     <li><p>Otherwise, jump to the last step in the overall set of
+     steps of the update process.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>If this is an <span title="concept-appcache-upgrade">upgrade
+   attempt</span> and the newly downloaded <var
+   title="">manifest</var> is byte-for-byte identical to the manifest
+   found in <var title="">cache</var>, or if the server reported it as
+   "304 Not Modified" or equivalent, then <span>fire a simple
+   event</span> called <code title="event-noupdate">noupdate</code> at
+   the <code>ApplicationCache</code> singleton of each <span>top-level
+   browsing context</span> that is associated with a cache in <var
+   title="">cache group</var>. The default action of this event should
+   be the display of some sort of user interface indicating to the
+   user that the application is up to date. Then, jump to the last
+   step of the update process.</p></li>
+
+   <li><p>Set the <span title="concept-appcache-status">status</span> of <var title="">cache group</var> to
+   <i>downloading</i>.</p></li>
+
+   <li><p><span>Fire a simple event</span> called <code
+   title="event-downloading">downloading</code> at the
+   <code>ApplicationCache</code> singleton of each <span>top-level
+   browsing context</span> that is associated with a cache in <var
+   title="">cache group</var>. The default action of this event should
+   be the display of some sort of user interface indicating to the
+   user that a new version is being downloaded.</p></li>
+
+   <li><p>If this is an <span title="concept-appcache-upgrade">upgrade
+   attempt</span>, then let <var title="">new cache</var> be a newly
+   created <span>application cache</span> identified by <span
+   title="">manifest URI</span>, being a new version in <var
+   title="">cache group</var>. Otherwise, let <var title="">new
+   cache</var> and <var title="">cache</var> be the same version of
+   the application cache.</p></li>
+
+   <li><p>Let <var title="">file list</var> be an empty list of
+   URIs with flags.</p></li>
+
+   <li><p>Add all the URIs in the list of <span
+   title="concept-appcache-explicit">explicit entries</span> obtained
+   by parsing <var title="">manifest</var> to <var title="">file
+   list</var>, each flagged with "explicit entry".</p></li>
+
+   <li><p>Add all the URIs in the list of <span
+   title="concept-appcache-fallback">fallback entries</span> obtained
+   by parsing <var title="">manifest</var> to <var title="">file
+   list</var>, each flagged with "fallback entry".</p></li>
+
+   <li><p>If this is an <span title="concept-appcache-upgrade">upgrade
+   attempt</span>, then add all the URIs of <span
+   title="concept-appcache-oppcache">opportunistically cached
+   entries</span> in <var title="">cache</var> that <span
+   title="concept-appcache-matches-oppcache">match</span> the <span
+   title="concept-appcache-oppcache-ns">opportunistic caching
+   namespaces</span> obtained by parsing <var title="">manifest</var>
+   to <var title="">file list</var>, each flagged with "opportunistic
+   entry".</p></li>
+
+   <li><p>If this is an <span title="concept-appcache-upgrade">upgrade
+   attempt</span>, then add all the URIs of <span
+   title="concept-appcache-dynamic">dynamic entries</dfn> in <var
+   title="">cache</var> to <var title="">file list</var>, each flagged
+   with "dynamic entry".</p></li>
+
+   <li><p>If any URI is in <var title="">file list</var> more than
+   once, then merge the entries into one entry for that URI, that
+   entry having all the flags that the original entries had.</p></li>
+
+   <li>
+
+    <p>For each URI in <var title="">file list</var>, run the
+    following steps:</p>
+
+    <ol>
+
+     <li><p><span>Fire a simple event</span> called <code
+     title="event-progress">progress</code> at the
+     <code>ApplicationCache</code> singleton of each <span>top-level
+     browsing context</span> that is associated with a cache in <var
+     title="">cache group</var>. The default action of this event
+     should be the display of some sort of user interface indicating
+     to the user that a file is being downloaded in preparation for
+     updating the application.</p></li> <!-- XXX need to include
+     progress information -->
+
+     <li><p>Fetch the resource. If this is an <span
+     title="concept-appcache-upgrade">upgrade attempt</span>, then use
+     <var title="">cache</var> as an HTTP cache, and honour HTTP
+     caching semantics (such as expiration, ETags, and so forth) with
+     respect to that cache. User agents may also have other caches in
+     place.</p></li>
+
+     <li>
+
+      <p>If the previous steps fails (e.g. the server returns a 4xx or
+      5xx response or equivalent, or there is a DNS error, or the
+      connection times out), then run these substeps:</p>
+
+      <ol>
+
+       <li><p><span>Fire a simple event</span> called <code
+       title="event-error">error</code> at the
+       <code>ApplicationCache</code> singleton of each <span>top-level
+       browsing context</span> that is associated with a cache in <var
+       title="">cache group</var>. The default action of this event
+       should be the display of some sort of user interface indicating
+       to the user that the user agent failed to save the application
+       for offline use.</p></li>
+
+       <li><p>If this is a <span title="concept-appcache-cache">cache
+       attempt</span>, then discard <var title="">cache</var> and
+       abort the update process, optionally alerting the user to the
+       failure.</p></li>
+
+       <li><p>Otherwise, jump to the last step in the overall set of
+       steps of the update process.</p></li>
+
+      </ol>
+
+     </li>
+
+     <li><p>Otherwise, the fetching succeeded. Store the resource in
+     the <var title="">new cache</var>.</p></li>
+
+     <li><p>If the URI being processed was flagged as an "explicit
+     entry" in <var title="">file list</var>, then categorise the
+     entry as an <span title="concept-appcache-explicit">explicit
+     entry</span>.</p></li>
+
+     <li><p>If the URI being processed was flagged as a "fallback
+     entry" in <var title="">file list</var>, then categorise the
+     entry as a <span title="concept-appcache-fallback">fallback
+     entry</span>.</p></li>
+
+     <li><p>If the URI being processed was flagged as a "opportunistic
+     entry" in <var title="">file list</var>, then categorise the
+     entry as an <span
+     title="concept-appcache-oppcache">opportunistically cached
+     entry</span>.</p></li>
+
+     <li><p>If the URI being processed was flagged as an "dynamic
+     entry" in <var title="">file list</var>, then categorise the
+     entry as a <span title="concept-appcache-dynamic">dynamic
+     entry</span>.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>Store <var title="">manifest</var> in <var title="">new
+   cache</var>, if it's not there already, and categorise this entry
+   (whether newly added or not) as <span
+   title="concept-appcache-manifest">the manifest</span>.</p></li>
+
+   <li><p>Store the list of <span
+   title="concept-appcache-oppcache-ns">opportunistic caching
+   namespaces</span>, and the URIs of the <span
+   title="concept-appcache-fallback">fallback entries</span> that they
+   map to, in the new cache.</p></li>
+
+   <li><p>Store the URIs that form the new <span
+   title="concept-appcache-onlinewhitelist">online whitelist</span> in
+   the new cache.</p></li>
+
+   <li>
+
+    <p>If this is a <span title="concept-appcache-cache">cache
+    attempt</span>, then:</p>
+
+    <p>Set the <span title="concept-appcache-status">status</span> of <var title="">cache group</var> to
+    <i>idle</i>.</p>
+
+    <p>Associate any <code>Document</code> objects that were <a
+    href="#flagAsCandidateForCache">flagged as candidates</a> for this
+    manifest URI's caches with <var title="">cache</var>.</p>
+
+    <p><span>Fire a simple event</span> called <code
+    title="event-cached">cached</code> at the
+    <code>ApplicationCache</code> singleton of each <span>top-level
+    browsing context</span> that is associated with a cache in <var
+    title="">cache group</var>. The default action of this event
+    should be the display of some sort of user interface indicating to
+    the user that the application has been cached and that they can
+    now use it offline.</p>
+
+   </li>
+
+   <li>
+
+    <p>Otherwise, this is an <span
+    title="concept-appcache-upgrade">upgrade attempt</span>:</p>
+
+    <p>Set the <span title="concept-appcache-status">status</span> of <var title="">cache group</var> to <i>update
+    ready</i>.</p>
+
+    <p><span>Fire a simple event</span> called <code
+    title="event-updateready">updateready</code> at the
+    <code>ApplicationCache</code> singleton of each <span>top-level
+    browsing context</span> that is associated with a cache in <var
+    title="">cache group</var>. The default action of this event
+    should be the display of some sort of user interface indicating to
+    the user that a new version is available and that they can
+    activate it by reloading the page.</p>
+
+   </li>
+
+   <li><p>Abort these steps. The following step is jumped to by
+   various parts of the algorithm above when they have to cancel the
+   update.</p></li>
+
+   <li><p>Let the <span title="concept-appcache-status">status</span>
+   of the group of caches to which <var title="">cache</var> belongs
+   be <i>idle</i>. If appropriate, remove any user interface
+   indicating that an update for this cache is in progress.</p></li>
+
+  </ol>
+
+
+  <h4>Processing model</h4>
+
+  <p>The processing model of application caches for offline support in
+  Web applications is part of the <span
+  title="navigate">navigation</span> model, but references the
+  algorithms defined in this section.</p>
+
+  <p>A URI <dfn title="concept-appcache-matches-oppcache">matches an
+  opportunistic caching namespace</dfn> if there exists an
+  <span>application cache</span> whose <span
+  title="concept-appcache-manifest">manifest</span>'s URI has the
+  <span>same scheme/host/port</span> as the URI in question, and if
+  that application cache has an <span
+  title="concept-appcache-oppcache-ns">opportunistic caching
+  namespace</span> with a <path> component that exactly matches
+  the start of the <path> component of the URI being
+  examined. If multiple opportunistic caching namespaces match the
+  same URI, the one with the longest <path> component is the one
+  that matches. A URI looking for an opportunistic caching namespace
+  can match more than one application cache at a time, but only
+  matches one namespace in each cache.</p>
+
+  <div class="example">
+
+   <p>If a manifest <code
+   title="">http://example.com/app1/manifest</code> declares that
+   <code title="">http://example.com/resources/images</code> should be
+   opportunistically cached, and the user navigates to <code
+   title="">http://example.com/resources/images/cat.png</code>, then
+   the user agent will decide that the application cache identified by
+   <code title="">http://example.com/app1/manifest</code> contains a
+   namespace with a match for that URI.</p>
+
+  </div>
+
+  <p>When the <dfn
+  title="concept-appcache-init-with-attribute">application cache
+  selection algorithm</dfn> algorithm is invoked with a manifest URI,
+  the user agent must run the first applicable set of steps from the
+  following list:</p>
+
+  <dl class="switch">
+
+   <dt>If the resource is not being loaded as part of navigation of a
+   <span>top-level browsing context</span></dt>
+
+   <dd>
+
+    <p>As an optimisation, if the resource was loaded from an
+    <span>application cache</span>, and the manifest URI of that cache
+    doesn't match the manifest URI with which the algorithm was
+    invoked, then the user agent should mark the entry in that
+    application cache corresponding to the resource that was just
+    loaded as being <span
+    title="concept-appcache-foreign">foreign</span>.</p>
+
+    <p>Other than that, nothing special happens with respect to
+    application caches.</p>
+
+   </dd>
+
+   <!-- otherwise, we're talking top-level browsing contexts only: -->
+
+   <dt>If the resource being loaded was loaded from an application
+   cache and the URI of that application cache's manifest is the
+   same as the manifest URI with which the algorithm was invoked</dt>
+   <dd>
+    <p>Associate the <code>Document</code> with the cache from which
+    it was loaded. Invoke the <span>application cache update
+    process</span>.</p>
+   </dd>
+
+
+   <dt>If the resource being loaded was loaded from an application
+   cache and the URI of that application cache's manifest is
+   <em>not</em> the same as the manifest URI with which the algorithm
+   was invoked</dt>
+
+   <dd>
+
+    <p>Mark the entry for this resource in the application cache from
+    which it was loaded as <span
+    title="concept-appcache-foreign">foreign</span>.</p>
+
+    <p>Restart the current navigation from the top of the <span
+    title="navigate">navigation algorithm</span>, undoing any changes
+    that were made as part of the initial load (changes can be avoided
+    by ensuring that the step to <span>update the session history with
+    the new page</span> is only ever completed <em>after</em> the
+    application cache selection algorithm is run, though this is not
+    required).</p>
+
+    <p class="note">The navigation will not result in the same
+    resource being loaded, because "foreign" entries are never picked
+    during navigation.</p>
+
+    <p>User agents may notify the user of the inconsistency between
+    the cache manifest and the resource's own metadata, to aid in
+    application development.</p>
+
+   </dd>
+
+
+   <dt>If the resource being loaded was not loaded from an application
+   cache, but it was loaded using HTTP GET or equivalent</dt>
+   <dd>
+
+    <ol>
+
+     <li><p>If the manifest URI does not have the <span>same
+     scheme/host/port</span> as the resource's own URI, then invoke
+     the <span title="concept-appcache-init-no-attribute">application
+     cache selection algorithm</span> again, but without a manifest,
+     and abort these steps.</p></li>
+
+     <li><p>If there is already an <span>application cache</span>
+     identified by this manifest URI, and that <span>application
+     cache</span> contains a resource with the URI of the manifest,
+     and that resource is categorised as a <span
+     title="concept-appcache-manifest">manifest</span>, then: store
+     the resource in the matching cache with the most up to date
+     version, categorised as an <span
+     title="concept-appcache-implicit">implicit entry</span>,
+     associate the <code>Document</code> with that cache, invoke the
+     <span>application cache update process</span>, and abort these
+     steps.</p></li>
+
+     <li id="flagAsCandidateForCache"><p>Flag the resource's
+     <code>Document</code> as a candidate for this manifest URI's
+     caches.</p></li>
+
+     <li><p>If there is already an <span>application cache</span>
+     identified by this manifest URI, then that <span>application
+     cache</span> does not yet contain a resource with the URI of the
+     manifest, or it does but that resource is not yet categorised as
+     a <span title="concept-appcache-manifest">manifest</span>: store
+     the resource in that cache, categorised as an <span
+     title="concept-appcache-implicit">implicit entry</span>
+     (replacing the file's previous contents if it was already in the
+     cache, but not removing any other categories it might have), and
+     abort these steps.</p></li>
+
+     <li><p>Otherwise, there is no matching <span>application
+     cache</span>: create a new application cache identified by this
+     manifest URI, store the resource in that cache, categorised as an
+     <span title="concept-appcache-implicit">implicit entry</span>,
+     and then invoke the <span>application cache update
+     process</span>.</p></li>
+
+    </ol>
+
+   </dd>
+
+
+   <dt>Otherwise</dt>
+   <dd>
+    <p>Invoke the <span
+    title="concept-appcache-init-no-attribute">application cache
+    selection algorithm</span> again, but without a manifest.</p>
+   </dd>
+
+  </dl>
+
+  <p>When the <dfn
+  title="concept-appcache-init-no-attribute">application cache
+  selection algorithm</dfn> is invoked <em>without</em> a manifest,
+  then: if the resource is being loaded as part of navigation of a
+  <span>top-level browsing context</span>, and the resource was
+  fetched from a particular <span>application cache</span>, then the
+  user agent must associate the <code>Document</code> with that
+  application cache and invoke the <span>application cache update
+  process</span> for that cache; otherwise, nothing special happens
+  with respect to application caches.</p>
+
+
+  <h5>Changes to the networking model</h5>
+
+  <p>When a browsing context is associated with an <span>application
+  cache</span>, any and all resource loads must go through the
+  following steps instead of immediately invoking the mechanisms
+  appropriate to that resource's scheme:</p>
+
+  <ol>
+
+   <li><p>If the resource is not to be fetched using the HTTP GET
+   mechanism or equivalent, then fetch the resource normally and abort
+   these steps.</p></li>
+
+   <li><p>If the resource's URI, ignoring its fragment identifier if
+   any, is listed in the <span>application cache</span>'s <span
+   title="concept-appcache-onlinewhitelist">online whitelist</span>,
+   then fetch the resource normally and abort these steps.</p></li>
+
+   <li><p>If the resource's URI is <span
+   title="concept-appcache-implicit">an implicit entry</span>, <span
+   title="concept-appcache-manifest">the manifest</span>, <span
+   title="concept-appcache-explicit">an explicit entry</span>, <span
+   title="concept-appcache-fallback">a fallback entry</span>, <span
+   title="concept-appcache-oppcache">an opportunistically cached
+   entry</span>, or a <span title="concept-appcache-dynamic">dynamic
+   entry</span> in the <span>application cache</span>, then fetch the
+   resource from the cache and abort these steps.</p></li>
+
+   <li>
+
+    <p>If the resource's URI has the <span>same
+    scheme/host/port</span> as the manifest's URI, and the start of
+    the resource's URI's <path> component is exactly matched by
+    the <path> component of an <span
+    title="concept-appcache-oppcache-ns">opportunistic caching
+    namespace</span> in the <span>application cache</span>, then:
+
+    <p>Fetch the resource normally. If this results 4xx or 5xx status
+    codes or equivalent, or if there were network errors, then instead
+    fetch, from the cache, the resource of the <span
+    title="concept-appcache-fallback">fallback entry</span>
+    corresponding to the namespace with the longest matching
+    <path> component. Abort these steps.</p>
+
+   </li>
+
+   <li><p>Fail the resource load.</p></li>
+
+  </ol>
+
+  <p class="note">The above algorithm ensures that resources that are
+  not present in the manifest will always fail to load (at least,
+  after the cache has been primed the first time), making the testing
+  of offline applications simpler.</p>
+
+
+  <h4>Application cache API</h4>
+
+  <pre class="idl">interface <dfn>ApplicationCache</dfn> {
+
+  // <span title="concept-appcache-status">update status</span>
+  const unsigned short <span title="dom-appcache-UNCACHED">UNCACHED</span> = 0;
+  const unsigned short <span title="dom-appcache-IDLE">IDLE</span> = 1;
+  const unsigned short <span title="dom-appcache-CHECKING">CHECKING</span> = 2;
+  const unsigned short <span title="dom-appcache-DOWNLOADING">DOWNLOADING</span> = 3;
+  const unsigned short <span title="dom-appcache-UPDATEREADY">UPDATEREADY</span> = 4;
+  readonly attribute unsigned short <span title="dom-appcache-status">status</span>;
+
+  // updates
+  void <span title="dom-appcache-update">update</span>();
+  void <span title="dom-appcache-swapCache">swapCache</span>();
+
+  // dynamic entries
+  readonly attribute unsigned long <span title="dom-appcache-length">length</span>;
+  DOMString <span title="dom-appcache-item">item</span>(in unsigned long index);
+  void <span title="dom-appcache-add">add</span>(in DOMString uri);
+  void <span title="dom-appcache-remove">remove</span>(in DOMString uri);
+
+  // events
+           attribute <span>EventListener</span> <span title="handler-appcache-onchecking">onchecking</span>;
+           attribute <span>EventListener</span> <span title="handler-appcache-onerror">onerror</span>;
+           attribute <span>EventListener</span> <span title="handler-appcache-onnoupdate">onnoupdate</span>;
+           attribute <span>EventListener</span> <span title="handler-appcache-ondownloading">ondownloading</span>;
+           attribute <span>EventListener</span> <span title="handler-appcache-onprogress">onprogress</span>;
+           attribute <span>EventListener</span> <span title="handler-appcache-onupdateready">onupdateready</span>;
+           attribute <span>EventListener</span> <span title="handler-appcache-oncached">oncached</span>;
+
+};</pre>
+
+  <p>Objects implementing the <code>ApplicationCache</code> interface
+  must also implement the <code>EventTarget</code> interface.</p>
+
+  <p>There is a one-to-one mapping from <code>Document</code> objects
+  to <code>ApplicationCache</code> objects. The <dfn
+  title="dom-applicationCache"><code>applicationCache</code></dfn>
+  attribute on <code>Window</code> objects must return the
+  <code>ApplicationCache</code> object associated with the
+  <span>active document</span> of the <code>Window</code>'s
+  <span>browsing context</span>.</p>
+
+  <p>An <code>ApplicationCache</code> object might be associated with
+  an <span>application cache</span>. When the <code>Document</code>
+  object that the <code>ApplicationCache</code> object maps to is
+  associated with an application cache, then that is the application
+  cache with which the <code>ApplicationCache</code> object is
+  associated. Otherwise, the <code>ApplicationCache</code> object is
+  associated with the application cache that the <code>Document</code>
+  object's <span>browsing context</span> is associated with, if
+  any.</p>
+
+  <p>The <dfn title="dom-appcache-status"><code>status</code></dfn>
+  attribute, on getting, must return the current state of the
+  <span>application cache</span> <code>ApplicationCache</code> object
+  is associated with, if any. This must be the appropriate value from
+  the following list:</p>
+
+  <dl>
+
+   <dt><dfn title="dom-appcache-UNCACHED"><code>UNCACHED</code></dfn>
+   (numeric value 0)</dt>
+
+   <dd><p>The <code>ApplicationCache</code> object is not associated
+   with an <span>application cache</span> at this time.</p></dd>
+
+   <dt><dfn title="dom-appcache-IDLE"><code>IDLE</code></dfn>
+   (numeric value 1)</dt>
+
+   <dd><p>The <code>ApplicationCache</code> object is associated with
+   an <span>application cache</span> whose group is in the <i>idle</i>
+   <span title="concept-appcache-states">update
+   status</span>.</p></dd>
+
+   <dt><dfn title="dom-appcache-CHECKING"><code>CHECKING</code></dfn>
+   (numeric value 2)</dt>
+
+   <dd><p>The <code>ApplicationCache</code> object is associated with
+   an <span>application cache</span> whose group is in the
+   <i>checking</i> <span title="concept-appcache-states">update
+   status</span>.</p></dd>
+
+   <dt><dfn title="dom-appcache-DOWNLOADING"><code>DOWNLOADING</code></dfn>
+   (numeric value 3)</dt>
+
+   <dd><p>The <code>ApplicationCache</code> object is associated with
+   an <span>application cache</span> whose group is in the
+   <i>downloading</i> <span title="concept-appcache-states">update
+   status</span>.</p></dd>
+
+   <dt><dfn title="dom-appcache-UPDATEREADY"><code>UPDATEREADY</code></dfn>
+   (numeric value 4)</dt>
+
+   <dd><p>The <code>ApplicationCache</code> object is associated with
+   an <span>application cache</span> whose group is in the <i>update
+   ready</i> <span title="concept-appcache-states">update
+   status</span>.</p></dd>
+
+  </dl>
+
+  <p>The <dfn title="dom-appcache-length"><code>length</code></dfn>
+  attribute must return the number of entries in the <span>application
+  cache</span> with which the <code>ApplicationCache</code> object is
+  associated, if any, and zero the object is not associated with any
+  application cache.</p>
+
+  <p>The <span title="concept-appcache-dynamic">dynamic entries</span>
+  in the <span>application cache</span> are ordered in the same order
+  as they were added to the cache by the <code
+  title="dom-appcache-add">add()</code> method, with the oldest entry
+  being the zeroth entry, and the most recently added entry having the
+  index <span><code
+  title="dom-appcache-length">length</code>-1</span>.</p>
+
+  <p>The <dfn title="dom-appcache-item"><code>item(<var
+  title="">index</var>)</code></dfn> method must return the <span
+  title="concept-appcache-dynamic">dynamic entries</span> with index
+  <var title="">index</var> from the <span>application cache</span>,
+  if one is associated with the <code>ApplicationCache</code>
+  object. If the object is not associated with any application cache,
+  or if the <var title="">index</var> argument is lower than zero or
+  greater than <span><code
+  title="dom-appcache-length">length</code>-1</span>, the method must
+  instead raise an <code>INDEX_SIZE_ERR</code> exception.</p>
+
+  <p>The <dfn title="dom-appcache-add"><code>add(<var
+  title="">uri</var>)</code></dfn> method must run the following
+  steps:</p>
+
+  <ol>
+
+   <li><p>If the <code>ApplicationCache</code> object is not
+   associated with any application cache, then raise an
+   <code>INVALID_STATE_ERR</code> exception and abort these
+   steps.</p></li>
+
+   <li><p>If there is already a resource in in the <span>application
+   cache</span> with which the <code>ApplicationCache</code> object is
+   associated that has the address <var title="">uri</var>, then
+   ensure that entry is categorised as a <span
+   title="concept-appcache-dynamic">dynamic entry</span> and return
+   and abort these steps.</p></li>
+
+   <li><p>Return, but do not abort these steps.</p></li>
+
+   <li><p>Fetch the resource referenced by <var
+   title="">uri</var>.</p></li>
+
+   <li><p>If this results 4xx or 5xx status codes or equivalent, or if
+   there were network errors, then abort these steps.</p></li>
+
+   <li>
+
+    <p>Wait for there to be no running scripts, or at least no running
+    scripts that can reach an <code>ApplicationCache</code> object
+    associated with the <span>application cache</span> with which this
+    <code>ApplicationCache</code> object is associated.</p>
+
+    <p>Add the fetched resource to the <span>application cache</span>
+    and categorise it as a <span
+    title="concept-appcache-dynamic">dynamic entry</span> before
+    letting any such scripts resume.</p>
+  
+   </li>
+
+  </ol>
+
+  <p class="big-issue">We can make the add() API more usable
+  (i.e. make it possible to detect progress and distinguish success
+  from errors without polling and timeouts) if we have the method
+  return an object that is a target of Progress Events, much like the
+  <a
+  href="http://dev.w3.org/cvsweb/~checkout~/2006/webapi/XMLHttpRequest-2/Overview.html?content-type=text/html;%20charset=utf-8#xmlhttprequesteventtarget-interface">XMLHttpRequestEventTarget</a>
+  interface. This would also make this far more complex to spec and
+  implement.</p>
+
+  <p>The <dfn title="dom-appcache-remove"><code>remove(<var
+  title="">uri</var>)</code></dfn> method must remove the <span
+  title="concept-appcache-dynamic">dynamic entry</span> categorisation
+  of any entry with the address <var title="">uri</var> in the
+  <span>application cache</span> with which the
+  <code>ApplicationCache</code> object is associated. If this removes
+  the last categorisation of an entry in that cache, then the entry
+  must be removed entirely (such that if it is re-added, it will be
+  loaded from the network again). If the <code>ApplicationCache</code>
+  object is not associated with any application cache, then the method
+  must raise an <code>INVALID_STATE_ERR</code> exception instead.</p>
+
+  <p>If the <dfn
+  title="dom-appcache-update"><code>update()</code></dfn> method is
+  invoked, the user agent must invoke the <span>application cache
+  update process</span>, in the background, for the <span>application
+  cache</span> with which the <code>ApplicationCache</code> object is
+  associated. If there is no such application cache, then the method
+  must raise an <code>INVALID_STATE_ERR</code> exception instead.</p>
+
+  <p>If the <dfn
+  title="dom-appcache-swapCache"><code>swapCache()</code></dfn> method
+  is invoked, the user agent must run the following steps:
+
+  <ol>
+
+   <li><p>Let <var title="">document</var> be the
+    <code>Document</code> with which the <code>ApplicationCache</code>
+    object is associated.</p></li>
+
+   <li>
+
+    <p>Check that <var title="">document</var> is associated with an
+    <span>application cache</span>. If it is not, then raise an
+    <code>INVALID_STATE_ERR</code> exception and abort these
+    steps.</p>
+
+    <p class="note">This is not the same thing as the
+    <code>ApplicationCache</code> object being itself associated with
+    an <span>application cache</span>! In particular, this can only
+    happen if <var title="">document</var> is in a <span>top-level
+    browsing context</span>.</p>
+
+   </li>
+
+   <li><p>Let <var title="">cache</var> be the <span>application
+   cache</span> with which the <code>ApplicationCache</code> object is
+   associated. (By definition, this is the same as the one that was
+   found in the previous step.)</p></li>
+
+   <li><p>Check that there is an application cache in the same group
+   as <var title="">cache</var> which has an entry categorised as a
+   <span title="concept-appcache-manifest">manifest</span> that has is
+   newer than <var title="">cache</var>. If there is not, then raise
+   an <code>INVALID_STATE_ERR</code> exception and abort these
+   steps.</p></li>
+
+   <li><p>Let <var title="">new cache</var> be the newest
+   <span>application cache</span> in the same group as <var
+   title="">cache</var> which has an entry categorised as a <span
+   title="concept-appcache-manifest">manifest</span>.</p></li>
+
+   <li><p>Unassociate <var title="">document</var> from <var
+   title="">cache</var> and instead associate it with <var
+   title="">new cache</var>.</p></li>
+
+  </ol>
+
+  <p>The following are the <span>event handler DOM attributes</span>
+  that must be supported by objects implementing the
+  <code>ApplicationCache</code> interface:</p>
+
+  <dl>
+
+   <dt><dfn title="handler-appcache-onchecking"><code>onchecking</code></dfn></dt>
+
+   <dd><p>Must be invoked whenever an <code
+   title="event-checking">checking</code> event is targeted at or
+   bubbles through the <code>ApplicationCache</code> object.</p></dd>
+
+
+   <dt><dfn title="handler-appcache-onerror"><code>onerror</code></dfn></dt>
+
+   <dd><p>Must be invoked whenever an <code
+   title="event-error">error</code> event is targeted at or bubbles
+   through the <code>ApplicationCache</code> object.</p></dd>
+
+
+   <dt><dfn title="handler-appcache-onnoupdate"><code>onnoupdate</code></dfn></dt>
+
+   <dd><p>Must be invoked whenever an <code
+   title="event-noupdate">noupdate</code> event is targeted at or
+   bubbles through the <code>ApplicationCache</code> object.</p></dd>
+
+
+   <dt><dfn title="handler-appcache-ondownloading"><code>ondownloading</code></dfn></dt>
+
+   <dd><p>Must be invoked whenever an <code
+   title="event-downloading">downloading</code> event is targeted at
+   or bubbles through the <code>ApplicationCache</code>
+   object.</p></dd>
+
+
+   <dt><dfn title="handler-appcache-onprogress"><code>onprogress</code></dfn></dt>
+
+   <dd><p>Must be invoked whenever an <code
+   title="event-progress">progress</code> event is targeted at or
+   bubbles through the <code>ApplicationCache</code> object.</p></dd>
+
+
+   <dt><dfn title="handler-appcache-onupdateready"><code>onupdateready</code></dfn></dt>
+
+   <dd><p>Must be invoked whenever an <code
+   title="event-updateready">updateready</code> event is targeted at
+   or bubbles through the <code>ApplicationCache</code>
+   object.</p></dd>
+
+
+   <dt><dfn title="handler-appcache-oncached"><code>oncached</code></dfn></dt>
+
+   <dd><p>Must be invoked whenever a <code
+   title="event-cached">cached</code> event is targeted at or bubbles
+   through the <code>ApplicationCache</code> object.</p></dd>
+
+  </dl>
+
+
+  <h4>Browser state</h4>
+
+  <p>The <dfn
+  title="dom-navigator-onLine"><code>navigator.onLine</code></dfn>
+  attribute must return false if the user agent will not contact the
+  network when the user follows links or when a script requests a
+  remote page (or knows that such an attempt would fail), and must
+  return true otherwise.</p>
+
+  <p>When the value that would be returned by the <code
+  title="dom-navigator-onLine">navigator.onLine</code> attribute of
+  the <code>Window</code> changes from true to false, the user agent
+  must <span>fire a simple event</span> called <dfn
+  title="event-offline"><code>offline</code></dfn> at <span>the body
+  element</span>.</p>
+
+  <p>On the other hand, when the value that would be returned by the
+  <code title="dom-navigator-onLine">navigator.onLine</code> attribute
+  of the <code>Window</code> changes from false to true, the user
+  agent must <span>fire a simple event</span> called <dfn
+  title="event-online"><code>online</code></dfn> at <span>the body
+  element</span>.</p>
+
+  <!-- XXX ononline onoffline need to be defined -->
+
+
+
   <h3 id="history">Session history and navigation</h3>
 
   <h4>The session history of browsing contexts</h4>
@@ -23520,8 +24962,9 @@
   whose index equals the index of the <span>current entry</span> plus
   <var title="">delta</var>.</p>
 
-  <p>When a user agent is required to <dfn>traverse the history</dfn>
-  to a specified entry, the user agent must act as follows:</p>
+  <p>When a user agent is required to <dfn>traverse the
+  history</dfn><!-- (traversal) --> to a specified entry, the user
+  agent must act as follows:</p>
 
   <ol>
 
@@ -23588,9 +25031,13 @@
 
      </li>
 
-     <li>The user agent must make the <span>specified entry</span>'s
-     <code>Document</code> object the <span>active document</span> of
-     the <span>browsing context</span>.</li>
+     <li id="appcache-history-2">The user agent must make the
+     <span>specified entry</span>'s <code>Document</code> object the
+     <span>active document</span> of the <span>browsing
+     context</span>. (If it is a <span>top-level browsing
+     context</span>, this might <a
+     href="#appcache-history-1">change</span> which <span>application
+     cache</span> it is associated with.)</li>
 
      <li>If the <span>specified entry</span> has a <span>browsing
      context name</span> stored with it, then the following
@@ -23682,19 +25129,17 @@
   <p>When this method is invoked, the user agent must first check the
   third argument. If a third argument is specified, then the user
   agent must verify that the third argument is a valid URI or IRI (as
-  defined by RFC 3986 and 3987, and as modified by RFC 2732), and if
-  so, that, after resolving it to an absolute URI, it is either
-  identical to the document's URI, or that it differs from the
-  document's URI only in the <query>, <abs_path>, and/or
-  <fragment> parts, as applicable (the <query> and
-  <abs_path> parts can only be the same if the document's URI
-  uses a hierarchical <scheme>). If the verification fails
-  (either because the argument is syntactically incorrect, or differs
-  in a way not described as acceptable in the previous sentence) then
-  the user agent must raise a <span>security exception</span>. <a
-  href="#refsRFC3986">[RFC3986]</a> <a
-  href="#refsRFC3987">[RFC3987]</a> <a
-  href="#refsRFC2732">[RFC2732]</a></p>
+  defined by RFC 3986 and 3987), and if so, that, after resolving it
+  to an absolute URI, it is either identical to the document's URI, or
+  that it differs from the document's URI only in the <query>,
+  <abs_path>, and/or <fragment> parts, as applicable (the
+  <query> and <abs_path> parts can only be the same if the
+  document's URI uses a hierarchical <scheme>). If the
+  verification fails (either because the argument is syntactically
+  incorrect, or differs in a way not described as acceptable in the
+  previous sentence) then the user agent must raise a <span>security
+  exception</span>. <a href="#refsRFC3986">[RFC3986]</a> <a
+  href="#refsRFC3987">[RFC3987]</a></p>
 
   <p>If the third argument passes its verification step, or if the
   third argument was omitted, then the user agent must remove from the
@@ -23980,26 +25425,100 @@
    scheme is not one of the supported protocols, or an inline prompt
    to allow the user to select <span
    title="dom-navigator-registerProtocolHandler">a registered
-   handler</span> for the given scheme, then <span title="display a
-   user agent page inline">display the inline content</span> and abort
-   these steps.</p></li>
+   handler</span> for the given scheme, then <span
+   title="navigate-ua-inline">display the inline content</span> and
+   abort these steps.</p></li>
 
    <li><p>If the new resource is to be handled using a mechanism that
    does not affect the browsing context, then abort these steps and
    proceed with that mechanism instead.</p></li>
 
-   <li><p>Start fetching the specified resource, as appropriate
-   (e.g. performing an HTTP GET or POST operation, or reading the file
-   from disk, or executing script in the case of a <span
-   title="javascript protocol"><code title="">javascript:</code>
-   URI</span>). If this results in a redirect, return to step 2 with
-   the new resource.</p></li>
+   <li>
 
+    <p>If the new resource is to be fetched using HTTP GET or
+    equivalent, and if the browsing context being navigated is a
+    <span>top-level browsing context</span>, then check if there are
+    any <span title="application cache">application caches</span> that
+    have a <span title="concept-appcache-manifest">manifest</span>
+    with the <span>same scheme/host/port</span> as the URI in
+    question, and that have this URI as one of their entries
+    (excluding entries marked as <span
+    title="concept-appcache-foreign">manifest</span>), and that
+    already contain their manifest, categorised as a <span
+    title="concept-appcache-manifest">manifest</span>. If so, then the
+    user agent must then fetch the resource from the <span
+    title="concept-appcache-selection">most appropriate application
+    cache</span> of those that match.</p>
+
+    <p>Otherwise, start fetching the specified resource in the
+    appropriate manner (e.g. performing an HTTP GET or POST operation,
+    or reading the file from disk, or executing script in the case of
+    a <span title="javascript protocol"><code
+    title="">javascript:</code> URI</span>). If this results in a
+    redirect, return to step 2 with the new resource.</p>
+
+    <p class="example">For example, imagine an HTML page with an
+    associated application cache displaying an image and a form, where
+    the image is also used by several other application caches. If the
+    user right-clicks on the image and chooses "View Image", then the
+    user agent could decide to show the image from any of those
+    caches, but it is likely that the most useful cache for the user
+    would be the one that was used for the aforementioned HTML
+    page. On the other hand, if the user submits the form, and the
+    form does a POST submission, then the user agent will not use an
+    application cache at all; the submission will be made to the
+    network.</p>
+
+   </li>
+
    <li><p>Wait for one or more bytes to be available or for the user
    agent to establish that the resource in question is empty. During
    this time, the user agent may allow the user to cancel this
    navigation attempt or start other navigation attempts.</p></li>
 
+   <li>
+
+    <p>If the resource was not fetched from an <span>application
+    cache</span>, and was to be fetched using HTTP GET or equivalent,
+    and its URI <span
+    title="concept-appcache-matches-oppcache">matches the
+    opportunistic caching namespace</span> of one or more application
+    caches, then:</p>
+
+    <dl class="switch">
+
+     <dt>If the file was successfully downloaded</dt>
+
+     <dd>The user agent must cache the resource in all those
+     application caches, categorised as <span
+     title="concept-appcache-oppcache">opportunistically cached
+     entries</span>.</dd>
+
+
+     <dt>If the server returned a 4xx or 5xx status code or
+     equivalent, or there were network errors</dt>
+
+     <dd>If the browsing context being navigated is a <span>top-level
+     browsing context</span>, then the user agent must discard the
+     failed load and instead use the <span
+     title="concept-appcache-fallback">fallback resource</span>
+     specified for the opportunistic caching namespace in question. If
+     multiple application caches match, the user agent must use the
+     fallback of the <span title="concept-appcache-selection">most
+     appropriate application cache</span> of those that match. For the
+     purposes of session history (and features that depend on session
+     history, e.g. bookmarking) the user agent must use the URI of the
+     resource that was requested (the one that matched the
+     opportunistic caching namespace), not the fallback
+     resource. However, the user agent may indicate to the user that
+     the original page load failed, that the page used was a fallback
+     resource, and what the URI of the fallback resource actually
+     is.</dd>
+
+    </dl>
+
+   </li>
+
    <li><p>If the document's out-of-band metadata (e.g. HTTP headers),
    not counting any <span title="Content-Type">type information</span>
    (such as the Content-Type HTTP header), requires some sort of
@@ -24069,9 +25588,9 @@
    the content, an error message because the specified type is not
    supported, or an inline prompt to allow the user to select <span
    title="dom-navigator-registerContentHandler">a registered
-   handler</span> for the given type, then <span title="display a user
-   agent page inline">display the inline content</span> and abort
-   these steps.</p></li>
+   handler</span> for the given type, then <span
+   title="navigate-ua-inline">display the inline content</span> and
+   abort these steps.</p></li>
 
    <li><p>Otherwise, the document's <var title="">type</var> is such
    that the resource will not affect the browsing context,
@@ -24163,10 +25682,11 @@
   document as the <span>input stream</span> for that parser.</p>
 
   <p class="note">The <span>input stream</span> converts bytes into
-  characters for use in the <span>tokeniser</span>. This process
-  relies, in part, on character encoding information found in the real
-  <span title="Content-Type">Content-Type metadata</span> of the
-  resource; the "sniffed type" is not used for this purpose.</p>
+  characters for use in the <span>tokeniser</span><!-- XXX xref
+  -->. This process relies, in part, on character encoding information
+  found in the real <span title="Content-Type">Content-Type
+  metadata</span> of the resource; the "sniffed type" is not used for
+  this purpose.</p>
 
   <!-- next two paragraphs are nearly identical to the navigate-text
   section, keep them in sync -->
@@ -24179,7 +25699,14 @@
   before the page has finished parsing, the user agent must
   <span>update the session history with the new page</span>.</p>
 
+  <p class="note"><span
+  title="concept-appcache-init-with-attribute">Application cache
+  selection</span> happens <a href="#parser-appcache">in the HTML
+  parser</a>.</p>
 
+
+
+
   <h4 id="read-xml"><dfn title="navigate-xml">Page load processing model for XML files</dfn></h4>
 
   <p>When faced with displaying an XML file inline, user agents must
@@ -24196,6 +25723,29 @@
   encoding according to the rules given in the above
   specifications.</p>
 
+  <p>If the root element, as parsed according to the XML
+  specifications cited above, is found to be an <code>html</code>
+  element with an attribute <code
+  title="attr-html-application">application</code>, then, as soon as
+  the element is inserted into the DOM, the user agent must run the
+  <span title="concept-appcache-init-with-attribute">application cache
+  selection algorithm</span> with the value of that attribute as the
+  manifest URI. Otherwise, as soon as the root element is inserted
+  into the DOM, the user agent must run the <span
+  title="concept-appcache-init-no-attribute">application cache
+  selection algorithm</span> with no manifest.</p>
+
+  <p class="note">Because the processing of the <code
+  title="attr-html-application">application</code> attribute happens
+  only once the root element is parsed, any URIs referenced by
+  processing instructions before the root element (such as <code
+  title=""><?xml-styleesheet?></code> and <code
+  title=""><?xbl?></code> PIs) will be fetched from the network and
+  cannot be cached.</p> <!-- XXX any ideas for avoiding this, that
+  aren't a PI themselves? We can't delay the processing, since the
+  whole point of the <?xbl?> PI is to have the XBL sheet loaded before
+  the root element... -->
+
   <p>User agents may examine the namespace of the root
   <code>Element</code> node of this <code>Document</code> object to
   perform namespace-based dispatch to alternative processing tools,
@@ -24232,8 +25782,13 @@
   subsequent versions thereof. <a href="#refsRFC2046">[RFC2046]</a> <a
   href="#refsRFC2046">[RFC2646]</a></p>
 
+  <p>Upon creation of the <code>Document</code> object, the user agent
+  must run the <span
+  title="concept-appcache-init-no-attribute">application cache
+  selection algorithm</span> with no manifest.</p>
+
   <!-- next two paragraphs are nearly identical to the navigate-html
-  section and similar to the "non-DOM-inline-content" section, and the
+  section and similar to the "navigate-ua-inline" section, and the
   next three are similar to the navigate-image and navigate-plugin
   sections; keep them all in sync -->
 
@@ -24269,6 +25824,11 @@
   <p>Then, the user agent must act as if it had <span title="stop
   parsing">stopped parsing</span>.</p>
 
+  <p>Upon creation of the <code>Document</code> object, the user agent
+  must run the <span
+  title="concept-appcache-init-no-attribute">application cache
+  selection algorithm</span> with no manifest.</p>
+
   <p>After creating the <code>Document</code> object, but potentially
   before the page has finished fully loading, the user agent must
   <span>update the session history with the new page</span>.</p>
@@ -24298,6 +25858,11 @@
   <p>Then, the user agent must act as if it had <span title="stop
   parsing">stopped parsing</span>.</p>
 
+  <p>Upon creation of the <code>Document</code> object, the user agent
+  must run the <span
+  title="concept-appcache-init-no-attribute">application cache
+  selection algorithm</span> with no manifest.</p>
+
   <p>After creating the <code>Document</code> object, but potentially
   before the page has finished fully loading, the user agent must
   <span>update the session history with the new page</span>.</p>
@@ -24308,16 +25873,16 @@
   the document a <code>title</code>.</p>
 
 
-  <h4 id="non-DOM-inline-content">Page load processing model for inline content that doesn't have a DOM</h4>
+  <h4 id="read-ua-inline"><dfn title="navigate-ua-inline">Page load processing model for inline content that doesn't have a DOM</dfn></h4>
 
-  <p>When the user agent is to <dfn>display a user agent page
-  inline</dfn> in a <span>browsing context</span>, the user agent
-  should create a <code>Document</code> object, mark it as being an
-  <span title="HTML documents">HTML document</span>, and then either
-  associate that <code>Document</code> with a custom rendering that is
-  not rendered using the normal <code>Document</code> rendering rules,
-  or mutate that <code>Document</code> until it represents the content
-  the user agent wants to render.</p>
+  <p>When the user agent is to display a user agent page inline in a
+  <span>browsing context</span>, the user agent should create a
+  <code>Document</code> object, mark it as being an <span title="HTML
+  documents">HTML document</span>, and then either associate that
+  <code>Document</code> with a custom rendering that is not rendered
+  using the normal <code>Document</code> rendering rules, or mutate
+  that <code>Document</code> until it represents the content the user
+  agent wants to render.</p>
 
   <!-- next two paragraphs are similar to the navigate-text section,
   keep them in sync -->
@@ -24325,6 +25890,11 @@
   <p>Once the page has been set up, the user agent must act as if it
   had <span title="stop parsing">stopped parsing</span>.</p>
 
+  <p>Upon creation of the <code>Document</code> object, the user agent
+  must run the <span
+  title="concept-appcache-init-no-attribute">application cache
+  selection algorithm</span> with no manifest.</p>
+
   <p>After creating the <code>Document</code> object, but potentially
   before the page has been completely set up, the user agent must
   <span>update the session history with the new page</span>.</p>
@@ -25190,9 +26760,10 @@
 
   <p>The <dfn title="dom-Storage-key"><code>key(<var
   title="">n</var>)</code></dfn> method must return the name of the
-  <var title="">n</var>th <span>accessible</span> key in the list. The
-  order of keys is user-agent defined, but must be consistent within
-  an object between changes to the number of keys. (Thus, <span
+  <var title="">n</var>th <span title="accessible
+  keys">accessible</span> key in the list. The order of keys is
+  user-agent defined, but must be consistent within an object between
+  changes to the number of keys. (Thus, <span
   title="dom-Storage-setItem">adding</span> or <span
   title="dom-Storage-removeItem">removing</span> a key may change the
   order of the keys, but merely changing the value of an existing key
@@ -25208,12 +26779,13 @@
   <code>StorageItem</code> object representing the key/value pair with
   the given <var title="">key</var>. If the given <var
   title="">key</var> does not exist in the list associated with the
-  object, or is not <span>accessible</span>, then this method must
-  return null. Subsequent calls to this method with the same key from
-  scripts running in the same <span>security context</span> must
-  return the same instance of the <code>StorageItem</code>
-  interface. (Such instances must not be shared across security
-  contexts, though.)</p> <!-- XXX define security context -->
+  object, or is not <span title="accessible keys">accessible</span>,
+  then this method must return null. Subsequent calls to this method
+  with the same key from scripts running in the same <span>security
+  context</span> must return the same instance of the
+  <code>StorageItem</code> interface. (Such instances must not be
+  shared across security contexts, though.)</p> <!-- XXX define
+  security context -->
 
   <p>The <dfn title="dom-Storage-setItem"><code>setItem(<var
   title="">key</var>, <var title="">value</var>)</code></dfn> method
@@ -25233,12 +26805,13 @@
 
   <p>If the given <var title="">key</var> <em>does</em> exist in the
   list, then, if the key/value pair with the given <var
-  title="">key</var> is <span>accessible</span>, it must have its
-  value updated so that any current or future <code>StorageItem</code>
-  objects referring to this key/value pair will return the value given
-  in the <var title="">value</var> argument. If it is <em>not</em>
-  <span>accessible</span>, the method must raise a <span>security
-  exception</span>.</p>
+  title="">key</var> is <span title="accessible
+  keys">accessible</span>, it must have its value updated so that any
+  current or future <code>StorageItem</code> objects referring to this
+  key/value pair will return the value given in the <var
+  title="">value</var> argument. If it is <em>not</em> <span
+  title="accessible keys">accessible</span>, the method must raise a
+  <span>security exception</span>.</p>
 
   <p>When the <code title="dom-Storage-setItem">setItem()</code>
   method is successfully invoked (i.e. when it doesn't raise an
@@ -25253,11 +26826,11 @@
   <p>The <dfn 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 and is
-  <span>accessible</span>. If no item with that key exists, the method
-  must do nothing. If an item with that key exists but is not
-  <span>accessible</span>, the method must raise a <span>security
-  exception</span>.</p>
+  list associated with the object, if it exists and is <span
+  title="accessible keys">accessible</span>. If no item with that key
+  exists, the method must do nothing. If an item with that key exists
+  but is not <span title="accessible keys">accessible</span>, the
+  method must raise a <span>security exception</span>.</p>
 
   <p>The <code title="dom-Storage-setItem">setItem()</code> and <code
   title="dom-Storage-removeItem">removeItem()</code> methods must be
@@ -25266,13 +26839,13 @@
   changed at all.</p>
 
   <p>In the ECMAScript DOM binding, enumerating a <code>Storage</code>
-  object must enumerate through the currently stored and
-  <span>accessible</span> keys in the list the object is associated
-  with. (It must not enumerate the values or the actual members of the
-  interface). In the ECMAScript DOM binding, <code>Storage</code>
-  objects must support dereferencing such that getting a property that
-  is not a member of the object (i.e. is neither a member of the
-  <code>Storage</code> interface nor of <code
+  object must enumerate through the currently stored and <span
+  title="accessible keys">accessible</span> keys in the list the
+  object is associated with. (It must not enumerate the values or the
+  actual members of the interface). In the ECMAScript DOM binding,
+  <code>Storage</code> objects must support dereferencing such that
+  getting a property that is not a member of the object (i.e. is
+  neither a member of the <code>Storage</code> interface nor of <code
   title="dom-Object">Object</code>) must invoke the <code
   title="dom-Storage-getItem">getItem()</code> method with the
   property's name as the argument, and setting such a property must
@@ -27558,10 +29131,9 @@
   value of <var title="">output</var>.</p>
 
   <p>The rules for parsing and constructing URIs are described in RFC
-  3986 and RFC 3987, as modified by RFC 2732. <a
+  3986 and RFC 3987. <a
   href="#refsRFC3986">[RFC3986]</a> <a
-  href="#refsRFC3987">[RFC3987]</a> <a
-  href="#refsRFC2732">[RFC2732]</a></p>
+  href="#refsRFC3987">[RFC3987]</a></p>
 
   <table>
    <thead>      
@@ -27584,7 +29156,7 @@
      <td>The new value is not the empty string
     <tr>
      <td><dfn title="dom-uda-host"><code>host</code></dfn>
-     <td><hostport>
+     <td><span><hostport></span>
      <td><span title="concept-uda-input">input</span> is hierarchical and uses a server-based naming authority
      <td>—
      <td>—
@@ -27592,7 +29164,7 @@
      <td>—
     <tr>
      <td><dfn title="dom-uda-hostname"><code>hostname</code></dfn>
-     <td><host>
+     <td><host>/<ihost>
      <td><span title="concept-uda-input">input</span> is hierarchical and uses a server-based naming authority
      <td>—
      <td>—
@@ -27632,6 +29204,11 @@
      <td>—
   </table>
 
+  <p>The <dfn><hostport></dfn> component is defined as being the
+  <host>/<ihost> component, followed by a colon and the
+  <port> component, but with the colon and <port>
+  component omitted if the given port matches the default port for the
+  protocol given by the <scheme> component.</p>
 
 <!--
   http://www.hixie.ch/tests/adhoc/dom/level0/location/components/
@@ -34585,6 +36162,15 @@
    <dt>An end tag token</dt>
    <dt>An end-of-file token</dt>
    <dd>
+
+    <p id="parser-appcache">If the token is a start tag token with the
+    tag name "html", and it has an attribute "application", then run
+    the <span title="concept-appcache-init-with-attribute">application
+    cache selection algorithm</span> with the value of that attribute
+    as the manifest URI. Otherwise, run the <span
+    title="concept-appcache-init-no-attribute">application cache
+    selection algorithm</span> with no manifest.</p>
+
     <p>Create an <code>HTMLElement</code> node with the tag name
     <code>html</code>, in the <span>HTML namespace</span>. Append it
     to the <code>Document</code> object. Switch to <span>the main




More information about the Commit-Watchers mailing list