forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestCacheVisitor.js
54 lines (45 loc) · 1.29 KB
/
TestCacheVisitor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var DEBUG = true;
var clientID = "javascript";
var nsICache = Components.interfaces.nsICache;
function getCacheService()
{
var nsCacheService = Components.classes["@mozilla.org/network/cache-service;1"];
var service = nsCacheService.getService(Components.interfaces.nsICacheService);
return service;
}
function CacheVisitor()
{
}
CacheVisitor.prototype = {
QueryInterface : function(iid)
{
if (iid.equals(Components.interfaces.nsICacheVisitor))
return this;
throw Components.results.NS_NOINTERFACE;
},
visitDevice : function(deviceID, deviceInfo)
{
print("[visiting device (deviceID = " + deviceID + ", description = " + deviceInfo.description + ")]");
return true;
},
visitEntry : function(deviceID, entryInfo)
{
print("[visiting entry (clientID = " + entryInfo.clientID + ", key = " + entryInfo.key + ")]");
return true;
}
};
function test()
{
var cacheService = getCacheService();
var visitor = new CacheVisitor();
cacheService.visitEntries(visitor);
}
// load the cache service before doing anything with Java...
getCacheService();
if (DEBUG) {
print("cache service loaded.");
} else {
print("running cache visitor test.");
test();
print("cache visitor test complete.");
}