Bugs 715418 and 685804 - Test case for bug 650995 has wrong name / Intermittent failure in test_bug650955.js r=michal.novotny

--HG--
rename : netwerk/test/unit/test_bug650955.js => netwerk/test/unit/test_bug650995.js
This commit is contained in:
bjarne@runitsoft.com 2012-01-09 11:02:39 -05:00
parent 9dd3c8ba7f
commit d006a61f17
2 changed files with 39 additions and 5 deletions

View File

@ -17,11 +17,37 @@ function repeatToLargerThan1K(data) {
return data;
}
function SyncWithCacheThread(aFunc) {
do_check_eq(sync_with_cache_IO_thread_cb.listener, null);
sync_with_cache_IO_thread_cb.listener = aFunc;
var cache = Cc["@mozilla.org/network/cache-service;1"].
getService(Ci.nsICacheService);
var session = cache.createSession(
"HTTP",
Ci.nsICache.STORE_ANYWHERE,
Ci.nsICache.STREAM_BASED);
var cacheEntry = session.asyncOpenCacheEntry(
"nonexistententry",
Ci.nsICache.ACCESS_READ,
sync_with_cache_IO_thread_cb);
}
var sync_with_cache_IO_thread_cb = {
listener: null,
onCacheEntryAvailable: function oCEA(descriptor, accessGranted, status) {
do_check_neq(status, Cr.NS_OK);
cb = this.listener;
this.listener = null;
do_execute_soon(cb);
}
};
function clearCache() {
var service = Components.classes["@mozilla.org/network/cache-service;1"]
.getService(Components.interfaces.nsICacheService);
service.evictEntries(
Components.interfaces.nsICache.STORE_ANYWHERE);
.getService(Ci.nsICacheService);
service.evictEntries(Ci.nsICache.STORE_ANYWHERE);
}
function setupChannel(suffix, value) {
@ -59,7 +85,15 @@ var tests = [
];
function nextTest() {
clearCache();
// We really want each test to be self-contained. Make sure cache is
// cleared and also let all operations finish before starting a new test
SyncWithCacheThread(function() {
clearCache();
SyncWithCacheThread(runNextTest);
});
}
function runNextTest() {
var aTest = tests.shift();
if (!aTest) {
httpserver.stop(do_test_finished);

View File

@ -64,7 +64,7 @@ skip-if = os == "android"
[test_bug596443.js]
[test_bug618835.js]
[test_bug633743.js]
[test_bug650955.js]
[test_bug650995.js]
[test_bug652761.js]
[test_bug651100.js]
# Bug 675044: test fails consistently on Android