Skip to content
Permalink
Browse files

[gwr] (2) Make application caches work at the iframe level as well, n…

…ot just whole-window level. This allows <iframe>s to contain gadgets from other hosts that are themselves cached.

git-svn-id: http://svn.whatwg.org/webapps@2344 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Oct 16, 2008
1 parent acfdd0a commit 2f54561cf942fe360b77e5bcceb5a45549097a8d
Showing with 232 additions and 180 deletions.
  1. +112 −86 index
  2. +120 −94 source
198 index
which is one of the following: <i>idle</i>, <i>checking</i>,
<i>downloading</i>.</p>

<p id=appcache-history-1>A <a href=#browsing-context>browsing context</a> can be
associated with an application cache. A <a href=#child-browsing-context>child browsing
context</a> is always associated with the same application cache
as its <a href=#parent-browsing-context>parent browsing context</a>, if any. A
<a href=#top-level-browsing-context>top-level browsing context</a> is associated with the
application cache appropriate for its <a href=#active-document>active
document</a>. (A browsing context's associated cache thus can <a href=#appcache-history-2>change</a> during <a href=#traverse-the-history title="traverse
the history">session history traversal</a>.)</p>

<p>A <code>Document</code> initially has no appropriate cache, but
steps <a href=#parser-appcache>in the parser</a> and in the <a href=#navigate title=navigate>navigation</a> sections cause <a href=#concept-appcache-init-with-attribute title=concept-appcache-init-with-attribute>cache selection</a>
to occur early in the page load process.</p>
<p id=appcache-history-1>A <a href=#browsing-context>browsing context</a> is
associated with the application cache appropriate for its
<a href=#active-document>active document</a>, if any. A <code>Document</code>
initially has no appropriate cache, but steps <a href=#parser-appcache>in the parser</a> and in the <a href=#navigate title=navigate>navigation</a> sections cause <a href=#concept-appcache-init-with-attribute title=concept-appcache-init-with-attribute>cache selection</a>
to occur early in the page load process. A browsing context's
associated cache can also <a href=#appcache-history-2>change</a>
during <a href=#traverse-the-history title="traverse the history">session history
traversal</a>.</p>

<p>An application cache consists of:</p>

<li>

<p><a href=#fire-a-simple-event>Fire a simple event</a> called <code title=event-checking>checking</code> at the
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#top-level-browsing-context>top-level
browsing context</a> that is associated with a cache in <var title="">cache group</var>. The default action of this event
should be the display of some sort of user interface indicating to
the user that the user agent is checking for the availability of
updates.</p>
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#browsing-context>browsing
context</a> whose <a href=#active-document>active document</a> is associated
with a cache in <var title="">cache group</var>. The default
action of this event should be the display of some sort of user
interface indicating to the user that the user agent is checking
for the availability of updates.</p>

</li>

as "304 Not Modified" or equivalent, then run these substeps:</p>

<ol><li><p><a href=#fire-a-simple-event>Fire a simple event</a> called <code title=event-noupdate>noupdate</code> at the
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#top-level-browsing-context>top-level
browsing context</a> that is associated with a cache in <var title="">cache group</var>. The default action of this event
should be the display of some sort of user interface indicating
to the user that the application is up to date.</li>
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#browsing-context>browsing
context</a> whose <a href=#active-document>active document</a> 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.</li>

<li><p>If there are any pending downloads of <span title="implicit entry">implicit entries</span> that are being
stored in the cache, then wait for all of them to have
of <var title="">cache group</var> to <i>downloading</i>.</li>

<li><p><a href=#fire-a-simple-event>Fire a simple event</a> called <code title=event-downloading>downloading</code> at the
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#top-level-browsing-context>top-level
browsing context</a> that is associated with a cache in <var title="">cache group</var>. The default action of this event should
be the display of some sort of user interface indicating to the
user that a new version is being downloaded.</li>
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#browsing-context>browsing
context</a> whose <a href=#active-document>active document</a> is associated
with a cache in <var title="">cache group</var>. The default action
of this event should be the display of some sort of user interface
indicating to the user that a new version is being
downloaded.</li>

<li><p>If this is an <a href=#concept-appcache-upgrade title=concept-appcache-upgrade>upgrade
attempt</a>, then let <var title="">new cache</var> be a newly
more of the URLs at a time.</p>

<ol><li><p><a href=#fire-a-simple-event>Fire a simple event</a> called <code title=event-progress><a href=#event-progress>progress</a></code> at the
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#top-level-browsing-context>top-level
browsing context</a> that is associated with a cache in <var title="">cache group</var>. The default action of this event
should be the display of some sort of user interface indicating
to the user that a file is being downloaded in preparation for
updating the application.</li> <!-- XXX need to include
progress information -->
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#browsing-context>browsing
context</a> whose <a href=#active-document>active document</a> is associated
with a cache in <var title="">cache group</var>. The default
action of this event should be the display of some sort of user
interface indicating to the user that a file is being downloaded
in preparation for updating the application.</li> <!-- XXX
need to include progress information -->

<li>

entry as a <a href=#concept-appcache-dynamic title=concept-appcache-dynamic>dynamic
entry</a>.</li>

<li><p>As an optimization, if the resource is an HTML or XML file
whose root element is an <code><a href=#the-html-element>html</a></code> element with a <code title=attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute whose value
doesn't match the manifest URL of the application cache being
processed, then the user agent should mark the entry as being
<a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>.</p>

</ol></li>

<li><p>Store <var title="">manifest</var> in <var title="">new
entry">implicit entries</span> that are being stored in the cache
to have completed.</p>

<p class=example>For example, if the <a href=#top-level-browsing-context>top-level browsing
<p class=example>For example, if the <a href=#browsing-context>browsing
context</a>'s <a href=#active-document>active document</a> isn't itself listed
in the cache manifest, then it might still be being
downloaded.</p>
manifest URL's caches with <var title="">cache</var>.</p>

<p><a href=#fire-a-simple-event>Fire a simple event</a> called <code title=event-cached>cached</code> at the
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#top-level-browsing-context>top-level
browsing context</a> that is associated with a cache in <var title="">cache group</var>. The default action of this event
should be the display of some sort of user interface indicating to
the user that the application has been cached and that they can
now use it offline.</p>
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#browsing-context>browsing
context</a> whose <a href=#active-document>active document</a> 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>

<p>Set the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of
<var title="">cache group</var> to <i>idle</i>.</p>
<p>Otherwise, this is an <a href=#concept-appcache-upgrade title=concept-appcache-upgrade>upgrade attempt</a>:</p>

<p><a href=#fire-a-simple-event>Fire a simple event</a> called <code title=event-updateready>updateready</code> at the
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#top-level-browsing-context>top-level
browsing context</a> that is associated with a cache in <var title="">cache group</var>. The default action of this event
should be the display of some sort of user interface indicating to
the user that a new version is available and that they can
activate it by reloading the page.</p>
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#browsing-context>browsing
context</a> whose <a href=#active-document>active document</a> is associated
with a cache in <var title="">cache group</var>. The default
action of this event should be the display of some sort of user
interface indicating to the user that a new version is available
and that they can activate it by reloading the page.</p>

<p>Set the <a href=#concept-appcache-status title=concept-appcache-status>status</a> of
<var title="">cache group</var> to <i>idle</i>.</p>
</ol><p>The <dfn id=cache-failure-steps>cache failure steps</dfn> are as follows:</p>

<ol><li><p><a href=#fire-a-simple-event>Fire a simple event</a> called <code title=event-error><a href=#event-error>error</a></code> at the
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#top-level-browsing-context>top-level
browsing context</a> that is associated with a cache in <var title="">cache group</var>. The default action of this event should
be the display of some sort of user interface indicating to the
user that the user agent failed to save the application for offline
use.</li>
<code><a href=#applicationcache>ApplicationCache</a></code> singleton of each <a href=#browsing-context>browsing
context</a> whose <a href=#active-document>active document</a> is associated
with a cache in <var title="">cache group</var>. The default action
of this event should be the display of some sort of user interface
indicating to the user that the user agent failed to save the
application for offline use.</li>

<li><p>If this is a <a href=#concept-appcache-cache title=concept-appcache-cache>cache
attempt</a>, then discard <var title="">cache</var> and abort
following list:</p>

<dl class=switch><dt>If the resource is not being loaded as part of navigation of a
<a href=#top-level-browsing-context>top-level browsing context</a></dt>
<a href=#browsing-context>browsing context</a></dt>

<dd>

<p>As an optimization, if the resource was loaded from an
<a href=#application-cache>application cache</a>, and the manifest URL of that cache
doesn't match the manifest URL with which the algorithm was
invoked, then the user agent should mark the entry in that
application cache corresponding to the resource that was just
loaded as being <a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>.</p>

<p>Other than that, nothing special happens with respect to
application caches.</p>

<p>Do nothing.</p>
</dd>

<!-- otherwise, we're talking top-level browsing contexts only: -->

<!-- otherwise, we're talking browsing contexts only: -->

<dt>If the resource being loaded was loaded from an application
cache and the URL of that application cache's manifest is the

</dl><p>When the <dfn id=concept-appcache-init-no-attribute title=concept-appcache-init-no-attribute>application cache
selection algorithm</dfn> is invoked <em>without</em> a manifest,
then: if the resource is being loaded as part of navigation of a
<a href=#top-level-browsing-context>top-level browsing context</a>, and the resource was
fetched from a particular <a href=#application-cache>application cache</a>, then the
user agent must associate the <code>Document</code> with that
application cache and invoke the <a href=#application-cache-update-process>application cache update
process</a> for that cache; otherwise, nothing special happens
with respect to application caches.</p>
then the user agent must run the first applicable set of steps from
the following list:</p>

<dl><dt>If the resource is being loaded as part of navigation of a
<a href=#browsing-context>browsing context</a>, and the resource was fetched from a
particular <a href=#application-cache>application cache</a></dt>

<dd>

<p>The user agent must associate the <code>Document</code> with
that application cache and invoke the <a href=#application-cache-update-process>application cache
update process</a> for that cache.

</dd>

<dt>If the resource is being loaded as part of navigation of a
<a href=#child-browsing-context>child browsing context</a></dt>

<dd>

<!-- e.g. iframes to online whitelisted resources -->

<p>The user agent must associate the <code>Document</code> with
that application cache associated with the <a href=#active-document>active
document</a> of the <a href=#parent-browsing-context>parent browsing context</a>.</p>

</dd>

<dt>Otherwise</dt>

<dd>

<p>Nothing special happens with respect to application caches.</p>

</dd>

<h5 id=changesToNetworkingModel><span class=secno>5.7.5.1 </span>Changes to the networking model</h5>
</dl><h5 id=changesToNetworkingModel><span class=secno>5.7.5.1 </span>Changes to the networking model</h5>

<p>When a browsing context is associated with an <a href=#application-cache>application
cache</a>, any and all resource loads must go through the
following steps instead of immediately invoking the mechanisms
appropriate to that resource's scheme:</p>
<p>When a <a href=#browsing-context>browsing context</a> is associated with an
<a href=#application-cache>application cache</a>, any and all resource loads must go
through the following steps instead of immediately invoking the
mechanisms appropriate to that resource's scheme:</p>

<ol><li><p>If the resource is not to be fetched using the HTTP GET
mechanism or equivalent, then <a href=#fetch>fetch</a> the resource
<li>

<p>If the new resource is to be fetched using HTTP GET or
equivalent, and if the browsing context being navigated is a
<a href=#top-level-browsing-context>top-level browsing context</a>, then check if there are
any <a href=#application-cache title="application cache">application caches</a> that
have a <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a>
with the <a href=#same-origin>same origin</a> as the URL in question, and that
have this URL as one of their entries (excluding entries marked as
<a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>), and that
equivalent, then check if there are any <a href=#application-cache title="application
cache">application caches</a> that have a <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a> with the
<a href=#same-origin>same origin</a> as the URL in question, and that have
this URL as one of their entries, excluding entries marked as
<a href=#concept-appcache-foreign title=concept-appcache-foreign>foreign</a>, and that
already contain their manifest, categorized as a <a href=#concept-appcache-manifest title=concept-appcache-manifest>manifest</a>. If so, then the
user agent must then get the resource from the <a href=#concept-appcache-selection title=concept-appcache-selection>most appropriate application
cache</a> of those that match.</p>
and its URL <a href=#concept-appcache-matches-fallback title=concept-appcache-matches-fallback>matches the fallback
namespace</a> of one or more application caches, and the user
didn't cancel the navigation attempt during the previous step, and
the browsing context being navigated is a <a href=#top-level-browsing-context>top-level browsing
context</a>, and the navigation attempt failed (e.g. the server
returned a 4xx or 5xx status code or equivalent, or there was a
DNS error), then:</p> <!-- note that a redirect can never reach
this point as it is handled earlier, meaning that a captive portal
captures URLs in fallback namespaces and you can't ever get to the
fallback file of a resource if you have a captive portal -->
the navigation attempt failed (e.g. the server returned a 4xx or
5xx status code or equivalent, or there was a DNS error),
then:</p> <!-- note that a redirect can never reach this point as
it is handled earlier, meaning that a captive portal captures URLs
in fallback namespaces and you can't ever get to the fallback file
of a resource if you have a captive portal -->

<p>Let <var title="">candidate</var> be the <a href=#concept-appcache-fallback title=concept-appcache-fallback>fallback resource</a>
specified for the <a href=#concept-appcache-fallback-ns title=concept-appcache-fallback-ns>fallback namespace</a> in

0 comments on commit 2f54561

Please sign in to comment.
You can’t perform that action at this time.