gecko/dom/tests/mochitest/ajax/offline/obsolete.html

63 lines
1.6 KiB
HTML

<html manifest="obsolete.cacheManifest">
<head>
<title>obsolete test</title>
<script type="text/javascript">
function obsolete(evt)
{
window.opener.ok(true, "Got an 'obsolete' event");
// The cache status is switched immediately AFTER sending the event,
// make sure that it isn't OBSOLETE yet...
window.opener.isnot(applicationCache.status, 5,
"Status should not yet be 5 (obsolete)");
// But check that it is after the event is fired.
setTimeout(function(){
window.opener.is(applicationCache.status, 5,
"Status should be 5 (obsolete)");
// Now swapCache(), and our new status should be UNCACHED.
applicationCache.swapCache();
window.opener.is(applicationCache.status, 0,
"Status should be 0 (UNCACHED)");
window.opener.finish();
}, 0);
}
function fail(evt)
{
window.opener.ok(false, "Got an unexpected event: " + evt.type)
window.opener.finish();
}
applicationCache.oncached = function() {
// ok, we've successfully loaded from the initial cache.
try {
applicationCache.swapCache();
window.opener.todo(false, "We shouldn't have to swapCache in the oncached handler (bug 443023)");
} catch(e) {
}
// Now delete the manifest and refresh, we should get an "obsolete" message.
applicationCache.oncached = fail;
applicationCache.onupdateready = fail;
applicationCache.onobsolete = obsolete;
var req = new XMLHttpRequest();
req.open("DELETE", "obsolete.cacheManifest");
req.send("");
req.onreadystatechange = function() {
if (req.readyState == 4) {
applicationCache.update();
}
}
}
</script>
</head>
<body>
<h1></h1>
</body> </html>