HTML Standard Tracker

Filter

File a bug

SVNBugCommentTime (UTC)
2692[Gecko] [Webkit] Big revamp of how Application Caches work. The core of the algorithm is the same, but it is described quite differently and the edge cases should be smoother now.2009-01-22 12:27
@@ -8744,24 +8744,24 @@ Consider: data:text/xml,<script xmlns="http://www.w3.org/1999/xhtml"><![CDATA[ d
   document.</p>
 
   <p>The <dfn title="attr-html-manifest"><code>manifest</code></dfn>
   attribute gives the address of the document's <span>application
   cache</span> <span
   title="concept-appcache-manifest">manifest</span>, if there is
   one. If the attribute is present, the attribute's value must be a
   <span>valid URL</span>.</p>
 
   <p>The <code title="attr-html-manifest">manifest</code> attribute
-  only <span title="concept-appcache-init-with-attribute">has an
-  effect</span> during the early stages of document load. Changing the
-  attribute dynamically thus has no effect (and thus, no DOM API is
-  provided for this attribute).</p>
+  only <span title="concept-appcache-init">has an effect</span> during
+  the early stages of document load. Changing the attribute
+  dynamically thus has no effect (and thus, no DOM API is provided for
+  this attribute).</p>
 
   <p class="note">Later <code>base</code> elements don't affect the
   <span title="resolve a url">resolving of relative URLs</span> in
   <code title="attr-html-manifest">manifest</code> attributes, as the
   attributes are processed before those elements are seen.</p>
 
 
   <h3>Document metadata</h3>
 
   <h4>The <dfn><code>head</code></dfn> element</h4>
@@ -10639,21 +10639,21 @@ people expect to have work and what is necessary.
 
       <p>Initialize <dfn><var>the script block's source</var></dfn> as
       follows:</p>
 
       <dl class="switch">
 
        <dt>If the script is from an external file</dt>
 
        <dd>
 
-        <p>The contents of that file, interpreted as as string of
+        <p>The contents of that file, interpreted as string of
         Unicode characters, are the script source.</p>
 
         <p>The file must be converted to Unicode using the character
         encoding given by <var>the script block's character
         encoding</var>, regardless of any metadata given by the file's
         <span title="Content-Type">Content-Type metadata</span>.</p>
 
         <p class="XXX">This means that a UTF-16 document will
         always assume external scripts are UTF-16...? This applies,
         e.g., to document's created using createDocument()... It also
@@ -39889,21 +39889,21 @@ JSURL: http://ietfreport.isoc.org/all-ids/draft-hoehrmann-javascript-scheme-00.t
   have other initial values, in particular the <code
   title="handler-window-onerror">onerror</code> event handler
   attribute on the <code>Window</code> object.</p>
 
   <p>Event handler attributes are exposed in one or two ways.</p>
 
   <p>The first way, common to all event handler attributes, is as an
   <span title="event handler DOM attributes">event handler DOM
   attribute</span>.</p>
 
-  <p>The second way is as as an <span title="event handler content
+  <p>The second way is as an <span title="event handler content
   attributes">event handler content attribute</span>. Event handlers on
   <span>HTML elements</span> and some of the event handlers on
   <code>Window</code> objects are exposed in this way.</p>
 
   <hr>
 
   <p><dfn>Event handler DOM attributes</dfn>, on setting, must set the
   corresponding event handler attribute to their new value, and on
   getting, must return whatever the current value of the corresponding
   event handler attribute is (possibly null).</p>
@@ -41515,56 +41515,22 @@ interface <dfn>Function</dfn> {
 
   <h4>Introduction</h4>
 
   <p><em>This section is non-normative.</em></p>
 
   <p class="XXX">...</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 <span>absolute URL</span> 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 URL, each having a
-  different version. A cache is newer than another if it was created
-  after the other (in other words, caches in a group have a
-  chronological order).</p>
-
-  <p>Each group of application caches for the same manifest URL has 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>.</p>
-
-  <p>Each group of application caches for the same manifest URL also
-  has a common <dfn title="concept-appcache-lifecycle">lifecycle
-  status</dfn>, which is one of the following: <i>new</i>,
-  <i>mature</i>, <i>obsolete</i>. A <dfn>relevant application
-  cache</dfn> is an <span>application cache</span> whose <span
-  title="concept-appcache-lifecycle">lifecycle status</span> is
-  <i>mature</i>.</p>
-
-  <p id="appcache-history-1">A <span>browsing context</span> is
-  associated with the application cache appropriate for its
-  <span>active document</span>, if any. 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. A browsing context's
-  associated cache can also <a href="#appcache-history-2">change</a>
-  during <span title="traverse the history">session history
-  traversal</span>.</p>
-
-  <p>An application cache consists of:</p>
+  <p>An <dfn>application cache</dfn> is a set of cached resources
+  consisting of:</p>
 
   <ul>
 
    <li>
 
     <p>One of more resources (including their out-of-band metadata,
     such as HTTP headers, if any), identified by URLs, each falling
     into one (or more) of the following categories:</p>
 
     <dl>
@@ -41624,42 +41590,93 @@ interface <dfn>Function</dfn> {
    title="concept-appcache-fallback">fallback entry</span>. Each
    namespace URL has the <span>same origin</span> as <span
    title="concept-appcache-manifest">the manifest</span>.</li>
 
    <li>Zero or more URLs that form the <dfn
    title="concept-appcache-onlinewhitelist">online whitelist
    namespaces</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
+  <p>Each <span>application cache</span> has a <dfn
+  title="concept-appcache-completeness">completeness flag</dfn>, which is
+  either <i>complete</i> or <i>incomplete</i>.</p>
+
+  <hr>
+
+  <p>An <dfn>application cache group</dfn> is a group of <span
+  title="application cache">application caches</span>, identified by
+  the <span>absolute URL</span> of a resource <span
+  title="concept-appcache-manifest">manifest</span> which is used to
+  populate the caches in the group.</p>
+
+  <p>An <span>application cache</span> is <dfn
+  title="concept-appcache-newer">newer</dfn> than another if it was
+  created after the other (in other words, <span title="application
+  cache">application caches</span> in an <span>application cache
+  group</span> have a chronological order).</p>
+
+  <p>Only the newest <span>application cache</span> in an
+  <span>application cache group</span> can have its <span
+  title="concept-appcache-completeness">completeness flag</span> set to
+  <i>incomplete</i>, the others are always all <i>complete</i>.</p>
+
+  <p>Each <span>application cache group</span> has an <dfn
+  title="concept-appcache-status">update status</dfn>, which is one of
+  the following: <i>idle</i>, <i>checking</i>, <i>downloading</i>.</p>
+
+  <p>A <dfn>relevant application cache</dfn> is an <span>application
+  cache</span> that is the <span
+  title="concept-appcache-newer">newest</span> in its <span
+  title="application cache group">group</span> to be
+  <i>complete</i>.</p>
+
+  <p>Each <span>application cache group</span> has a <dfn
+  title="concept-appcache-pending-masters">list of pending master
+  entries</dfn>. Each entry in this list consists of a resource and a
+  corresponding <code>Document</code> object. It is used during the
+  update process to ensure that new master entries are cached.</p>
+
+  <hr>
+
+  <p>A <code>Document</code> initially is not associated with an
+  <span>application cache</span>, 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">cache selection</span> to occur early
+  in the page load process.</p>
+
+  <p>Multiple <span title="application cache">application
+  caches</span> in different <span title="application cache
+  group">application cache groups</span> can contain the same
+  resource, e.g. if the 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 <span title="relevant
   application cache">relevant application caches</span> 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>
+   <li>which application cache the user prefers.
 
   </ul>
 
 
+
   <h4 id="manifests">The cache manifest syntax</h4>
 
 
   <h5>A sample manifest</h5>
 
   <p><em>This section is non-normative.</em></p>
 
   <p>This example manifest requires two images and a style sheet to be
   cached and whitelists a CGI script.</p>
 
@@ -42091,304 +42108,368 @@ style/default.css</pre>
   matches an entry in the online whitelist, or if a resource matches
   both an entry in the fallback section and the online whitelist, the
   resource will taken from the cache, and the online whitelist entry
   will be ignored.</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> for a <span
-  title="concept-appcache-manifest">manifest</span> URL or for an
-  <span>application cache</span>, potentially given a particular
+  process</dfn> for an <span>absolute URL</span> purported to identify
+  a <span title="concept-appcache-manifest">manifest</span>, or for an
+  <span>application cache group</span>, potentially given a particular
   <span>browsing context</span>, and potentially given a new <span
   title="concept-appcache-master">master</span> resource, the user
   agent must run the following steps:</p>
 
-  <p class="XXX">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); also, we need to update
-  this so all event firing uses queues</p>
-
   <ol>
 
    <li>
 
     <p>Atomically, so as to avoid race conditions, perform the
     following substeps:</p>
 
     <ol>
 
-     <li><p>Let <var title="">manifest URL</var> be the URL of the
-     <span title="concept-appcache-manifest">manifest</span> to be
-     updated, or of the <span
-     title="concept-appcache-manifest">manifest</span> of the
-     <span>application cache</span> to be updated, as
-     appropriate.</p></li>
-
-     <li><p>If these steps were invoked with a URL (as opposed to a
-     specific cache), and there is no <span>application cache</span>
-     identified by <var title="">manifest URL</var> whose <span
-     title="concept-appcache-lifecycle">lifecycle status</span> is not
-     <i>obsolete</i>, then create a new <span>application cache</span>
-     identified with that URL and set the group's <span
-     title="concept-appcache-lifecycle">lifecycle status</span> to
-     <i>new</i>.</p></li>
-
-     <li id="flagAsCandidateForCache"><p>If these steps were invoked
-     with a new <span title="concept-appcache-master">master</span>
-     resource, then flag the resource's <code>Document</code> as a
-     candidate for this manifest URL's caches, so that it will be <a
-     href="#flagAsCandidateForCache-result">associated with an
-     application cache identified by this manifest URL</a> later, when
-     such an <span>application cache</span> is ready.</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 URL</var>.</p></li>
-
-     <li><p>Let <var title="">cache</var> be the most recently updated
-     <span>application cache</span> identified by <var title="">manifest
-     URL</var> (that is, the newest version found in <var title="">cache
-     group</var>).</p></li>
+     <li>
+
+      <p>Pick the approprate substeps:</p>
+
+      <dl class="switch">
+
+       <dt>If these steps were invoked with an <span>absolute
+       URL</span> purported to identify a <span
+       title="concept-appcache-manifest">manifest</span></dt>
+
+       <dd>
+
+        <p>Let <var title="">manifest URL</var> be that <span>absolute
+        URL</span>.</p>
+
+        <p>If there is no <span>application cache group</span>
+        identified by <var title="">manifest URL</var>, then create a
+        new <span>application cache group</span> identified by <var
+        title="">manifest URL</var>. Initially it has no <span
+        title="application cache">application caches</span>, though
+        one will be created later in this algorithm.</p>
+
+       </dd>
+
+
+       <dt>If these steps were invoked with an <span>application cache
+       group</span></dt>
+
+       <dd>
+
+        <p>Let <var title="">manifest URL</var> be the <span>absolute
+        URL</span> of the <span
+        title="concept-appcache-manifest">manifest</span> used to
+        identify the <span>application cache group</span> to be
+        updated.</p>
+
+       </dd>
+
+      </dl>
+
+     </li>
+
+     <li><p>Let <var title="">cache group</var> be the
+     <span>application cache group</span> identified by <var
+     title="">manifest URL</var>.</p></li>
+
+     <li><p>If these steps were invoked with a new <span
+     title="concept-appcache-master">master</span> resource, then add
+     the resource, along with the resource's <code>Document</code>, to
+     <var title="">cache group</var>'s <span
+     title="concept-appcache-pending-masters">list of pending master
+     entries</span>.</p></li>
 
      <li><p>If these steps were invoked with a <span>browsing
      context</span>, and the <span
-     title="concept-appcache-status">status</span> of the <var
+     title="concept-appcache-status">status</span> of <var
      title="">cache group</var> is <i>checking</i> or
-     <i>downloading</i>, then <span>fire a simple event</span> called
-     <code title="event-checking">checking</code> at the
+     <i>downloading</i>, then <span>queue a task</span> to <span>fire
+     a simple event</span> called <code
+     title="event-checking">checking</code> at the
      <code>ApplicationCache</code> singleton of that <span>browsing
      context</span>.</p></li>
 
      <li><p>If these steps were invoked with a <span>browsing
      context</span>, and the <span
-     title="concept-appcache-status">status</span> of the <var
+     title="concept-appcache-status">status</span> of <var
      title="">cache group</var> is <i>downloading</i>, then also
-     <span>fire a simple event</span> called <code
-     title="event-downloading">downloading</code> at the
+     <span>queue a task</span> to <span>fire a simple event</span>
+     called <code title="event-downloading">downloading</code> at the
      <code>ApplicationCache</code> singleton of that <span>browsing
      context</span>.</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 this instance of the update
      process, as an update is already in progress for them.</p></li>
 
      <li><p>Set the <span
-     title="concept-appcache-status">status</span> of this group of
-     caches to <i>checking</i>.</p>
+     title="concept-appcache-status">status</span> of <var
+     title="">cache group</var> to <i>checking</i>.</p>
+
+     <li><p>For each <span>browsing context</span> whose <span>active
+     document</span> is associated with an <span>application
+     cache</span> in <var title="">cache group</var>, <span>queue a
+     task</span> to <span>fire a simple event</span> called <code
+     title="event-checking">checking</code> at the
+     <code>ApplicationCache</code> singleton of the <span>browsing
+     context</span>. The default action of these events 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>
 
     </ol>
 
     <p>The remainder of the steps run asychronously.</p>
 
-   </li>
-
-   <li>
-
-    <p>If there is already a resource with the URL of <var
-    title="">manifest URL</var> in <var title="">cache</var>, and
-    that resource is categorized 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>
+    <p>If <var title="">cache group</var> already has an
+    <span>application cache</span> in it, 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>
 
    </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>browsing
-    context</span> whose <span>active document</span> 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>
-
-    <p class="note">Again, if this is a <span
-    title="concept-appcache-cache">cache attempt</span>, then <var
-    title="">cache group</var> has only one cache and it has no
-    browsing contexts associated with it, so no events are dispatched
-    due to this step or any of the other steps that fire events other
-    than the final <code title="event-cached">cached</code> event.</p>
-
-   </li>
+   <li><p>If this is a <span title="concept-appcache-cache">cache
+   attempt</span>, then this algorithm was invoked with a
+   <span>browsing context</span>; <span>queue a task</span> to
+   <span>fire a simple event</span> called <code
+   title="event-checking">checking</code> at the
+   <code>ApplicationCache</code> singleton of that <span>browsing
+   context</span>.</p></li>
 
    <li>
 
-    <p><span>Fetch</span> the resource from <var title="">manifest
-    URL</var>, and let <var title="">manifest</var> be that
-    resource.</p>
+    <p><i>Fetching the manifest</i>: <span>Fetch</span> the resource
+    from <var title="">manifest URL</var>, and let <var
+    title="">manifest</var> be that resource.</p>
 
     <p>If the resource is labeled 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-fallback-ns">fallback
     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 due to a 404 or 410 response <span
-    title="concept-http-equivalent-codes">or equivalent</span>, then
-    run the <span>cache removal steps</span></p>
+    <p>If <i>fetching the manifest</i> fails due to a 404 or 410
+    response <span title="concept-http-equivalent-codes">or
+    equivalent</span>, then run these substeps:</p>
+
+    <ol> <!-- XXX can they be merged with the cache failure steps? (event name is different, this always disassociates even for upgrades, anything else?) -->
+
+     <li><p>For each <span>browsing context</span> whose <span>active
+     document</span> is associated with an <span>application
+     cache</span> in <var title="">cache group</var>, <span>queue a
+     task</span> to <span>fire a simple event</span> called <code
+     title="event-obsolete">obsolete</code> at the
+     <code>ApplicationCache</code> singleton of the <span>browsing
+     context</span>. The default action of these events should be the
+     display of some sort of user interface indicating to the user
+     that the application is no longer available for offline
+     use.</p></li>
+
+     <li><p>Unassociate any <code>Document</code> associated with an
+     <span>application cache</span> in <var title="">cache
+     group</var>.</p></li>
+
+     <li><p>If appropriate, remove any user interface indicating
+     that an update for this cache is in progress.</p></li>
+
+     <li><p>Discard <var title="">cache group</var> and its associated
+     <span title="application cache">application caches</span>, if
+     any.</p>
+
+     <li><p>Abort the update process.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li>
 
-    <p>If the previous step fails in some other way (e.g. the server
-    returns another 4xx or 5xx response <span
+    <p>Otherwise, if <i>fetching the manifest</i> fails in some other
+    way (e.g. the server returns another 4xx or 5xx response <span
     title="concept-http-equivalent-codes">or equivalent</span>, or
     there is a DNS error, or the connection times out, or the user
     cancels the download, or the parser for manifests fails when
     checking the magic signature), or if the server returned a
     redirect, or if the resource is labeled with a MIME type other
     than <code title="">text/cache-manifest</code>, then run the
     <span>cache failure steps</span>.</p>
 
    </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" <span
+    found in the <span title="concept-appcache-newer">newest</span>
+    <span>application cache</span> in <var title="">cache group</var>,
+    or the server reported it as "304 Not Modified" <span
     title="concept-http-equivalent-codes">or equivalent</span>, then
     run these substeps:</p>
 
-    <ol>
+    <ol> <!-- XXX can they be merged with the cache failure steps? (event name is different, anything else?) -->
+
+     <li><p>Let <var title="">cache</var> be the <span
+     title="concept-appcache-newer">newest</span> <span>application
+     cache</span> in <var title="">cache group</var>.</p></li>
 
-     <li><p><span>Fire a simple event</span> called <code
-     title="event-noupdate">noupdate</code> at the
-     <code>ApplicationCache</code> singleton of each <span>browsing
-     context</span> whose <span>active document</span> 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.</p></li>
-
-     <li><p>If there are any pending downloads of <span
-     title="concept-appcache-master">master entries</span> that are
-     being stored in the cache, then wait for all of them to have
-     completed. If any of these downloads fail (e.g. the server
-     returns a 4xx or 5xx response <span
-     title="concept-http-equivalent-codes">or equivalent</span>, or
-     there is a DNS error, or the connection times out, or the user
-     cancels the download), then run the <span>cache failure
-     steps</span>.</p></li>
+     <li>
+
+      <p>For each entry in <var title="">cache group</var>'s <span
+      title="concept-appcache-pending-masters">list of pending master
+      entries</span>, wait for the resource for this entry to have
+      completely downloaded.</p>
+
+      <p>If the download failed (e.g. the connection times out, or the
+      user cancels the download), then <span>queue a task</span> to
+      <span>fire a simple event</span> called <code
+      title="event-error">error</code> at the
+      <code>ApplicationCache</code> singleton of the <span>browsing
+      context</span> whose <span>active document</span> is the
+      <code>Document</code> for this entry, if there still is one. 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>
+
+      <p>Otherwise, associate the <code>Document</code> for this entry
+      with <var title="">cache</var>; store the resource for this
+      entry in <var title="">cache</var>, if it isn't already there,
+      and categorize its entry as a <span
+      title="concept-appcache-master">master entry</span>; and
+      <span>queue a task</span> to <span>fire a simple event</span>
+      called <code title="event-noupdate">noupdate</code> at the
+      <code>ApplicationCache</code> singleton of the <span>browsing
+      context</span> whose <span>active document</span> is the
+      <code>Document</code> for this entry, if there still is one. 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.</p>
+
+     </li>
+
+     <li><p>Empty <var title="">cache group</var>'s <span
+     title="concept-appcache-pending-masters">list of pending master
+     entries</span>.</p></li>
+
+     <li><p>If appropriate, remove any user interface indicating that
+     an update for this cache is in progress.</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>
+     title="concept-appcache-status">status</span> of <var
+     title="">cache group</var> be <i>idle</i>.</p></li>
 
      <li><p>Abort the update process.</p></li>
 
     </ol>
 
    </li>
 
+   <li><p>Let <var title="">new cache</var> be a newly created
+   <span>application cache</span> in <var title="">cache
+   group</var>. Set its <span
+   title="concept-appcache-completeness">completeness flag</span> to
+   <i>incomplete</i>.</p></li>
+
+   <li><p>For each entry in <var title="">cache group</var>'s <span
+   title="concept-appcache-pending-masters">list of pending master
+   entries</span>, associate the <code>Document</code> for this entry
+   with <var title="">new cache</var>.</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
+   <li><p>For each <span>browsing context</span> whose <span>active
+   document</span> is associated with an <span>application
+   cache</span> in <var title="">cache group</var>, <span>queue a
+   task</span> to <span>fire a simple event</span> called <code
    title="event-downloading">downloading</code> at the
-   <code>ApplicationCache</code> singleton of each <span>browsing
-   context</span> whose <span>active document</span> 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 URL</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>
+   <code>ApplicationCache</code> singleton of the <span>browsing
+   context</span>. The default action of these events 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>Let <var title="">file list</var> be an empty list of
    URLs with flags.</p></li>
 
    <li><p>Add all the URLs 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 URLs 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 URLs of <span
-   title="concept-appcache-master">master entries</span> in <var
-   title="">cache</var> to <var title="">file list</var>, each flagged
-   with "master entry".</p></li>
+   title="concept-appcache-master">master entries</span> in the <span
+   title="concept-appcache-newer">newest</span> <span>application
+   cache</span> in <var title="">cache group</var> whose <span
+   title="concept-appcache-completeness">completeness flag</span> is
+   <i>complete</i> to <var title="">file list</var>, each flagged with
+   "master entry".</p></li>
 
    <li><p>If any URL is in <var title="">file list</var> more than
    once, then merge the entries into one entry for that URL, that
    entry having all the flags that the original entries had.</p></li>
 
    <li>
 
     <p>For each URL in <var title="">file list</var>, run the
     following steps. These steps may be run in parallel for two or
     more of the URLs at a time.</p>
 
     <ol>
 
      <li>
 
       <p>If the resource URL being processed was flagged as neither an
       "explicit entry" nor or a "fallback entry", then the user agent
       may skip this URL.</p>
 
       <p class="note">This is intended to allow user agents to expire
-      resources (other than those in the manifest itself) from the
-      cache. Generally, implementors are urged to use an approach that
-      expires lesser-used resources first.</p>
+      resources not listed in the manifest (other than those in the
+      manifest itself) from the cache. Generally, implementors are
+      urged to use an approach that expires lesser-used resources
+      first.</p>
 
      </li>
 
-     <li><p><span>Fire a simple event</span> called <code
+     <li><p>For each <span>browsing context</span> whose <span>active
+     document</span> is associated with an <span>application
+     cache</span> in <var title="">cache group</var>, <span>queue a
+     task</span> to <span>fire a simple event</span> called <code
      title="event-progress">progress</code> at the
-     <code>ApplicationCache</code> singleton of each <span>browsing
-     context</span> whose <span>active document</span> 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 -->
+     <code>ApplicationCache</code> singleton of the <span>browsing
+     context</span>. The default action of these events 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><span>Fetch</span> 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 honor HTTP
       caching semantics (such as expiration, ETags, and so forth) with
       respect to that cache. User agents may also have other caches in
       place that are also honored.</p>
 
@@ -42442,36 +42523,39 @@ style/default.css</pre>
        <dd>
 
         <p>Skip this resource. It is dropped from the cache.</p>
 
        </dd>
 
        <dt>Otherwise</dt>
 
        <dd>
 
-        <p>Copy the resource and its metadata from <var
-        title="">cache</var>, and act as if that was the fetched
+        <p>Copy the resource and its metadata from the <span
+        title="concept-appcache-newer">newest</span> <span>application
+        cache</span> in <var title="">cache group</var> whose <span
+        title="concept-appcache-completeness">completeness flag</span>
+        is <i>complete</i>, and act as if that was the fetched
         resource, ignoring the resource obtained from the network.</p>
 
        </dd>
 
       </dl>
 
       <p>User agents may warn the user of these errors as an aid to
       development.</p>
 
       <p class="note">These rules make errors for resources listed in
       the manifest fatal, while making it possible for other resources
       to be removed from caches when they are removed from the server,
       without errors, and making non-manifest resources survive
-      server-side errors.
+      server-side errors.</p>
 
      </li>
 
      <li><p>Otherwise, the fetching succeeded. Store the resource in
      the <var title="">new cache</var>.</p></li>
 
      <li><p>If the URL being processed was flagged as an "explicit
      entry" in <var title="">file list</var>, then categorize the
      entry as an <span title="concept-appcache-explicit">explicit
      entry</span>.</p></li>
@@ -42502,34 +42586,75 @@ style/default.css</pre>
    and the URLs of the <span
    title="concept-appcache-fallback">fallback entries</span> that they
    map to, in <var title="">new cache</var>.</p></li>
 
    <li><p>Store the URLs that form the new <span
    title="concept-appcache-onlinewhitelist">online whitelist</span> in
    <var title="">new cache</var>.</p></li>
 
    <li>
 
-    <p>Wait for all pending downloads of <span
-    title="concept-appcache-master">master entries</span> that are
-    being stored in the cache to have completed.</p>
+    <p>For each entry in <var title="">cache group</var>'s <span
+    title="concept-appcache-pending-masters">list of pending master
+    entries</span>, wait for the resource for this entry to have
+    completely downloaded.</p>
+
+    <p>If the download failed (e.g. the connection times out, or the
+    user cancels the download), then run these sebsteps:</p>
+
+    <ol>
+
+     <li><p>Unassociate the <code>Document</code> for this entry from
+     <var title="">new cache</var>.</p></li>
+
+     <li><p><span>Queue a task</span> to <span>fire a simple event</span>
+     called <code title="event-error">error</code> at the
+     <code>ApplicationCache</code> singleton of the <span>browsing
+     context</span> whose <span>active document</span> is the
+     <code>Document</code> for this entry, if there still is one. 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>
+
+      <p>If this is a <span title="concept-appcache-cache">cache
+      attempt</span> and this entry is the last entry in <var
+      title="">cache group</var>'s <span
+      title="concept-appcache-pending-masters">list of pending master
+      entries</span>, then run these further substeps:</p>
+
+      <ol>
+
+       <li><p>Discard <var title="">cache group</var> and its only
+       <span>application cache</span>, <var title="">new
+       cache</var>.</p>
+
+       <li><p>If appropriate, remove any user interface indicating
+       that an update for this cache is in progress.</p></li>
+
+       <li><p>Abort the update process.</p></li>
+
+      </ol>
+
+     </li>
+
+     <li><p>Otherwise, remove this entry from <var title="">cache
+     group</var>'s <span title="concept-appcache-pending-masters">list
+     of pending master entries</span>.</p></li>
 
-    <p class="example">For example, if the <span>browsing
-    context</span>'s <span>active document</span> isn't itself listed
-    in the cache manifest, then it might still be being
-    downloaded.</p>
+    </ol>
 
-    <p>If any of these downloads fail (e.g. the connection times out,
-    or the user cancels the download), then run the <span>cache
-    failure steps</span>.</p> <!-- can't fail with a non-2xx code,
-    because things only get added to the cache implicitly once they
-    are known to have a manifest="" attribute. -->
+    <p>Otherwise, store the resource for this entry in <var
+    title="">new cache</var>, if it isn't already there, and
+    categorize its entry as a <span
+    title="concept-appcache-master">master entry</span>.</p>
 
    </li>
 
    <li>
 
     <p><span>Fetch</span> the resource from <var title="">manifest
     URL</var> again, and let <var title="">second manifest</var> be
     that resource.</p>
 
    </li>
@@ -42542,164 +42667,195 @@ style/default.css</pre>
     byte-for-byte identical, then schedule a rerun of the entire
     algorithm with the same parameters after a short delay, and run
     the <span>cache failure steps</span>.</p>
 
    </li>
 
    <li>
 
     <p>Otherwise, store <var title="">manifest</var> in <var
     title="">new cache</var>, if it's not there already, and
-    categorize this entry (whether newly added or not) as <span
+    categorize its entry as <span
     title="concept-appcache-manifest">the manifest</span>.</p>
 
    </li>
 
+   <li><p>Set the <span
+   title="concept-appcache-completeness">completeness flag</span> of
+   <var title="">new cache</var> to <i>complete</i>.</p></li>
+
    <li>
 
     <p>If this is a <span title="concept-appcache-cache">cache
-    attempt</span>, then:</p>
+    attempt</span>, then for each <span>browsing context</span>
+    whose <span>active document</span> is associated with an
+    <span>application cache</span> in <var title="">cache
+    group</var>, <span>queue a task</span> to <span>fire a simple
+    event</span> called <code title="event-cached">cached</code> at
+    the <code>ApplicationCache</code> singleton of the
+    <span>browsing context</span>. The default action of these
+    events 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>
+
+    <p>Otherwise, it is an <span
+    title="concept-appcache-upgrade">upgrade attempt</span>. For
+    each <span>browsing context</span> whose <span>active
+    document</span> is associated with an <span>application
+    cache</span> in <var title="">cache group</var>, <span>queue a
+    task</span> to <span>fire a simple event</span> called <code
+    title="event-updateready">updateready</code> at the
+    <code>ApplicationCache</code> singleton of the <span>browsing
+    context</span>. The default action of these events 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 id="flagAsCandidateForCache-result">Associate any
-    <code>Document</code> objects that were <a
-    href="#flagAsCandidateForCache">flagged as candidates</a> for this
-    manifest URL's caches with <var title="">cache</var>.</p>
+   <li><p>If appropriate, remove any user interface indicating that
+   an update for this cache is in progress.</p></li>
 
-    <p><span>Fire a simple event</span> called <code
-    title="event-cached">cached</code> at the
-    <code>ApplicationCache</code> singleton of each <span>browsing
-    context</span> whose <span>active document</span> 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>Set the <span title="concept-appcache-status">update
+   status</span> of <var title="">cache group</var> to
+   <i>idle</i>.</p></li>
 
-    <p>Set the <span title="concept-appcache-lifecycle">lifecycle
-    status</span> of <var title="">cache group</var> to
-    <i>mature</i>.</p>
+  </ol>
 
-    <p>Set the <span title="concept-appcache-status">update
-    status</span> of <var title="">cache group</var> to
-    <i>idle</i>.</p>
+  <p>The <dfn>cache failure steps</dfn> are as follows:</p>
 
-   </li>
+  <dl class="switch">
 
-   <li>
+   <dt>If this was a <span title="concept-appcache-cache">cache
+   attempt</span></dt>
 
-    <p>Otherwise, this is an <span
-    title="concept-appcache-upgrade">upgrade attempt</span>. Perform
-    the following substeps atomically, so as to avoid race
-    conditions:</p>
+   <dd>
 
     <ol>
 
-     <li>
+     <li><p>For each entry in <var title="">cache group</var>'s
+     <span title="concept-appcache-pending-masters">list of pending
+     master entries</span>, <span>queue a task</span> to <span>fire
+     a simple event</span> called <code
+     title="event-error">error</code> at the
+     <code>ApplicationCache</code> singleton of the <span>browsing
+     context</span> whose <span>active document</span> is the
+     <code>Document</code> for this entry, if there still is
+     one. 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 appropriate, remove any user interface indicating
+     that an update for this cache is in progress.</p></li>
 
-      <p>For each <span>browsing context</span> whose <span>active
-      document</span> is associated with a cache in <var
-      title="">cache group</var>, <span>queue a task</span> to
-      <span>fire a simple event</span> called <code
-      title="event-updateready">updateready</code> at the relevant
-      <code>ApplicationCache</code> singleton. The default action of
-      these events 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>Discard <var title="">cache group</var> (and its
+     <span>application cache</span>, if any).</p>
 
-      <p class="note">Since this step merely queues tasks, and since
-      all these substeps are being done atomically, the next step is
-      guaranteed to happen before the events are actually
-      dispatched.</p>
+     <li><p>Abort the update process.</p></li>
 
-     </li>
+    </ol>
 
-     <li>
+   </dd>
 
-      <p>Set the <span title="concept-appcache-status">status</span>
-      of <var title="">cache group</var> to <i>idle</i>.</p>
+   <dt>If this was an <span title="concept-appcache-upgrade">upgrade
+   attempt</span></dt>
 
-     </li>
+   <dd>
 
-    </ol>
+    <ol>
 
-   </li>
+     <li><p>For each <span>browsing context</span> whose <span>active
+     document</span> is associated with an <span>application
+     cache</span> in <var title="">cache group</var>, <span>queue a
+     task</span> to <span>fire a simple event</span> called <code
+     title="event-error">error</code> at the
+     <code>ApplicationCache</code> singleton of the <span>browsing
+     context</span>. The default action of these events 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>Let <var title="">cache</var> be the <span
+     title="concept-appcache-newer">newest</span> <span>application
+     cache</span> in <var title="">cache group</var>.</p></li>
 
-  </ol>
+     <li>
 
-  <p>The <dfn>cache removal steps</dfn> are as follows:</p>
+      <p>For each entry in <var title="">cache group</var>'s <span
+      title="concept-appcache-pending-masters">list of pending master
+      entries</span>, run the following further substeps.  These steps
+      may be run in parallel for two or more entries at a time.</p>
 
-  <ol>
+      <ol>
 
-   <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.</p></li>
+       <li><p>Wait for the resource for this entry to have completely
+       downloaded.</p>
+
+       <li><p>If the download was successful, associate the
+       <code>Document</code> for this entry with <var
+       title="">cache</var> (unassociating it from the other
+       <span>application cache</span> it is associated with, if any),
+       store the resource for this entry in <var title="">cache</var>,
+       if it isn't already there, and categorize its entry as a <span
+       title="concept-appcache-master">master entry</span>.</p></li>
+
+       <li><p><span>Queue a task</span> to <span>fire a simple
+       event</span> called <code title="event-error">error</code> at
+       the <code>ApplicationCache</code> singleton of the
+       <span>browsing context</span> whose <span>active
+       document</span> is the <code>Document</code> for this entry, if
+       there still is one. 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><p><span>Fire a simple event</span> called <code
-   title="event-obsolete">obsolete</code> at the
-   <code>ApplicationCache</code> singleton of each <span>browsing
-   context</span> whose <span>active document</span> 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 no longer available
-   for offline use.</p></li>
-
-   <li><p>Set the <span title="concept-appcache-lifecycle">lifecycle
-   status</span> of <var title="">cache group</var> to
-   <i>obsolete</i>.</p></li>
+      </ol>
 
-   <li><p>Let the <span title="concept-appcache-status">update
-   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. Abort the update process.</p></li>
+     </li>
 
-  </ol>
+     <li><p>Empty <var title="">cache group</var>'s <span
+     title="concept-appcache-pending-masters">list of pending master
+     entries</span>.</p></li>
 
-  <p>The <dfn>cache failure steps</dfn> are as follows:</p>
+     <li><p>If <var title="">cache group</var> has an
+     <span>application cache</span> whose <span
+     title="concept-appcache-completeness">completeness flag</span> is
+     <i>incomplete</i>, then discrad that <span>application
+     cache</span>.</p>
 
-  <ol>
+     <li><p>If appropriate, remove any user interface indicating that
+     an update for this cache is in progress.</p></li>
 
-   <li><p><span>Fire a simple event</span> called <code
-   title="event-error">error</code> at the
-   <code>ApplicationCache</code> singleton of each <span>browsing
-   context</span> whose <span>active document</span> 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>Let the <span
+     title="concept-appcache-status">status</span> of <var
+     title="">cache group</var> be <i>idle</i>.</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.</p></li>
-
-   <li><p>Otherwise, 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. Abort the update
-   process.</p></li>
+     <li><p>Abort the update process.</p></li>
 
-  </ol>
+    </ol>
+
+   </dd>
+
+  </dl>
+
+  <hr>
 
   <p>User agents may invoke the <span>application cache update
   process</span>, in the background, for any <span>application
   cache</span>, at any time (with no <span>browsing
   context</span>). This allows user agents to keep caches primed and
   to update caches even before the user visits a site.</p>
 
 
 
-  <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>
+  <h4>Matching a fallback namespace</h4>
 
   <p>A URL <dfn title="concept-appcache-matches-fallback">matches a
   fallback namespace</dfn> if there exists a <span>relevant
   application cache</span> whose <span
   title="concept-appcache-manifest">manifest</span>'s URL has the
   <span>same origin</span> as the URL in question, and that has a
   <span title="concept-appcache-fallback-ns">fallback namespace</span>
   that is a <span>prefix match</span> for the URL being examined. If
   multiple fallback namespaces match the same URL, the longest one is
   the one that matches. A URL looking for an fallback namespace can
@@ -42716,140 +42872,125 @@ style/default.css</pre>
    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 URL.</p>
 
    <!-- "resolve a url" canonicalises the case for the scheme and host
    and removes the port if it is the default -->
 
   </div>
 
-  <hr>
-
-  <p>When the <dfn
-  title="concept-appcache-init-with-attribute">application cache
-  selection algorithm</dfn> algorithm is invoked with a manifest URL
-  and document, the user agent must run the first applicable set of
-  steps from the following list:</p>
-
-  <dl class="switch">
-
-   <dt>If the document is not being loaded as part of navigation of a
-   <span>browsing context</span></dt>
-
-   <dd>
-
-    <p>Do nothing.</p>
-
-    <p class="note">For instance, the HTML parser can call this
-    algorithm during the processing of a document generated
-    exclusively from <code
-    title="dom-document-write">document.open()</code> and <code
-    title="dom-document-write">document.write()</code>, without
-    navigation taking place.</p>
-
-   </dd>
 
+  <h4>The application cache selection algorithm</h4>
 
-   <!-- otherwise, we're talking browsing contexts only: -->
+  <p>When the <dfn title="concept-appcache-init">application cache
+  selection algorithm</dfn> algorithm is invoked with a
+  <code>Document</code> <var title="">document</var> and optinally a
+  manifest <span>URL</span> <var title="">manifest URL</var>, the user
+  agent must run the first applicable set of steps from the following
+  list:</p>
 
-   <dt>If the document was loaded from an application cache and the
-   URL of that application cache's manifest is the same as the
-   manifest URL 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> for that cache and with the <span>browsing
-    context</span> being navigated.</p>
-
-   </dd>
+  <dl class="switch">
 
+   <dt>If <var title="">document</var> was loaded from an
+   <span>application cache</span>, and there is no <var
+   title="">manifest URL</var></dt>
 
-   <dt>If the document being loaded was loaded from an application
-   cache and the URL of that application cache's manifest is
-   <em>not</em> the same as the manifest URL with which the algorithm
-   was invoked</dt>
+   <dt>If <var title="">document</var> was loaded from an
+   <span>application cache</span>, and the URL of the <span
+   title="concept-appcache-manifest">manifest</span> of that cache's
+   <span>application cache group</span> is <em>not</em> the same as
+   <var title="">manifest URL</var></dt>
 
    <dd>
 
-    <p>Mark the entry for this document in the application cache from
-    which it was loaded as <span
+    <p>Mark the entry for the resource from which <var
+    title="">document</var> was taken in the <span>application
+    cache</span> 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>
+    the new page</span> is only ever completed <em>after</em> this
+    <span title="concept-appcache-init">application cache selection
+    algorithm</span> 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 document's own metadata, to aid in
     application development.</p>
 
    </dd>
 
 
-   <dt>If the document being loaded was not loaded from an application
-   cache, but it was loaded using HTTP GET <span
-   title="concept-http-equivalent-get">or equivalent</span></dt> <dd>
+   <dt>If <var title="">document</var> was loaded from an
+   <span>application cache</span><!--[redundant], and the URL of the
+   <span title="concept-appcache-manifest">manifest</span> of that
+   cache's <span>application cache group</span> is the same as <var
+   title="">manifest URL</var>--></dt>
 
-    <ol>
+   <dd>
 
-     <li><p>If the manifest URL does not have the <span>same
-     origin</span> as the document, 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>
+    <p>Associate <var title="">document</var> with the
+    <span>application cache</span> from which it was loaded. Invoke
+    the <span>application cache update process</span> for that cache
+    and with the <span>browsing context</span> being navigated.</p>
 
-     <li><p>Otherwise, invoke the <span>application cache update
-     process</span> for the given manifest URL, with the
-     <span>browsing context</span> being navigated, and with the
-     <code>Document</code> as the new <span
-     title="concept-appcache-master">master</span> resource.</p></li>
+   </dd>
 
-    </ol>
+
+   <dt>If <var title="">document</var> <!--[redundant] was not loaded
+   from an <span>application cache</span>, but it--> was loaded using
+   HTTP GET <span title="concept-http-equivalent-get">or
+   equivalent</span>, and <var title="">manifest URL</var> has the
+   <span>same origin</span> as <var title="">document</var></dt>
+
+   <dd>
+
+    <p>Invoke the <span>application cache update process</span> for
+    <var title="">manifest URL</var>, with the <span>browsing
+    context</span> being navigated, and with <var
+    title="">document</var> and the resource from which <var
+    title="">document</var> was loaded as the new <span
+    title="concept-appcache-master">master</span> resource.</p>
 
    </dd>
 
 
-   <dt>Otherwise</dt>
+   <dt>Otherwise</dt> <!-- not from cache and either non GET or wrong-origin manifest -->
+
    <dd>
-    <p>Invoke the <span
-    title="concept-appcache-init-no-attribute">application cache
-    selection algorithm</span> again, but without a manifest.</p>
+
+    <p>The <code>Document</code> is not associated with any
+    <span>application cache</span>.</p>
+
+    <p>If there was a <var title="">manifest URL</var>, the user agent
+    may report to the user that it was ignored, to aid in application
+    development.</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, if
-  the document is being loaded as part of navigation of a
-  <span>browsing context</span>, and it 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, with
-  that <span>browsing context</span>. Otherwise, nothing special
-  happens.</p>
-
 
 
   <h5 id="changesToNetworkingModel">Changes to the networking model</h5>
 
-  <p>When a <span>browsing context</span> is associated with an
-  <span>application cache</span>, any and all loads for resources in
+  <p>When a <span>browsing context</span>'s <span>active
+  document</span> is associated with an <span>application cache</span>
+  whose <span title="concept-appcache-completeness">completeness
+  flag</span> is <i>complete</i>, any and all loads for resources in
   that <span>browsing context</span> other than those for <span
   title="child browsing context">child browsing contexts</span> 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 <span title="concept-http-equivalent-get">or
    equivalent</span>, or if it has a <span title="javascript
@@ -42889,36 +43030,37 @@ style/default.css</pre>
    whitelist</span> that has the <span>same origin</span> as the
    resource's URL and that is a <span>prefix match</span> for the
    resource's URL, then <span>fetch</span> the resource normally and
    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>
+  not present in the <span
+  title="concept-appcache-manifest">manifest</span> will always fail
+  to load (at least, after the <span>application cache</span> 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;
-  const unsigned short <span title="dom-appcache-OBSOLETE">OBSOLETE</span> = 5;
   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>();
 
   // events
            attribute <span>Function</span> <span title="handler-appcache-onchecking">onchecking</span>;
            attribute <span>Function</span> <span title="handler-appcache-onerror">onerror</span>;
            attribute <span>Function</span> <span title="handler-appcache-onnoupdate">onnoupdate</span>;
@@ -42959,60 +43101,52 @@ style/default.css</pre>
    <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-status">update status</span> and the
-   <i>mature</i> <span title="concept-appcache-lifecycle">lifecycle
-   status</span> and that application cache is the newest cache in its
+   an <span>application cache</span> whose <span>application cache
+   group</span>'s <span title="concept-appcache-status">update
+   status</span> is <i>idle</i>, and that application cache is the
+   <span title="concept-appcache-newer">newest</span> cache in its
    group.</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-status">update
-   status</span>.</p></dd>
+   an <span>application cache</span> whose <span>application cache
+   group</span>'s <span title="concept-appcache-status">update
+   status</span> is <i>checking</i>.</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-status">update
-   status</span>.</p></dd>
+   an <span>application cache</span> whose <span>application cache
+   group</span>'s <span title="concept-appcache-status">update
+   status</span> is <i>downloading</i>.</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>idle</i>
-   <span title="concept-appcache-status">update status</span> and the
-   <i>mature</i> <span title="concept-appcache-lifecycle">lifecycle
-   status</span> but that application cache is <em>not</em> the newest
+   an <span>application cache</span> whose <span>application cache
+   group</span>'s <span title="concept-appcache-status">update
+   status</span> is <i>idle</i>, but that application cache is
+   <em>not</em> the <span title="concept-appcache-newer">newest</span>
    cache in its group.</p></dd>
 
-   <dt><dfn title="dom-appcache-OBSOLETE"><code>OBSOLETE</code></dfn>
-   (numeric value 5)</dt>
-
-   <dd><p>The <code>ApplicationCache</code> object is associated with
-   an <span>application cache</span> whose group is in the
-   <i>obsolete</i> <span title="concept-appcache-lifecycle">lifecycle
-   status</span>.</p></dd>
-
   </dl>
 
   <hr>
 
   <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, but with no <span>browsing context</span>. If there is
@@ -43032,38 +43166,35 @@ style/default.css</pre>
    <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></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>If the group of <span title="application cache">application
-   caches</span> to which <var title="">cache</var> belongs has the
-   <span title="concept-appcache-lifecycle">lifecycle status</span>
-   <i>obsolete</i>, unassociate <var title="">document</var> from <var
-   title="">cache</var> and abort these steps.</p></li>
-
-   <li><p>Otherwise, check that there is an application cache in the
-   same group as <var title="">cache</var> which has an entry
-   categorized as a <span
-   title="concept-appcache-manifest">manifest</span> that is newer
-   than <var title="">cache</var>. If there is not, then raise an
+   <li><p>Check that there is an application cache in the same
+   <span>application cache group</span> as <var title="">cache</var>
+   whose <span title="concept-appcache-completeness">completeness
+   flag</span> is <i>complete</i> and that is <span
+   title="concept-appcache-newer">newer</span> 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 categorized as a <span
-   title="concept-appcache-manifest">manifest</span>.</p></li>
+   <li><p>Let <var title="">new cache</var> be the <span
+   title="concept-appcache-newer">newest</span> <span>application
+   cache</span> in the same <span>application cache group</span> as
+   <var title="">cache</var> whose <span
+   title="concept-appcache-completeness">completeness flag</span> is
+   <i>complete</i>.</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 attributes</span> that
   must be supported, as DOM attributes, by all objects implementing
   the <code>ApplicationCache</code> interface:</p>
@@ -44088,24 +44219,23 @@ user reload must be equivalent to .reload()
   section, keep them in sync -->
 
   <p>When no more bytes are available, an EOF character is implied,
   which eventually causes a <code title="event-load">load</code> event
   to be fired.</p>
 
   <p>After creating the <code>Document</code> object, but potentially
   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>
+  <p class="note"><span title="concept-appcache-init">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
   first create a <code>Document</code> object, following the
   requirements of the XML and Namespaces in XML recommendations, RFC
   3023, DOM3 Core, and other relevant specifications. <a
@@ -44122,29 +44252,29 @@ user reload must be equivalent to .reload()
   character encoding.</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-manifest">manifest</code>, then, as soon as the
   element is <span title="insert an element into a document">inserted
   into the document</span>, the user agent must <span title="resolve a
   url">resolve</span> the value of that attribute, and if that is
   successful, must run the <span
-  title="concept-appcache-init-with-attribute">application cache
-  selection algorithm</span> with the resulting <span>absolute
-  URL</span> as the manifest URL, and passing in the newly-created
+  title="concept-appcache-init">application cache selection
+  algorithm</span> with the resulting <span>absolute URL</span> as the
+  manifest URL, and passing in the newly-created
   <code>Document</code>. Otherwise, if the attribute is absent or
   resolving it fails, then as soon as the root element is <span
   title="insert an element into a document">inserted into the
   document</span>, the user agent must run the <span
-  title="concept-appcache-init-no-attribute">application cache
-  selection algorithm</span> with no manifest, passing in the
+  title="concept-appcache-init">application cache selection
+  algorithm</span> with no manifest, passing in the
   <code>Document</code>.</p>
 
   <p class="note">Because the processing of the <code
   title="attr-html-manifest">manifest</code> attribute happens
   only once the root element is parsed, any URLs referenced by
   processing instructions before the root element (such as <code
   title="">&lt;?xml-styleesheet?></code> and <code
   title="">&lt;?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
@@ -44185,22 +44315,21 @@ user reload must be equivalent to .reload()
 
   <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="#refsRFC2646">[RFC2646]</a></p>
 
   <p>The <span>document's character encoding</span> must be set to the
   character encoding used to decode the document.</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
+  must run the <span title="concept-appcache-init">application cache
   selection algorithm</span> with no manifest, passing in the
   newly-created <code>Document</code>.</p>
 
   <!-- next two paragraphs are nearly identical to the navigate-html
   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 -->
 
   <p>When no more character are available, an EOF character is
   implied, which eventually causes a <code
@@ -44228,22 +44357,21 @@ user reload must be equivalent to .reload()
   <code title="attr-img-src">src</code> attribute of the
   <code>img</code> element to the address of the image.</p>
 
   <!-- next three paragraphs are similar to the navigate-text section,
   keep them in sync -->
 
   <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
+  must run the <span title="concept-appcache-init">application cache
   selection algorithm</span> with no manifest, passing in the
   newly-created <code>Document</code>.</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>
 
   <p>User agents may add content to the <code>head</code> element of
   the <code>Document</code>, or attributes to the <code>img</code>
   element, e.g. to link to stylesheet or an XBL binding, to provide a
@@ -44263,22 +44391,21 @@ user reload must be equivalent to .reload()
   title="attr-embed-src">src</code> attribute of the
   <code>embed</code> element to the address of the resource.</p>
 
   <!-- next three paragraphs are similar to the navigate-text section,
   keep them in sync -->
 
   <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
+  must run the <span title="concept-appcache-init">application cache
   selection algorithm</span> with no manifest, passing in the
   newly-created <code>Document</code>.</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>
 
   <p>User agents may add content to the <code>head</code> element of
   the <code>Document</code>, or attributes to the <code>embed</code>
   element, e.g. to link to stylesheet or an XBL binding, or to give
@@ -44301,22 +44428,21 @@ user reload must be equivalent to .reload()
   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 <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
+  must run the <span title="concept-appcache-init">application cache
   selection algorithm</span> with no manifest, passing in the
   newly-created <code>Document</code>.</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>
 
 
 
   <h4 id="scroll-to-fragid"><dfn title="navigate-fragid">Navigating to a fragment identifier</dfn></h4>
@@ -44447,24 +44573,21 @@ user reload must be equivalent to .reload()
        <li id="resetBCName">The browsing context's <span>browsing
        context name</span> must be unset.</li>
 
       </ol>
 
      </li>
 
      <li id="appcache-history-2">The user agent must make the
      <i>specified entry</i>'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</a> which <span>application
-     cache</span> it is associated with.)</li>
+     context</span>.</li>
 
      <li>If the <i>specified entry</i> has a <span>browsing
      context name</span> stored with it, then the following
      sub-sub-steps must be run:
 
       <ol>
 
        <li>The browsing context's <span>browsing context name</span>
        must be set to the name stored with the specified entry.</li>
 
@@ -56717,48 +56840,51 @@ interface <dfn>MessageChannel</dfn> {
    </dd>
 
    <dt>A start tag whose tag name is "html"</dt>
    <dd>
 
     <p><span>Create an element for the token</span> in the <span>HTML
     namespace</span>. Append it to the <code>Document</code>
     object. Put this element in the <span>stack of open
     elements</span>.</p>
 
-    <p id="parser-appcache">If the token has an attribute "manifest",
-    then <span title="resolve a url">resolve</span> the value of that
-    attribute to an <span>absolute URL</span>, and if that is
-    successful, run the <span
-    title="concept-appcache-init-with-attribute">application cache
-    selection algorithm</span> with the resulting <span>absolute
-    URL</span>. Otherwise, if there is no such attribute or resolving
-    it fails, run the <span
-    title="concept-appcache-init-no-attribute">application cache
+    <p id="parser-appcache">If the <code>Document</code> is being
+    loaded as part of <span title="navigate">navigation</span> of a
+    <span>browsing context</span>, then: if the token has an attribute
+    "manifest", then <span title="resolve a url">resolve</span> the
+    value of that attribute to an <span>absolute URL</span>, and if
+    that is successful, run the <span
+    title="concept-appcache-init">application cache selection
+    algorithm</span> with the resulting <span>absolute URL</span>;
+    otherwise, if there is no such attribute or resolving it fails,
+    run the <span title="concept-appcache-init">application cache
     selection algorithm</span> with no manifest. The algorithm must be
     passed the <code>Document</code> object.</p>
 
     <p>Switch the <span>insertion mode</span> to "<span
     title="insertion mode: before head">before head</span>".</p>
 
    </dd>
 
    <dt>Anything else</dt>
    <dd>
 
     <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. Put this element in the
     <span>stack of open elements</span>.</p>
 
-    <p>Run the <span
-    title="concept-appcache-init-no-attribute">application cache
-    selection algorithm</span> with no manifest, passing it the
+    <p>If the <code>Document</code> is being loaded as part of <span
+    title="navigate">navigation</span> of a <span>browsing
+    context</span>, then: run the <span
+    title="concept-appcache-init">application cache selection
+    algorithm</span> with no manifest, passing it the
     <code>Document</code> object.</p>
 
     <p>Switch the <span>insertion mode</span> to "<span
     title="insertion mode: before head">before head</span>", then
     reprocess the current token.</p>
 
     <p class="XXX">Should probably make end tags be ignored, so
     that "&lt;/head>&lt;!-- -->&lt;html>" puts the comment before the
     root node (or should we?)</p>
 

|