Bug 916887 - waitForEvent should return the promise that is resolved after its cleanup is complete. r=mbrubeck

--HG--
extra : rebase_source : fb9bf106058495563e3fa37802b7bb320db773bf
This commit is contained in:
Sam Foster 2013-09-17 11:12:40 -07:00
Родитель f5eb6822c5
Коммит f68da31e4c
1 изменённых файлов: 4 добавлений и 5 удалений

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

@ -341,14 +341,13 @@ function waitForEvent(aSubject, aEventName, aTimeoutMs, aTarget) {
eventDeferred.resolve(aEvent);
}
function cleanup() {
function cleanup(aEventOrError) {
// unhook listener in case of success or failure
aSubject.removeEventListener(aEventName, listener);
return aEventOrError;
}
eventDeferred.promise.then(cleanup, cleanup);
aSubject.addEventListener(aEventName, listener, false);
return eventDeferred.promise;
return eventDeferred.promise.then(cleanup, cleanup);
}
/**
@ -425,7 +424,7 @@ function waitForCondition(aCondition, aTimeoutMs, aIntervalMs) {
}
/**
* same as waitForCondition but with better test output.
* same as waitForCondition but with better test output.
*
* @param aCondition the callback that must return a truthy value
* @param aTestMsg test condition message printed when the test succeeds or