Bug 1055580 - Intermittent test_cache2-14b-concurent-readers-complete.js | 1 == 3 | 2 == 1 | 3 == 2, r=michal

This commit is contained in:
Honza Bambas 2014-11-19 18:46:09 +01:00
parent b807dc3eb5
commit d2816c9755
2 changed files with 25 additions and 12 deletions

View File

@ -47,6 +47,8 @@ const COMPLETE = 1 << 12;
const DONTFILL = 1 << 13;
// Used in combination with METAONLY, don't call setValid() on the entry after metadata has been set
const DONTSETVALID = 1 << 14;
// Notify before checking the data, useful for proper callback ordering checks
const NOTIFYBEFOREREAD = 1 << 15;
var log_c2 = true;
function LOG_C2(o, m)
@ -237,6 +239,8 @@ OpenCallback.prototype =
do_check_eq(entry.getMetaDataElement("meto"), this.workingMetadata);
if (this.behavior & THROWAVAIL)
this.throwAndNotify(entry);
if (this.behavior & NOTIFYBEFOREREAD)
this.goon(entry, true);
var wrapper = Cc["@mozilla.org/scriptableinputstream;1"].
createInstance(Ci.nsIScriptableInputStream);

View File

@ -14,24 +14,33 @@ function run_test()
var order = 0;
asyncOpenCacheEntry("http://x/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
new OpenCallback(NORMAL|COMPLETE, "x1m", "x1d", function(entry) {
++order;
do_check_eq(order, newCacheBackEndUsed() ? 3 : 1);
mc.fired();
new OpenCallback(NORMAL|COMPLETE|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) {
if (beforeReading) {
++order;
do_check_eq(order, newCacheBackEndUsed() ? 3 : 1);
} else {
mc.fired();
}
})
);
asyncOpenCacheEntry("http://x/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
new OpenCallback(NORMAL, "x1m", "x1d", function(entry) {
++order;
do_check_eq(order, newCacheBackEndUsed() ? 1 : 2);
mc.fired();
new OpenCallback(NORMAL|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) {
if (beforeReading) {
++order;
do_check_eq(order, newCacheBackEndUsed() ? 1 : 2);
} else {
mc.fired();
}
})
);
asyncOpenCacheEntry("http://x/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
new OpenCallback(NORMAL, "x1m", "x1d", function(entry) {
++order;
do_check_eq(order, newCacheBackEndUsed() ? 2 : 3);
mc.fired();
new OpenCallback(NORMAL|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) {
if (beforeReading) {
++order;
do_check_eq(order, newCacheBackEndUsed() ? 2 : 3);
} else {
mc.fired();
}
})
);