[not part of build] Tests disk cache using XPConnnect.

This commit is contained in:
beard%netscape.com 2001-02-28 05:06:25 +00:00
parent ff21b4221a
commit bc439b5703

View File

@ -0,0 +1,38 @@
function getCacheService()
{
var nsCacheService = Components.classes["@mozilla.org/network/cache-service;1"];
var service = nsCacheService.getService(Components.interfaces.nsICacheService);
return service;
}
function createCacheSession(clientID, storagePolicy, streamable)
{
var service = getCacheService();
var nsICache = Components.interfaces.nsICache;
var session = service.createSession(clientID, storagePolicy, streamable);
return session;
}
function openCacheEntry()
{
var nsICache = Components.interfaces.nsICache;
var session = createCacheSession("javascript", nsICache.STORE_ON_DISK, true);
var entry = session.openCacheEntry("theme:button", nsICache.ACCESS_READ_WRITE);
return entry;
}
function dumpLeaks()
{
var leakDetector = Components.classes["@mozilla.org/xpcom/leakdetector;1"].getService(Components.interfaces.nsILeakDetector);
leakDetector.dumpLeaks();
}
var entry = openCacheEntry();
var transport = entry.transport;
var output = transport.openOutputStream(0, -1, 0);
if (output.write("foo", 3) == 3)
print("disk cache works!");
else
print("disk cache sucks!");
entry.markValid();
entry.close();