HTML Standard Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/2692

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
Index: source
===================================================================
--- source	(revision 2691)
+++ source	(revision 2692)
@@ -8751,10 +8751,10 @@
   <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
@@ -10646,7 +10646,7 @@
 
        <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
@@ -39896,7 +39896,7 @@
   <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>
@@ -41522,43 +41522,9 @@
 
   <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>An <dfn>application cache</dfn> is a set of cached resources
+  consisting of:</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>
-
   <ul>
 
    <li>
@@ -41631,9 +41597,59 @@
 
   </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
@@ -41648,11 +41664,12 @@
    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>
 
 
@@ -42098,22 +42115,13 @@
 
   <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>
@@ -42123,54 +42131,75 @@
 
     <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>
 
-     <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>
+      <p>Pick the approprate substeps:</p>
 
-     <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>
+      <dl class="switch">
 
-     <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>
+       <dt>If these steps were invoked with an <span>absolute
+       URL</span> purported to identify a <span
+       title="concept-appcache-manifest">manifest</span></dt>
 
-     <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>
+       <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>
 
@@ -42180,60 +42209,45 @@
      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>
+    <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>
-
-    <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>
-
    </li>
 
-   <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>
 
-    <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><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
@@ -42250,12 +42264,44 @@
 
    <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>
 
-    <p>If the previous step fails in some other way (e.g. the server
-    returns another 4xx or 5xx response <span
+    <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>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
@@ -42271,37 +42317,62 @@
     <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><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>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>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>
 
@@ -42309,26 +42380,30 @@
 
    </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>
+   <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>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>
-
    <li><p>Let <var title="">file list</var> be an empty list of
    URLs with flags.</p></li>
 
@@ -42344,9 +42419,12 @@
 
    <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
@@ -42367,21 +42445,24 @@
       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>
 
@@ -42449,8 +42530,11 @@
 
        <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>
@@ -42464,7 +42548,7 @@
       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>
 
@@ -42509,21 +42593,62 @@
 
    <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 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>
+    <p>If the download failed (e.g. the connection times out, or the
+    user cancels the download), then run these sebsteps:</p>
 
-    <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. -->
+    <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>
+
+    </ol>
+
+    <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>
@@ -42549,136 +42674,172 @@
 
     <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 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>
+    <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>
 
-    <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-lifecycle">lifecycle
-    status</span> of <var title="">cache group</var> to
-    <i>mature</i>.</p>
+   <li><p>If appropriate, remove any user interface indicating that
+   an update for this cache is in progress.</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-status">update
+   status</span> of <var title="">cache group</var> to
+   <i>idle</i>.</p></li>
 
-   </li>
+  </ol>
 
-   <li>
+  <p>The <dfn>cache failure steps</dfn> are as follows:</p>
 
-    <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>
+  <dl class="switch">
 
+   <dt>If this was a <span title="concept-appcache-cache">cache
+   attempt</span></dt>
+
+   <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>
 
-      <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>If appropriate, remove any user interface indicating
+     that an update for this cache is in progress.</p></li>
 
-      <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>Discard <var title="">cache group</var> (and its
+     <span>application cache</span>, if any).</p>
 
-     </li>
+     <li><p>Abort the update process.</p></li>
 
-     <li>
+    </ol>
 
-      <p>Set the <span title="concept-appcache-status">status</span>
-      of <var title="">cache group</var> to <i>idle</i>.</p>
+   </dd>
 
-     </li>
+   <dt>If this was an <span title="concept-appcache-upgrade">upgrade
+   attempt</span></dt>
 
-    </ol>
+   <dd>
 
-   </li>
+    <ol>
 
-  </ol>
+     <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>
 
-  <p>The <dfn>cache removal steps</dfn> are as follows:</p>
+     <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>
 
-   <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>
+      <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>
 
-   <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>
+      <ol>
 
-   <li><p>Set the <span title="concept-appcache-lifecycle">lifecycle
-   status</span> of <var title="">cache group</var> to
-   <i>obsolete</i>.</p></li>
+       <li><p>Wait for the resource for this entry to have completely
+       downloaded.</p>
 
-   <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><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>
 
-  </ol>
+       <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>
 
-  <p>The <dfn>cache failure steps</dfn> are as follows:</p>
+      </ol>
 
-  <ol>
+     </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>Empty <var title="">cache group</var>'s <span
+     title="concept-appcache-pending-masters">list of pending master
+     entries</span>.</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>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>
 
-   <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>If appropriate, remove any user interface indicating that
+     an update for this cache is in progress.</p></li>
 
-  </ol>
+     <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>Abort the update process.</p></li>
+
+    </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
@@ -42687,13 +42848,8 @@
 
 
 
-  <h4>Processing model</h4>
+  <h4>Matching a fallback namespace</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 URL <dfn title="concept-appcache-matches-fallback">matches a
   fallback namespace</dfn> if there exists a <span>relevant
   application cache</span> whose <span
@@ -42723,65 +42879,42 @@
 
   </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>
+  <h4>The application cache selection algorithm</h4>
 
+  <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>
+
   <dl class="switch">
 
-   <dt>If the document is not being loaded as part of navigation of a
-   <span>browsing context</span></dt>
+   <dt>If <var title="">document</var> was loaded from an
+   <span>application cache</span>, and there is no <var
+   title="">manifest URL</var></dt>
 
-   <dd>
+   <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>
 
-    <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>
-
-
-   <!-- otherwise, we're talking browsing contexts only: -->
-
-   <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>
-
-
-   <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>
-
    <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
@@ -42794,55 +42927,63 @@
    </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
@@ -42896,9 +43037,11 @@
   </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>
@@ -42911,7 +43054,6 @@
   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
@@ -42966,46 +43108,38 @@
    (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>
@@ -43039,24 +43173,21 @@
    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
@@ -44095,10 +44226,9 @@
   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>
 
 
 
@@ -44129,15 +44259,15 @@
   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
@@ -44192,8 +44322,7 @@
   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>
 
@@ -44235,8 +44364,7 @@
   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>
 
@@ -44270,8 +44398,7 @@
   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>
 
@@ -44308,8 +44435,7 @@
   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>
 
@@ -44454,10 +44580,7 @@
      <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
@@ -56724,15 +56847,16 @@
     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>
 
@@ -56749,9 +56873,11 @@
     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

|