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 var DEBUG = true;
3 var clientID = "javascript";
4 var nsICache = Components.interfaces.nsICache;
6 function getCacheService()
7 {
8 var nsCacheService = Components.classes["@mozilla.org/network/cache-service;1"];
9 var service = nsCacheService.getService(Components.interfaces.nsICacheService);
10 return service;
11 }
13 function CacheVisitor()
14 {
15 }
17 CacheVisitor.prototype = {
18 QueryInterface : function(iid)
19 {
20 if (iid.equals(Components.interfaces.nsICacheVisitor))
21 return this;
22 throw Components.results.NS_NOINTERFACE;
23 },
25 visitDevice : function(deviceID, deviceInfo)
26 {
27 print("[visiting device (deviceID = " + deviceID + ", description = " + deviceInfo.description + ")]");
28 return true;
29 },
31 visitEntry : function(deviceID, entryInfo)
32 {
33 print("[visiting entry (clientID = " + entryInfo.clientID + ", key = " + entryInfo.key + ")]");
34 return true;
35 }
36 };
38 function test()
39 {
40 var cacheService = getCacheService();
41 var visitor = new CacheVisitor();
42 cacheService.visitEntries(visitor);
43 }
45 // load the cache service before doing anything with Java...
46 getCacheService();
48 if (DEBUG) {
49 print("cache service loaded.");
50 } else {
51 print("running cache visitor test.");
52 test();
53 print("cache visitor test complete.");
54 }