[not part of build] Added debug harness, explicit doom.

This commit is contained in:
beard%netscape.com 2001-03-03 03:42:10 +00:00
Родитель 05aac4c419
Коммит dc318fa7c8
1 изменённых файлов: 44 добавлений и 23 удалений

Просмотреть файл

@ -1,3 +1,5 @@
var DEBUG = false;
var clientID = "javascript";
var key = "theme:button";
var nsICache = Components.interfaces.nsICache;
@ -38,32 +40,51 @@ function wrapInputStream(input)
return wrapper;
}
var outputEntry = openCacheEntry(nsICache.ACCESS_WRITE);
var output = outputEntry.transport.openOutputStream(0, -1, 0);
if (output.write("foo", 3) == 3)
print("disk cache write works!");
else
print("disk cache write broken!");
function test()
{
var outputEntry = openCacheEntry(nsICache.ACCESS_WRITE);
var output = outputEntry.transport.openOutputStream(0, -1, 0);
if (output.write("foo", 3) == 3)
print("disk cache write works!");
else
print("disk cache write broken!");
// store some metadata.
outputEntry.setMetaDataElement("size", "3");
// store some metadata.
outputEntry.setMetaDataElement("size", "3");
output.close();
outputEntry.markValid();
outputEntry.close();
output.close();
outputEntry.markValid();
outputEntry.close();
var inputEntry = openCacheEntry(nsICache.ACCESS_READ);
var input = wrapInputStream(inputEntry.transport.openInputStream(0, -1, 0));
var inputEntry = openCacheEntry(nsICache.ACCESS_READ);
var input = wrapInputStream(inputEntry.transport.openInputStream(0, -1, 0));
if (input.read(input.available()) == "foo")
print("disk cache read works!");
else
print("disk cache read broken!");
if (input.read(input.available()) == "foo")
print("disk cache read works!");
else
print("disk cache read broken!");
if (inputEntry.getMetaDataElement("size") == "3")
print("disk cache metadata works!");
else
print("disk cache metadata broken!");
if (inputEntry.getMetaDataElement("size") == "3")
print("disk cache metadata works!");
else
print("disk cache metadata broken!");
input.close();
inputEntry.close();
input.close();
inputEntry.close();
}
function doom()
{
var doomedEntry = openCacheEntry(nsICache.ACCESS_READ_WRITE);
doomedEntry.doom();
doomedEntry.close();
}
if (DEBUG) {
getCacheService();
print("cache service loaded.");
} else {
print("running disk cache test.");
test();
print("disk cache test complete.");
}