Bug 497884: Intermittent failure in test_classifier.html and test_classifier_worker.html. r=sdwilsh

This commit is contained in:
Dave Townsend 2009-06-17 11:47:08 +01:00
Родитель 26cdfe1e13
Коммит bd0eb24d3a
5 изменённых файлов: 26 добавлений и 41 удалений

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

@ -259,6 +259,14 @@ user_pref("security.warn_viewing_mixed", false);
user_pref("geo.wifi.uri", "http://localhost:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs");
user_pref("camino.warn_when_closing", false); // Camino-only, harmless to others
// Make url-classifier updates so rare that they won't affect tests
user_pref("urlclassifier.updateinterval", 172800);
// Point the url-classifier to the local testing server for fast failures
user_pref("browser.safebrowsing.provider.0.gethashURL", "http://localhost:8888/safebrowsing-dummy/gethash");
user_pref("browser.safebrowsing.provider.0.keyURL", "http://localhost:8888/safebrowsing-dummy/newkey");
user_pref("browser.safebrowsing.provider.0.lookupURL", "http://localhost:8888/safebrowsing-dummy/lookup");
user_pref("browser.safebrowsing.provider.0.updateURL", "http://localhost:8888/safebrowsing-dummy/update");
"""
prefs.append(part)

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

@ -45,9 +45,6 @@
// TODO more comprehensive update tests, for example add unittest check
// that the listmanagers tables are properly written on updates
// How frequently we check for updates (30 minutes)
const kUpdateInterval = 30 * 60 * 1000;
function QueryAdapter(callback) {
this.callback_ = callback;
};
@ -68,6 +65,7 @@ function PROT_ListManager() {
this.currentUpdateChecker_ = null; // set when we toggle updates
this.prefs_ = new G_Preferences();
this.updateInterval = this.prefs_.getPref("urlclassifier.updateinterval", 30 * 60) * 1000;
this.updateserverURL_ = null;
this.gethashURL_ = null;
@ -301,16 +299,15 @@ PROT_ListManager.prototype.maybeToggleUpdateChecking = function() {
/**
* Start periodic checks for updates. Idempotent.
* We want to distribute update checks evenly across the update period (an
* hour). To do this, we pick a random number of time between 0 and 30
* minutes. The client first checks at 15 + rand, then every 30 minutes after
* that.
* hour). The first update is scheduled for a random time between 0.5 and 1.5
* times the update interval.
*/
PROT_ListManager.prototype.startUpdateChecker = function() {
this.stopUpdateChecker();
// Schedule the first check for between 15 and 45 minutes.
var repeatingUpdateDelay = kUpdateInterval / 2;
repeatingUpdateDelay += Math.floor(Math.random() * kUpdateInterval);
var repeatingUpdateDelay = this.updateInterval / 2;
repeatingUpdateDelay += Math.floor(Math.random() * this.updateInterval);
this.updateChecker_ = new G_Alarm(BindToObject(this.initialUpdateCheck_,
this),
repeatingUpdateDelay);
@ -319,12 +316,12 @@ PROT_ListManager.prototype.startUpdateChecker = function() {
/**
* Callback for the first update check.
* We go ahead and check for table updates, then start a regular timer (once
* every 30 minutes).
* every update interval).
*/
PROT_ListManager.prototype.initialUpdateCheck_ = function() {
this.checkForUpdates();
this.updateChecker_ = new G_Alarm(BindToObject(this.checkForUpdates, this),
kUpdateInterval, true /* repeat */);
this.updateInterval, true /* repeat */);
}
/**

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

@ -4278,7 +4278,7 @@ nsUrlClassifierDBService::Shutdown()
// First close the db connection.
if (mWorker) {
rv = mWorkerProxy->CancelUpdate();
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to post cancel udpate event");
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to post cancel update event");
rv = mWorkerProxy->CloseDb();
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to post close db event");
}

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

@ -53,21 +53,11 @@ function doUpdate(update) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
try {
dbService.beginUpdate(listener,
"test-malware-simple", "");
dbService.beginStream("", "");
dbService.updateStream(update);
dbService.finishStream();
dbService.finishUpdate();
} catch(ex) {
// The DB service might already be updating. Try again after a 5 seconds...
if (--numTries != 0) {
setTimeout(function() { doUpdate(update) }, 5000);
return;
}
throw ex;
}
dbService.beginUpdate(listener, "test-malware-simple", "");
dbService.beginStream("", "");
dbService.updateStream(update);
dbService.finishStream();
dbService.finishUpdate();
}
SimpleTest.waitForExplicitFinish();

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

@ -53,21 +53,11 @@ function doUpdate(update) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
try {
dbService.beginUpdate(listener,
"test-malware-simple", "");
dbService.beginStream("", "");
dbService.updateStream(update);
dbService.finishStream();
dbService.finishUpdate();
} catch(ex) {
// The DB service might already be updating. Try again after a 5 seconds...
if (--numTries != 0) {
setTimeout(function() { doUpdate(update) }, 5000);
return;
}
throw ex;
}
dbService.beginUpdate(listener, "test-malware-simple", "");
dbService.beginStream("", "");
dbService.updateStream(update);
dbService.finishStream();
dbService.finishUpdate();
}
function onmessage(event)