diff options
Diffstat (limited to 'dom/tests/mochitest/ajax/offline/obsolete.html')
-rw-r--r-- | dom/tests/mochitest/ajax/offline/obsolete.html | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/tests/mochitest/ajax/offline/obsolete.html b/dom/tests/mochitest/ajax/offline/obsolete.html new file mode 100644 index 000000000..5f0106d3a --- /dev/null +++ b/dom/tests/mochitest/ajax/offline/obsolete.html @@ -0,0 +1,69 @@ +<html manifest="obsoletingManifest.sjs"> +<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.onnoupdate = fail; + applicationCache.onerror = fail; + applicationCache.onobsolete = obsolete; + + // Make the obsoleting.sjs return 404 NOT FOUND code + var req = new XMLHttpRequest(); + req.open("GET", "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/obsoletingManifest.sjs?state="); + var channel = SpecialPowers.wrap(req).channel + .QueryInterface(SpecialPowers.Ci.nsIApplicationCacheChannel); + channel.chooseApplicationCache = false; + channel.inheritApplicationCache = false; + req.send(""); + req.onreadystatechange = function() { + if (req.readyState == 4) { + applicationCache.update(); + } + } +} + +</script> +</head> + +<body> +<h1></h1> +</body> </html> |