Bug 1104908 - 2 - Remove the timeout in styleinspector's waitforsuccess test helper function; r=harth

This commit is contained in:
Patrick Brosset 2014-12-16 22:34:13 +01:00
parent b9eee2db52
commit ecde280972

View File

@ -506,25 +506,19 @@ function fireCopyEvent(element) {
* polling timeouts after several tries and the promise rejects.
* @param {String} name Optional name of the test. This is used to generate
* the success and failure messages.
* @param {Number} timeout Optional timeout for the validator function, in
* milliseconds. Default is 5000.
* @return a promise that resolves when the function returned true or rejects
* if the timeout is reached
*/
function waitForSuccess(validatorFn, name="untitled", timeout=5000) {
function waitForSuccess(validatorFn, name="untitled") {
let def = promise.defer();
let start = Date.now();
function wait(validatorFn) {
if ((Date.now() - start) > timeout) {
ok(false, "Validator function " + name + " timed out");
return def.reject();
}
if (validatorFn()) {
ok(true, "Validator function " + name + " returned true");
def.resolve();
} else {
setTimeout(() => wait(validatorFn), 100);
setTimeout(() => wait(validatorFn), 200);
}
}
wait(validatorFn);