2020-04-07 19:00:03 +03:00
|
|
|
/* import-globals-from head_cache.js */
|
|
|
|
/* import-globals-from head_channels.js */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var callbacks = [];
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
// Expect an existing entry
|
|
|
|
const NORMAL = 0;
|
|
|
|
// Expect a new entry
|
|
|
|
const NEW = 1 << 0;
|
|
|
|
// Return early from onCacheEntryCheck and set the callback to state it expects onCacheEntryCheck to happen
|
|
|
|
const NOTVALID = 1 << 1;
|
|
|
|
// Throw from onCacheEntryAvailable
|
|
|
|
const THROWAVAIL = 1 << 2;
|
|
|
|
// Open entry for reading-only
|
|
|
|
const READONLY = 1 << 3;
|
|
|
|
// Expect the entry to not be found
|
|
|
|
const NOTFOUND = 1 << 4;
|
|
|
|
// Return ENTRY_NEEDS_REVALIDATION from onCacheEntryCheck
|
|
|
|
const REVAL = 1 << 5;
|
|
|
|
// Return ENTRY_PARTIAL from onCacheEntryCheck, in combo with NEW or RECREATE bypasses check for emptiness of the entry
|
|
|
|
const PARTIAL = 1 << 6;
|
|
|
|
// Expect the entry is doomed, i.e. the output stream should not be possible to open
|
|
|
|
const DOOMED = 1 << 7;
|
|
|
|
// Don't trigger the go-on callback until the entry is written
|
|
|
|
const WAITFORWRITE = 1 << 8;
|
|
|
|
// Don't write data (i.e. don't open output stream)
|
|
|
|
const METAONLY = 1 << 9;
|
|
|
|
// Do recreation of an existing cache entry
|
|
|
|
const RECREATE = 1 << 10;
|
|
|
|
// Do not give me the entry
|
|
|
|
const NOTWANTED = 1 << 11;
|
2013-11-21 02:20:17 +04:00
|
|
|
// Tell the cache to wait for the entry to be completely written first
|
|
|
|
const COMPLETE = 1 << 12;
|
2014-05-15 01:12:38 +04:00
|
|
|
// Don't write meta/data and don't set valid in the callback, consumer will do it manually
|
|
|
|
const DONTFILL = 1 << 13;
|
2014-07-07 22:58:26 +04:00
|
|
|
// Used in combination with METAONLY, don't call setValid() on the entry after metadata has been set
|
|
|
|
const DONTSETVALID = 1 << 14;
|
2014-11-19 20:46:09 +03:00
|
|
|
// Notify before checking the data, useful for proper callback ordering checks
|
|
|
|
const NOTIFYBEFOREREAD = 1 << 15;
|
2015-10-22 13:11:00 +03:00
|
|
|
// It's allowed to not get an existing entry (result of opening is undetermined)
|
|
|
|
const MAYBE_NEW = 1 << 16;
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
var log_c2 = true;
|
|
|
|
function LOG_C2(o, m) {
|
|
|
|
if (!log_c2) {
|
|
|
|
return;
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
if (!m) {
|
|
|
|
dump("TEST-INFO | CACHE2: " + o + "\n");
|
|
|
|
} else {
|
2014-05-18 22:03:57 +04:00
|
|
|
dump(
|
|
|
|
"TEST-INFO | CACHE2: callback #" +
|
|
|
|
o.order +
|
|
|
|
"(" +
|
|
|
|
(o.workingData ? o.workingData.substr(0, 10) : "---") +
|
|
|
|
") " +
|
|
|
|
m +
|
|
|
|
"\n"
|
|
|
|
);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function pumpReadStream(inputStream, goon) {
|
|
|
|
if (inputStream.isNonBlocking()) {
|
|
|
|
// non-blocking stream, must read via pump
|
|
|
|
var pump = Cc["@mozilla.org/network/input-stream-pump;1"].createInstance(
|
|
|
|
Ci.nsIInputStreamPump
|
|
|
|
);
|
2017-09-26 08:21:44 +03:00
|
|
|
pump.init(inputStream, 0, 0, true);
|
2013-09-20 13:11:25 +04:00
|
|
|
var data = "";
|
2020-08-05 14:21:51 +03:00
|
|
|
pump.asyncRead({
|
|
|
|
onStartRequest(aRequest) {},
|
|
|
|
onDataAvailable(aRequest, aInputStream, aOffset, aCount) {
|
|
|
|
var wrapper = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
|
|
|
|
Ci.nsIScriptableInputStream
|
|
|
|
);
|
|
|
|
wrapper.init(aInputStream);
|
|
|
|
var str = wrapper.read(wrapper.available());
|
|
|
|
LOG_C2("reading data '" + str.substring(0, 5) + "'");
|
|
|
|
data += str;
|
2013-09-20 13:11:25 +04:00
|
|
|
},
|
2020-08-05 14:21:51 +03:00
|
|
|
onStopRequest(aRequest, aStatusCode) {
|
|
|
|
LOG_C2("done reading data: " + aStatusCode);
|
|
|
|
Assert.equal(aStatusCode, Cr.NS_OK);
|
|
|
|
goon(data);
|
|
|
|
},
|
|
|
|
});
|
2013-09-20 13:11:25 +04:00
|
|
|
} else {
|
|
|
|
// blocking stream
|
|
|
|
var data = read_stream(inputStream, inputStream.available());
|
|
|
|
goon(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenCallback.prototype = {
|
2019-06-21 23:13:40 +03:00
|
|
|
QueryInterface: ChromeUtils.generateQI(["nsICacheEntryOpenCallback"]),
|
|
|
|
onCacheEntryCheck(entry, appCache) {
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(this, "onCacheEntryCheck");
|
|
|
|
Assert.ok(!this.onCheckPassed);
|
|
|
|
this.onCheckPassed = true;
|
|
|
|
|
|
|
|
if (this.behavior & NOTVALID) {
|
|
|
|
LOG_C2(this, "onCacheEntryCheck DONE, return ENTRY_WANTED");
|
|
|
|
return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.behavior & NOTWANTED) {
|
|
|
|
LOG_C2(this, "onCacheEntryCheck DONE, return ENTRY_NOT_WANTED");
|
|
|
|
return Ci.nsICacheEntryOpenCallback.ENTRY_NOT_WANTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
Assert.equal(entry.getMetaDataElement("meto"), this.workingMetadata);
|
|
|
|
|
|
|
|
// check for sane flag combination
|
|
|
|
Assert.notEqual(this.behavior & (REVAL | PARTIAL), REVAL | PARTIAL);
|
|
|
|
|
|
|
|
if (this.behavior & (REVAL | PARTIAL)) {
|
2013-11-21 02:20:17 +04:00
|
|
|
LOG_C2(this, "onCacheEntryCheck DONE, return ENTRY_NEEDS_REVALIDATION");
|
2013-09-20 13:11:25 +04:00
|
|
|
return Ci.nsICacheEntryOpenCallback.ENTRY_NEEDS_REVALIDATION;
|
|
|
|
}
|
|
|
|
|
2013-11-21 02:20:17 +04:00
|
|
|
if (this.behavior & COMPLETE) {
|
|
|
|
LOG_C2(
|
|
|
|
this,
|
|
|
|
"onCacheEntryCheck DONE, return RECHECK_AFTER_WRITE_FINISHED"
|
|
|
|
);
|
2017-08-24 11:25:38 +03:00
|
|
|
// Specific to the new backend because of concurrent read/write:
|
|
|
|
// when a consumer returns RECHECK_AFTER_WRITE_FINISHED from onCacheEntryCheck
|
|
|
|
// the cache calls this callback again after the entry write has finished.
|
|
|
|
// This gives the consumer a chance to recheck completeness of the entry
|
|
|
|
// again.
|
|
|
|
// Thus, we reset state as onCheck would have never been called.
|
|
|
|
this.onCheckPassed = false;
|
|
|
|
// Don't return RECHECK_AFTER_WRITE_FINISHED on second call of onCacheEntryCheck.
|
|
|
|
this.behavior &= ~COMPLETE;
|
2013-11-21 02:20:17 +04:00
|
|
|
return Ci.nsICacheEntryOpenCallback.RECHECK_AFTER_WRITE_FINISHED;
|
|
|
|
}
|
|
|
|
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(this, "onCacheEntryCheck DONE, return ENTRY_WANTED");
|
|
|
|
return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
|
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
onCacheEntryAvailable(entry, isnew, appCache, status) {
|
2015-10-22 13:11:00 +03:00
|
|
|
if (this.behavior & MAYBE_NEW && isnew) {
|
|
|
|
this.behavior |= NEW;
|
|
|
|
}
|
|
|
|
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(this, "onCacheEntryAvailable, " + this.behavior);
|
|
|
|
Assert.ok(!this.onAvailPassed);
|
|
|
|
this.onAvailPassed = true;
|
|
|
|
|
|
|
|
Assert.equal(isnew, !!(this.behavior & NEW));
|
|
|
|
|
|
|
|
if (this.behavior & (NOTFOUND | NOTWANTED)) {
|
|
|
|
Assert.equal(status, Cr.NS_ERROR_CACHE_KEY_NOT_FOUND);
|
|
|
|
Assert.ok(!entry);
|
|
|
|
if (this.behavior & THROWAVAIL) {
|
|
|
|
this.throwAndNotify(entry);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
this.goon(entry);
|
|
|
|
} else if (this.behavior & (NEW | RECREATE)) {
|
|
|
|
Assert.ok(!!entry);
|
|
|
|
|
|
|
|
if (this.behavior & RECREATE) {
|
|
|
|
entry = entry.recreate();
|
|
|
|
Assert.ok(!!entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.behavior & THROWAVAIL) {
|
|
|
|
this.throwAndNotify(entry);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
if (!(this.behavior & WAITFORWRITE)) {
|
|
|
|
this.goon(entry);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
if (!(this.behavior & PARTIAL)) {
|
|
|
|
try {
|
|
|
|
entry.getMetaDataElement("meto");
|
|
|
|
Assert.ok(false);
|
|
|
|
} catch (ex) {}
|
|
|
|
}
|
|
|
|
|
2014-05-15 01:12:38 +04:00
|
|
|
if (this.behavior & DONTFILL) {
|
|
|
|
Assert.equal(false, this.behavior & WAITFORWRITE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-20 13:11:25 +04:00
|
|
|
var self = this;
|
|
|
|
executeSoon(function() {
|
|
|
|
// emulate network latency
|
|
|
|
entry.setMetaDataElement("meto", self.workingMetadata);
|
|
|
|
entry.metaDataReady();
|
|
|
|
if (self.behavior & METAONLY) {
|
|
|
|
// Since forcing GC/CC doesn't trigger OnWriterClosed, we have to set the entry valid manually :(
|
2014-07-07 22:58:26 +04:00
|
|
|
if (!(self.behavior & DONTSETVALID)) {
|
|
|
|
entry.setValid();
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2014-07-07 22:58:26 +04:00
|
|
|
|
2013-09-20 13:11:25 +04:00
|
|
|
entry.close();
|
2014-07-07 22:58:26 +04:00
|
|
|
if (self.behavior & WAITFORWRITE) {
|
|
|
|
self.goon(entry);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2014-07-07 22:58:26 +04:00
|
|
|
|
2013-09-20 13:11:25 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
executeSoon(function() {
|
|
|
|
// emulate more network latency
|
|
|
|
if (self.behavior & DOOMED) {
|
2015-10-22 13:11:00 +03:00
|
|
|
LOG_C2(self, "checking doom state");
|
2013-09-20 13:11:25 +04:00
|
|
|
try {
|
2018-04-25 07:01:00 +03:00
|
|
|
var os = entry.openOutputStream(0, -1);
|
2015-10-22 13:11:00 +03:00
|
|
|
// Unfortunately, in the undetermined state we cannot even check whether the entry
|
|
|
|
// is actually doomed or not.
|
|
|
|
os.close();
|
|
|
|
Assert.ok(!!(self.behavior & MAYBE_NEW));
|
2013-09-20 13:11:25 +04:00
|
|
|
} catch (ex) {
|
|
|
|
Assert.ok(true);
|
|
|
|
}
|
|
|
|
if (self.behavior & WAITFORWRITE) {
|
|
|
|
self.goon(entry);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var offset = self.behavior & PARTIAL ? entry.dataSize : 0;
|
|
|
|
LOG_C2(self, "openOutputStream @ " + offset);
|
2018-04-25 07:01:00 +03:00
|
|
|
var os = entry.openOutputStream(offset, -1);
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(self, "writing data");
|
|
|
|
var wrt = os.write(self.workingData, self.workingData.length);
|
|
|
|
Assert.equal(wrt, self.workingData.length);
|
|
|
|
os.close();
|
|
|
|
if (self.behavior & WAITFORWRITE) {
|
|
|
|
self.goon(entry);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
entry.close();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// NORMAL
|
|
|
|
Assert.ok(!!entry);
|
|
|
|
Assert.equal(entry.getMetaDataElement("meto"), this.workingMetadata);
|
|
|
|
if (this.behavior & THROWAVAIL) {
|
|
|
|
this.throwAndNotify(entry);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2014-11-19 20:46:09 +03:00
|
|
|
if (this.behavior & NOTIFYBEFOREREAD) {
|
|
|
|
this.goon(entry, true);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
|
|
|
|
var wrapper = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
|
|
|
|
Ci.nsIScriptableInputStream
|
|
|
|
);
|
|
|
|
var self = this;
|
|
|
|
pumpReadStream(entry.openInputStream(0), function(data) {
|
|
|
|
Assert.equal(data, self.workingData);
|
|
|
|
self.onDataCheckPassed = true;
|
|
|
|
LOG_C2(self, "entry read done");
|
|
|
|
self.goon(entry);
|
|
|
|
entry.close();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
selfCheck() {
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(this, "selfCheck");
|
|
|
|
|
2015-10-22 13:11:00 +03:00
|
|
|
Assert.ok(this.onCheckPassed || this.behavior & MAYBE_NEW);
|
2013-09-20 13:11:25 +04:00
|
|
|
Assert.ok(this.onAvailPassed);
|
2015-10-22 13:11:00 +03:00
|
|
|
Assert.ok(this.onDataCheckPassed || this.behavior & MAYBE_NEW);
|
2013-09-20 13:11:25 +04:00
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
throwAndNotify(entry) {
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(this, "Throwing");
|
|
|
|
var self = this;
|
|
|
|
executeSoon(function() {
|
|
|
|
LOG_C2(self, "Notifying");
|
|
|
|
self.goon(entry);
|
|
|
|
});
|
2020-05-05 20:41:36 +03:00
|
|
|
throw Components.Exception("", Cr.NS_ERROR_FAILURE);
|
2013-09-20 13:11:25 +04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function OpenCallback(behavior, workingMetadata, workingData, goon) {
|
|
|
|
this.behavior = behavior;
|
|
|
|
this.workingMetadata = workingMetadata;
|
|
|
|
this.workingData = workingData;
|
|
|
|
this.goon = goon;
|
|
|
|
this.onCheckPassed =
|
|
|
|
(!!(behavior & (NEW | RECREATE)) || !workingMetadata) &&
|
|
|
|
!(behavior & NOTVALID);
|
|
|
|
this.onAvailPassed = false;
|
|
|
|
this.onDataCheckPassed =
|
|
|
|
!!(behavior & (NEW | RECREATE | NOTWANTED)) || !workingMetadata;
|
|
|
|
callbacks.push(this);
|
|
|
|
this.order = callbacks.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
VisitCallback.prototype = {
|
2019-06-21 23:13:40 +03:00
|
|
|
QueryInterface: ChromeUtils.generateQI(["nsICacheStorageVisitor"]),
|
|
|
|
onCacheStorageInfo(num, consumption) {
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(this, "onCacheStorageInfo: num=" + num + ", size=" + consumption);
|
|
|
|
Assert.equal(this.num, num);
|
2017-08-24 11:25:38 +03:00
|
|
|
Assert.equal(this.consumption, consumption);
|
2013-09-20 13:11:25 +04:00
|
|
|
if (!this.entries) {
|
|
|
|
this.notify();
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
onCacheEntryInfo(
|
|
|
|
aURI,
|
|
|
|
aIdEnhance,
|
|
|
|
aDataSize,
|
|
|
|
aFetchCount,
|
|
|
|
aLastModifiedTime,
|
|
|
|
aExpirationTime,
|
2017-02-03 06:15:00 +03:00
|
|
|
aPinned,
|
|
|
|
aInfo
|
2013-09-20 13:11:25 +04:00
|
|
|
) {
|
2014-05-01 15:28:12 +04:00
|
|
|
var key = (aIdEnhance ? aIdEnhance + ":" : "") + aURI.asciiSpec;
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(this, "onCacheEntryInfo: key=" + key);
|
|
|
|
|
2017-02-03 06:15:00 +03:00
|
|
|
function findCacheIndex(element) {
|
|
|
|
if (typeof element === "string") {
|
|
|
|
return element === key;
|
|
|
|
} else if (typeof element === "object") {
|
|
|
|
return (
|
|
|
|
element.uri === key &&
|
|
|
|
element.lci.isAnonymous === aInfo.isAnonymous &&
|
|
|
|
ChromeUtils.isOriginAttributesEqual(
|
|
|
|
element.lci.originAttributes,
|
|
|
|
aInfo.originAttributes
|
2019-07-05 11:55:23 +03:00
|
|
|
)
|
2017-02-03 06:15:00 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-20 13:11:25 +04:00
|
|
|
Assert.ok(!!this.entries);
|
|
|
|
|
2017-02-03 06:15:00 +03:00
|
|
|
var index = this.entries.findIndex(findCacheIndex);
|
2013-09-20 13:11:25 +04:00
|
|
|
Assert.ok(index > -1);
|
|
|
|
|
|
|
|
this.entries.splice(index, 1);
|
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
onCacheEntryVisitCompleted() {
|
2013-09-20 13:11:25 +04:00
|
|
|
LOG_C2(this, "onCacheEntryVisitCompleted");
|
|
|
|
if (this.entries) {
|
|
|
|
Assert.equal(this.entries.length, 0);
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
this.notify();
|
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
notify() {
|
2013-09-20 13:11:25 +04:00
|
|
|
Assert.ok(!!this.goon);
|
|
|
|
var goon = this.goon;
|
|
|
|
this.goon = null;
|
|
|
|
executeSoon(goon);
|
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
selfCheck() {
|
2013-09-20 13:11:25 +04:00
|
|
|
Assert.ok(!this.entries || !this.entries.length);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function VisitCallback(num, consumption, entries, goon) {
|
|
|
|
this.num = num;
|
|
|
|
this.consumption = consumption;
|
|
|
|
this.entries = entries;
|
|
|
|
this.goon = goon;
|
|
|
|
callbacks.push(this);
|
|
|
|
this.order = callbacks.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
EvictionCallback.prototype = {
|
2019-06-21 23:13:40 +03:00
|
|
|
QueryInterface: ChromeUtils.generateQI(["nsICacheEntryDoomCallback"]),
|
|
|
|
onCacheEntryDoomed(result) {
|
2013-09-20 13:11:25 +04:00
|
|
|
Assert.equal(this.expectedSuccess, result == Cr.NS_OK);
|
|
|
|
this.goon();
|
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
selfCheck() {},
|
2013-09-20 13:11:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
function EvictionCallback(success, goon) {
|
|
|
|
this.expectedSuccess = success;
|
|
|
|
this.goon = goon;
|
|
|
|
callbacks.push(this);
|
|
|
|
this.order = callbacks.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
MultipleCallbacks.prototype = {
|
2019-06-21 23:13:40 +03:00
|
|
|
fired() {
|
2013-09-20 13:11:25 +04:00
|
|
|
if (--this.pending == 0) {
|
|
|
|
var self = this;
|
|
|
|
if (this.delayed) {
|
|
|
|
executeSoon(function() {
|
|
|
|
self.goon();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.goon();
|
2019-07-05 11:55:23 +03:00
|
|
|
}
|
2013-09-20 13:11:25 +04:00
|
|
|
}
|
2015-10-22 13:11:00 +03:00
|
|
|
},
|
2019-06-21 23:13:40 +03:00
|
|
|
add() {
|
2015-10-22 13:11:00 +03:00
|
|
|
++this.pending;
|
2013-09-20 13:11:25 +04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function MultipleCallbacks(number, goon, delayed) {
|
|
|
|
this.pending = number;
|
|
|
|
this.goon = goon;
|
|
|
|
this.delayed = delayed;
|
|
|
|
}
|
|
|
|
|
2016-05-20 09:33:00 +03:00
|
|
|
function wait_for_cache_index(continue_func) {
|
|
|
|
// This callback will not fire before the index is in the ready state. nsICacheStorage.exists() will
|
|
|
|
// no longer throw after this point.
|
|
|
|
get_cache_service().asyncGetDiskConsumption({
|
2019-06-21 23:13:40 +03:00
|
|
|
onNetworkCacheDiskConsumption() {
|
|
|
|
continue_func();
|
|
|
|
},
|
|
|
|
// eslint-disable-next-line mozilla/use-chromeutils-generateqi
|
2016-05-20 09:33:00 +03:00
|
|
|
QueryInterface() {
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-09-20 13:11:25 +04:00
|
|
|
function finish_cache2_test() {
|
|
|
|
callbacks.forEach(function(callback, index) {
|
|
|
|
callback.selfCheck();
|
|
|
|
});
|
|
|
|
do_test_finished();
|
|
|
|
}
|