Bug 1438671 - Terminate tests early when updates fail. r=gcp

Some of the tests don't handle update errors very well and rely on timeouts to
fire after several minutes. Since these tests are not actually testing update
failure modes, it's safe to fail quicly and terminate the test with an
exception.

MozReview-Commit-ID: EJgaWke6kl2

--HG--
extra : rebase_source : 486797e1a3c23c5a65ae7c5134fd4db7e663a3aa
This commit is contained in:
Francois Marier 2018-03-27 16:29:02 -07:00
Родитель 6ed7327a36
Коммит 9b74d3b226
3 изменённых файлов: 14 добавлений и 0 удалений

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

@ -451,6 +451,16 @@ function waitUntilMetaDataSaved(expectedState, expectedChecksum, callback) {
});
}
function throwOnUpdateErrors() {
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
info("[" + aTopic + "] " + aData);
if (aData != "success") {
Services.obs.removeObserver(observer, aTopic);
updateError(aData);
}
}, "safebrowsing-update-finished");
}
cleanUp();
registerCleanupFunction(function() {

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

@ -230,6 +230,8 @@ function registerHandlerUpdateV4() {
}
function run_test() {
throwOnUpdateErrors();
gHttpServV4 = new HttpServer();
gHttpServV4.registerDirectory("/", do_get_cwd());

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

@ -192,6 +192,8 @@ add_test(function test_getGethashUrl() {
});
function run_test() {
throwOnUpdateErrors();
// Setup primary testing server.
gHttpServ = new HttpServer();
gHttpServ.registerDirectory("/", do_get_cwd());