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