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/simpleManifest.cacheManifest">
2 <head>
3 <title>simple 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 ok(applicationCache.mozItems.length == 0,
15 "applicationCache.mozItems should be available and empty before associating with a cache.");
17 function addFinished()
18 {
19 OfflineTest.ok(applicationCache.mozLength == 1, "applicationCache should have one dynamic entry (deprecated API)");
20 OfflineTest.ok(applicationCache.mozItem(0) == "http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
21 "applicationCache's dynamic entry should be the one we expect (deprecated API)");
23 OfflineTest.ok(applicationCache.mozItems.length == 1, "applicationCache should have one dynamic entry");
24 OfflineTest.ok(applicationCache.mozItems[0] == "http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
25 "applicationCache's dynamic entry should be the one we expect");
27 OfflineTest.ok(applicationCache.mozHasItem("http://mochi.test:8888/tests/SimpleTest/EventUtils.js"),
28 "applicationCache.mozHasItem() should see the dynamic entry");
30 // Check that the entry was added successfully
31 OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
32 true,
33 removeItem);
34 }
36 function removeItem()
37 {
38 // Now test that removes work
39 applicationCache.mozRemove("http://mochi.test:8888/tests/SimpleTest/EventUtils.js");
41 OfflineTest.ok(applicationCache.mozLength == 0,
42 "applicationCache should have no dynamic entries (deprecated API)");
43 OfflineTest.ok(applicationCache.mozItems.length == 0,
44 "applicationCache should have no dynamic entries");
45 OfflineTest.ok(!applicationCache.mozHasItem("http://mochi.test:8888/tests/SimpleTest/EventUtils.js"),
46 "applicationCache.mozHasItem() should not see the removed dynamic entry");
48 OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
49 false,
50 function() {
51 // We're done
52 OfflineTest.teardownAndFinish();
53 });
54 }
56 function manifestUpdated()
57 {
58 OfflineTest.ok(gGotChecking, "Should get a checking event");
59 OfflineTest.ok(gGotDownloading, "Should get a downloading event");
61 OfflineTest.is(applicationCache.status, 1, "Cache status should be 1 (CACHED)");
63 var entries = [
64 // The manifest itself should be in the cache
65 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
67 // The document that requested the manifest should be in the cache
68 [window.location.href, true],
70 // The entries from the manifest should be in the cache
71 ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
72 ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
74 // The bad entries from the manifest should not be in the cache
75 ["bad:/uri/invalid", false]
76 ];
77 OfflineTest.checkCacheEntries(
78 entries,
79 function() {
80 try {
81 applicationCache.swapCache();
82 OfflineTest.ok(false, "application.swapCache() should fail after initial update.");
83 } catch(ex) {
84 OfflineTest.ok(true, "application.swapCache() should fail after initial update.");
85 }
87 // XXX: make sure that the previous version went away after the swapCache().
89 // Now add a file using the applicationCache API
90 applicationCache.mozAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js");
92 // Wait for the add() to be downloaded
93 OfflineTest.waitForAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
94 OfflineTest.priv(addFinished));
95 });
96 }
98 if (OfflineTest.setup()) {
99 OfflineTest.ok(applicationCache instanceof EventTarget,
100 "applicationCache should be an event target");
102 applicationCache.onerror = OfflineTest.failEvent;
104 applicationCache.addEventListener("checking", function() {
105 // We should get the "checking" event during an initial update,
106 // but until we are associated it will not affect applicationCache.status
107 OfflineTest.is(applicationCache.status, applicationCache.UNCACHED,
108 "CHECKING state during initial update");
109 gGotChecking = true;
110 }, true);
111 applicationCache.ondownloading = function() {
112 // We should get the "downloading" event during an initial update,
113 // but until we are associated it will not affect applicationCache.status
114 OfflineTest.is(applicationCache.status, applicationCache.UNCACHED,
115 "DOWNLOADING state during initial update")
116 gGotDownloading = true; };
117 applicationCache.oncached = OfflineTest.priv(manifestUpdated);
118 }
120 SimpleTest.waitForExplicitFinish();
122 </script>
124 </head>
126 <body>
128 </body>
129 </html>