Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | <html manifest="obsoletingManifest.sjs"> |
michael@0 | 2 | <head> |
michael@0 | 3 | <title>obsolete test</title> |
michael@0 | 4 | <script type="text/javascript"> |
michael@0 | 5 | |
michael@0 | 6 | function obsolete(evt) |
michael@0 | 7 | { |
michael@0 | 8 | window.opener.ok(true, "Got an 'obsolete' event"); |
michael@0 | 9 | |
michael@0 | 10 | // The cache status is switched immediately AFTER sending the event, |
michael@0 | 11 | // make sure that it isn't OBSOLETE yet... |
michael@0 | 12 | window.opener.isnot(applicationCache.status, 5, |
michael@0 | 13 | "Status should not yet be 5 (obsolete)"); |
michael@0 | 14 | |
michael@0 | 15 | // But check that it is after the event is fired. |
michael@0 | 16 | setTimeout(function(){ |
michael@0 | 17 | window.opener.is(applicationCache.status, 5, |
michael@0 | 18 | "Status should be 5 (obsolete)"); |
michael@0 | 19 | |
michael@0 | 20 | // Now swapCache(), and our new status should be UNCACHED. |
michael@0 | 21 | applicationCache.swapCache(); |
michael@0 | 22 | window.opener.is(applicationCache.status, 0, |
michael@0 | 23 | "Status should be 0 (UNCACHED)"); |
michael@0 | 24 | window.opener.finish(); |
michael@0 | 25 | }, 0); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function fail(evt) |
michael@0 | 29 | { |
michael@0 | 30 | window.opener.ok(false, "Got an unexpected event: " + evt.type) |
michael@0 | 31 | window.opener.finish(); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | applicationCache.oncached = function() { |
michael@0 | 35 | // ok, we've successfully loaded from the initial cache. |
michael@0 | 36 | try { |
michael@0 | 37 | applicationCache.swapCache(); |
michael@0 | 38 | window.opener.todo(false, "We shouldn't have to swapCache in the oncached handler (bug 443023)"); |
michael@0 | 39 | } catch(e) { |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | // Now delete the manifest and refresh, we should get an "obsolete" message. |
michael@0 | 43 | applicationCache.oncached = fail; |
michael@0 | 44 | applicationCache.onupdateready = fail; |
michael@0 | 45 | applicationCache.onnoupdate = fail; |
michael@0 | 46 | applicationCache.onerror = fail; |
michael@0 | 47 | applicationCache.onobsolete = obsolete; |
michael@0 | 48 | |
michael@0 | 49 | // Make the obsoleting.sjs return 404 NOT FOUND code |
michael@0 | 50 | var req = new XMLHttpRequest(); |
michael@0 | 51 | req.open("GET", "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/obsoletingManifest.sjs?state="); |
michael@0 | 52 | var channel = SpecialPowers.wrap(req).channel |
michael@0 | 53 | .QueryInterface(SpecialPowers.Ci.nsIApplicationCacheChannel); |
michael@0 | 54 | channel.chooseApplicationCache = false; |
michael@0 | 55 | channel.inheritApplicationCache = false; |
michael@0 | 56 | req.send(""); |
michael@0 | 57 | req.onreadystatechange = function() { |
michael@0 | 58 | if (req.readyState == 4) { |
michael@0 | 59 | applicationCache.update(); |
michael@0 | 60 | } |
michael@0 | 61 | } |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | </script> |
michael@0 | 65 | </head> |
michael@0 | 66 | |
michael@0 | 67 | <body> |
michael@0 | 68 | <h1></h1> |
michael@0 | 69 | </body> </html> |