On x86 compilers without fastcall, simulate it when invoking traces and un-simulate...
[wine-gecko.git] / netwerk / test / TestObjectCache.js
blob4e5a7100cc62d55d9f3415f75f61775de061c601
1 function dumpLeaks()
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);
11     return service;
14 function createCacheSession(clientID, storagePolicy, streamable)
16     var service = getCacheService();
17     var nsICache = Components.interfaces.nsICache;
18     var session = service.createSession(clientID, storagePolicy, streamable);
19     return session;
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);
27     return entry;
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);
35     wrapper.data = str;
36     return wrapper;
39 function test()
41     var data = wrapString("javascript");
42     var entry = openCacheEntry("javascript", "theme:button");
43     entry.cacheElement = data;
44     entry.markValid();
45     entry.close();
47     var newEntry = openCacheEntry("javascript", "theme:button");
48     if (newEntry.cacheElement === data)
49         print("object cache works.");
50     else
51         print("object cache failed.");
54 test();