зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
f5eb6822c5
Коммит
f68da31e4c
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче