Bug 806422 - Modify and add tests for new Complete caching behavior in protocol 2.3. r=dcamp

This commit is contained in:
Gian-Carlo Pascutto 2012-11-06 15:38:25 +01:00
parent 219e600a01
commit 44ba37d641

View File

@ -566,6 +566,86 @@ function testCachedResultsWithExpire() {
});
}
function testCachedResultsUpdate()
{
var existUrls = ["foo.com/a"];
setupCachedResults(existUrls, function() {
// This is called after setupCachedResults(). Verify that
// checking the url again does not cause a completer request.
// install a new completer, this one should never be queried.
var newCompleter = installCompleter('test-phish-simple', [[1, []]], []);
var assertions = {
"urlsExist" : existUrls,
"completerQueried" : [newCompleter, []]
};
var addUrls = ["foobar.org/a"];
var update2 = buildPhishingUpdate(
[
{ "chunkNum" : 2,
"urls" : addUrls
}],
4);
checkAssertions(assertions, function () {
// Apply the update. The cached completes should be gone.
doStreamUpdate(update2, function() {
// Now the completer gets queried again.
var newCompleter2 = installCompleter('test-phish-simple', [[1, existUrls]], []);
var assertions2 = {
"tableData" : "test-phish-simple;a:1-2",
"urlsExist" : existUrls,
"completerQueried" : [newCompleter2, existUrls]
};
checkAssertions(assertions2, runNextTest);
}, updateError);
});
});
}
function testCachedResultsFailure()
{
var existUrls = ["foo.com/a"];
setupCachedResults(existUrls, function() {
// This is called after setupCachedResults(). Verify that
// checking the url again does not cause a completer request.
// install a new completer, this one should never be queried.
var newCompleter = installCompleter('test-phish-simple', [[1, []]], []);
var assertions = {
"urlsExist" : existUrls,
"completerQueried" : [newCompleter, []]
};
var addUrls = ["foobar.org/a"];
var update2 = buildPhishingUpdate(
[
{ "chunkNum" : 2,
"urls" : addUrls
}],
4);
checkAssertions(assertions, function() {
// Apply the update. The cached completes should be gone.
doErrorUpdate("test-phish-simple,test-malware-simple", function() {
// Now the completer gets queried again.
var newCompleter2 = installCompleter('test-phish-simple', [[1, existUrls]], []);
var assertions2 = {
"tableData" : "test-phish-simple;a:1",
"urlsExist" : existUrls,
"completerQueried" : [newCompleter2, existUrls]
};
checkAssertions(assertions2, runNextTest);
}, updateError);
});
});
}
function setupUncachedResults(addUrls, part2)
{
var update = buildPhishingUpdate(
@ -616,7 +696,9 @@ function testErrorList()
{ "chunkNum" : 1,
"urls" : addUrls
}],
32);
4);
// The update failure should will kill the completes, so the above
// must be a prefix to get any hit at all past the update failure.
var completer = installCompleter('test-phish-simple', [[1, addUrls]], []);
@ -729,7 +811,9 @@ function testErrorListIndependent()
{ "chunkNum" : 1,
"urls" : phishUrls
}],
32);
4);
// These have to persist past the update failure, so they must be prefixes,
// not completes.
update += buildMalwareUpdate(
[
@ -779,6 +863,8 @@ function run_test()
testCachedResults,
testCachedResultsWithSub,
testCachedResultsWithExpire,
testCachedResultsUpdate,
testCachedResultsFailure,
testUncachedResults,
testStaleList,
testStaleListEmpty,