1 function getCacheService()
3 var nsCacheService = Components.classes["@mozilla.org/network/cache-service;1"];
4 var service = nsCacheService.getService(Components.interfaces.nsICacheService);
8 function createCacheSession(clientID, storagePolicy, streamable)
10 var service = getCacheService();
11 var nsICache = Components.interfaces.nsICache;
12 var session = service.createSession(clientID, storagePolicy, streamable);
16 function openCacheEntry(clientID, url)
18 var nsICache = Components.interfaces.nsICache;
19 var session = createCacheSession(clientID, nsICache.STORE_ANYWHERE, false);
20 var entry = session.openCacheEntry(url, nsICache.ACCESS_READ_WRITE);
24 function wrapString(str)
26 var nsISupportsCString = Components.interfaces.nsISupportsCString;
27 var factory = Components.classes["@mozilla.org/supports-cstring;1"];
28 var wrapper = factory.createInstance(nsISupportsCString);
35 var data = wrapString("javascript");
36 var entry = openCacheEntry("javascript", "theme:button");
37 entry.cacheElement = data;
41 var newEntry = openCacheEntry("javascript", "theme:button");
42 if (newEntry.cacheElement === data)
43 print("object cache works.");
45 print("object cache failed.");