mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1104908 - 2 - Remove the timeout in styleinspector's waitforsuccess test helper function; r=harth
This commit is contained in:
parent
b9eee2db52
commit
ecde280972
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user