2010-03-12 13:53:36 -08:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changingManifest.sjs">
|
2008-11-05 16:01:07 -08:00
|
|
|
<head>
|
|
|
|
<title>refetch manifest test</title>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
function finish()
|
|
|
|
{
|
|
|
|
OfflineTest.teardown();
|
|
|
|
OfflineTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
function failAndFinish(e)
|
|
|
|
{
|
|
|
|
OfflineTest.ok(false, "Unexpected event: " + e.type);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
function manifestUpdated()
|
|
|
|
{
|
|
|
|
// Replace this manifest with a new one.
|
|
|
|
|
|
|
|
// XXX: After this put, we will no longer have Cache-Control:
|
|
|
|
// no-cache on the manifest, so future updates will just use the
|
|
|
|
// cached manifest.
|
|
|
|
|
|
|
|
// Get the initial contents of the first two files.
|
|
|
|
fetcher = new OfflineCacheContents([g1SecUrl, g1HourUrl]);
|
|
|
|
fetcher.fetch(function(contents) {
|
|
|
|
gCacheContents = contents;
|
|
|
|
|
|
|
|
// Now make sure applicationCache.update() does what we expect.
|
|
|
|
applicationCache.onupdateready = OfflineTest.priv(manifestUpdatedAgain);
|
|
|
|
applicationCache.onnoupdate = failAndFinish;
|
|
|
|
applicationCache.oncached = failAndFinish;
|
|
|
|
|
|
|
|
gGotChecking = false;
|
|
|
|
gGotDownloading = false;
|
|
|
|
|
|
|
|
// The changing versions give out a new version each second,
|
|
|
|
// make sure it has time to grab a new version, and for the
|
|
|
|
// 1-second cache timeout to pass.
|
|
|
|
window.setTimeout("applicationCache.update()", 5000);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function replaceManifest()
|
|
|
|
{
|
|
|
|
// If we replace the manifest after a downloading event, the update
|
|
|
|
// should fail when it revalidates the manifest at the end of the update.
|
2009-02-18 05:31:30 -08:00
|
|
|
OfflineTest.setSJSState("changingManifest.sjs", "2");
|
2008-11-05 16:01:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function cached()
|
|
|
|
{
|
|
|
|
OfflineTest.ok(true, "Got the expected cached event.");
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
function gotError()
|
|
|
|
{
|
|
|
|
OfflineTest.ok(true, "Got the expected error event.");
|
|
|
|
|
|
|
|
// Now this update will be rescheduled, and it should succeed.
|
|
|
|
applicationCache.onerror = failAndFinish;
|
|
|
|
applicationCache.oncached = cached;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OfflineTest.setup()) {
|
|
|
|
applicationCache.onerror = gotError;
|
|
|
|
applicationCache.onnoupdate = failAndFinish;
|
|
|
|
|
|
|
|
applicationCache.ondownloading = replaceManifest;
|
|
|
|
applicationCache.oncached = failAndFinish;
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|