1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/ajax/offline/obsolete.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +<html manifest="obsoletingManifest.sjs"> 1.5 +<head> 1.6 +<title>obsolete test</title> 1.7 +<script type="text/javascript"> 1.8 + 1.9 +function obsolete(evt) 1.10 +{ 1.11 + window.opener.ok(true, "Got an 'obsolete' event"); 1.12 + 1.13 + // The cache status is switched immediately AFTER sending the event, 1.14 + // make sure that it isn't OBSOLETE yet... 1.15 + window.opener.isnot(applicationCache.status, 5, 1.16 + "Status should not yet be 5 (obsolete)"); 1.17 + 1.18 + // But check that it is after the event is fired. 1.19 + setTimeout(function(){ 1.20 + window.opener.is(applicationCache.status, 5, 1.21 + "Status should be 5 (obsolete)"); 1.22 + 1.23 + // Now swapCache(), and our new status should be UNCACHED. 1.24 + applicationCache.swapCache(); 1.25 + window.opener.is(applicationCache.status, 0, 1.26 + "Status should be 0 (UNCACHED)"); 1.27 + window.opener.finish(); 1.28 + }, 0); 1.29 +} 1.30 + 1.31 +function fail(evt) 1.32 +{ 1.33 + window.opener.ok(false, "Got an unexpected event: " + evt.type) 1.34 + window.opener.finish(); 1.35 +} 1.36 + 1.37 +applicationCache.oncached = function() { 1.38 + // ok, we've successfully loaded from the initial cache. 1.39 + try { 1.40 + applicationCache.swapCache(); 1.41 + window.opener.todo(false, "We shouldn't have to swapCache in the oncached handler (bug 443023)"); 1.42 + } catch(e) { 1.43 + } 1.44 + 1.45 + // Now delete the manifest and refresh, we should get an "obsolete" message. 1.46 + applicationCache.oncached = fail; 1.47 + applicationCache.onupdateready = fail; 1.48 + applicationCache.onnoupdate = fail; 1.49 + applicationCache.onerror = fail; 1.50 + applicationCache.onobsolete = obsolete; 1.51 + 1.52 + // Make the obsoleting.sjs return 404 NOT FOUND code 1.53 + var req = new XMLHttpRequest(); 1.54 + req.open("GET", "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/obsoletingManifest.sjs?state="); 1.55 + var channel = SpecialPowers.wrap(req).channel 1.56 + .QueryInterface(SpecialPowers.Ci.nsIApplicationCacheChannel); 1.57 + channel.chooseApplicationCache = false; 1.58 + channel.inheritApplicationCache = false; 1.59 + req.send(""); 1.60 + req.onreadystatechange = function() { 1.61 + if (req.readyState == 4) { 1.62 + applicationCache.update(); 1.63 + } 1.64 + } 1.65 +} 1.66 + 1.67 +</script> 1.68 +</head> 1.69 + 1.70 +<body> 1.71 +<h1></h1> 1.72 +</body> </html>