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 xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changingManifest.sjs">
2 <head>
3 <title>changing manifest test</title>
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
9 <script type="text/javascript">
11 var gGotChecking = false;
12 var gGotDownloading = false;
14 var g1SecUrl = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changing1Sec.sjs";
15 var g1HourUrl = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changing1Hour.sjs";
17 var gCacheContents = null;
19 function finish()
20 {
21 OfflineTest.teardownAndFinish();
22 }
24 function manifestUpdatedAgain()
25 {
26 OfflineTest.ok(gGotChecking, "Should get a checking event on the second update");
27 OfflineTest.ok(gGotDownloading, "Should get a downloading event on the second update");
29 // The second manifest has no NETWORK entry, but we are still
30 // associated with the first version of the manifest, so we should
31 // be able to access the whitelisted entry.
32 try {
33 var xhr = new XMLHttpRequest();
34 xhr.open("GET", "onwhitelist.html", false);
35 xhr.send();
36 OfflineTest.ok(true, "Fetched from the initial cache's whitelist.");
37 } catch (e) {
38 OfflineTest.ok(false, "Failed to fetch from the initial cache's whitelist.");
39 }
41 // Get the initial contents of the first two files.
42 fetcher = new OfflineCacheContents([g1SecUrl, g1HourUrl]);
43 fetcher.fetch(function(contents) {
44 // Make sure the contents of the 1-second-expiration file have changed,
45 // but that the 1-hour-expiration has not.
46 OfflineTest.isnot(gCacheContents[g1SecUrl], contents[g1SecUrl], "1-second expiration should have changed");
47 OfflineTest.is(gCacheContents[g1HourUrl], contents[g1HourUrl], "1-hour expiration should not have changed");
49 finish();
50 });
51 }
53 function failAndFinish(e) {
54 OfflineTest.ok(false, "Unexpected event: " + e.type);
55 finish();
56 }
58 function manifestUpdated()
59 {
60 OfflineTest.ok(gGotChecking, "Should get a checking event");
61 OfflineTest.ok(gGotDownloading, "Should get a downloading event");
63 // Replace this manifest with a new one.
64 OfflineTest.setSJSState("changingManifest.sjs", "2");
66 // Get the initial contents of the first two files.
67 fetcher = new OfflineCacheContents([g1SecUrl, g1HourUrl]);
68 fetcher.fetch(function(contents) {
69 gCacheContents = contents;
71 // Now make sure applicationCache.update() does what we expect.
72 applicationCache.onchecking = function() {
73 OfflineTest.is(applicationCache.status, applicationCache.CHECKING,
74 "CHECKING state during update");
75 gGotChecking = true;
76 };
77 applicationCache.ondownloading = function() {
78 OfflineTest.is(applicationCache.status, applicationCache.DOWNLOADING,
79 "DOWNLOADING state during update");
80 gGotDownloading = true;
81 };
83 applicationCache.onupdateready = OfflineTest.priv(manifestUpdatedAgain);
84 applicationCache.onnoupdate = failAndFinish;
85 applicationCache.oncached = failAndFinish;
87 gGotChecking = false;
88 gGotDownloading = false;
90 // The changing versions give out a new version each second,
91 // make sure it has time to grab a new version, and for the
92 // 1-second cache timeout to pass.
93 window.setTimeout("applicationCache.update()", 5000);
94 });
95 }
97 if (OfflineTest.setup()) {
98 applicationCache.onerror = failAndFinish;
99 applicationCache.onnoupdate = failAndFinish;
101 applicationCache.onchecking = function() { gGotChecking = true; };
102 applicationCache.ondownloading = function() { gGotDownloading = true; };
103 applicationCache.oncached = OfflineTest.priv(manifestUpdated);
104 }
106 SimpleTest.waitForExplicitFinish();
108 </script>
110 </head>
112 <body>
114 </body>
115 </html>