3 var leakDetector = Components.classes["@mozilla.org/xpcom/leakdetector;1"].getService(Components.interfaces.nsILeakDetector);
4 leakDetector.dumpLeaks();
7 function getCacheService()
9 var nsCacheService = Components.classes["@mozilla.org/network/cache-service;1"];
10 var service = nsCacheService.getService(Components.interfaces.nsICacheService);
14 function createCacheSession(clientID, storagePolicy, streamable)
16 var service = getCacheService();
17 var nsICache = Components.interfaces.nsICache;
18 var session = service.createSession(clientID, storagePolicy, streamable);
22 function openCacheEntry(clientID, url)
24 var nsICache = Components.interfaces.nsICache;
25 var session = createCacheSession(clientID, nsICache.STORE_ANYWHERE, false);
26 var entry = session.openCacheEntry(url, nsICache.ACCESS_READ_WRITE);
30 function wrapString(str)
32 var nsISupportsCString = Components.interfaces.nsISupportsCString;
33 var factory = Components.classes["@mozilla.org/supports-cstring;1"];
34 var wrapper = factory.createInstance(nsISupportsCString);
41 var data = wrapString("javascript");
42 var entry = openCacheEntry("javascript", "theme:button");
43 entry.cacheElement = data;
47 var newEntry = openCacheEntry("javascript", "theme:button");
48 if (newEntry.cacheElement === data)
49 print("object cache works.");
51 print("object cache failed.");