forked from mirrors/gecko-dev
Drop linting of the .eslintrc.js config files. Fix some minor errors in the code (missing let/const, undefined vars). Let eslint know that some files get their globals from other places (typically via xul script tags). MozReview-Commit-ID: CwxuwPtRUr6 --HG-- rename : browser/components/contextualidentity/test/browser/.eslintrc.js => browser/components/syncedtabs/test/browser/.eslintrc.js rename : browser/components/contextualidentity/test/browser/.eslintrc.js => browser/extensions/webcompat/test/browser/.eslintrc.js extra : rebase_source : 9026aac49953d941853022cbab3e33d7d2f2fa21
34 lines
907 B
JavaScript
34 lines
907 B
JavaScript
Cu.import("resource://gre/modules/Promise.jsm");
|
|
|
|
const SINGLE_TRY_TIMEOUT = 100;
|
|
const NUMBER_OF_TRIES = 30;
|
|
|
|
function waitForConditionPromise(condition, timeoutMsg, tryCount=NUMBER_OF_TRIES) {
|
|
let defer = Promise.defer();
|
|
let tries = 0;
|
|
function checkCondition() {
|
|
if (tries >= tryCount) {
|
|
defer.reject(timeoutMsg);
|
|
}
|
|
var conditionPassed;
|
|
try {
|
|
conditionPassed = condition();
|
|
} catch (e) {
|
|
return defer.reject(e);
|
|
}
|
|
if (conditionPassed) {
|
|
return defer.resolve();
|
|
}
|
|
tries++;
|
|
setTimeout(checkCondition, SINGLE_TRY_TIMEOUT);
|
|
return undefined;
|
|
}
|
|
setTimeout(checkCondition, SINGLE_TRY_TIMEOUT);
|
|
return defer.promise;
|
|
}
|
|
|
|
function waitForCondition(condition, nextTest, errorMsg) {
|
|
waitForConditionPromise(condition, errorMsg).then(nextTest, (reason) => {
|
|
ok(false, reason + (reason.stack ? "\n" + reason.stack : ""));
|
|
});
|
|
}
|