gecko/browser/modules/test/head.js
Blair McBride 099b9e9b54 Bug 1098071 - Move uitour.js library out of test directory. r=MattN
--HG--
rename : browser/modules/test/uitour.js => browser/components/uitour/UITour-lib.js
rename : browser/modules/UITour.jsm => browser/components/uitour/UITour.jsm
rename : browser/base/content/content-UITour.js => browser/components/uitour/content-UITour.js
rename : browser/modules/test/browser_UITour.js => browser/components/uitour/test/browser_UITour.js
rename : browser/modules/test/browser_UITour2.js => browser/components/uitour/test/browser_UITour2.js
rename : browser/modules/test/browser_UITour3.js => browser/components/uitour/test/browser_UITour3.js
rename : browser/modules/test/browser_UITour_annotation_size_attributes.js => browser/components/uitour/test/browser_UITour_annotation_size_attributes.js
rename : browser/modules/test/browser_UITour_availableTargets.js => browser/components/uitour/test/browser_UITour_availableTargets.js
rename : browser/modules/test/browser_UITour_detach_tab.js => browser/components/uitour/test/browser_UITour_detach_tab.js
rename : browser/modules/test/browser_UITour_loop.js => browser/components/uitour/test/browser_UITour_loop.js
rename : browser/modules/test/browser_UITour_modalDialog.js => browser/components/uitour/test/browser_UITour_modalDialog.js
rename : browser/modules/test/browser_UITour_observe.js => browser/components/uitour/test/browser_UITour_observe.js
rename : browser/modules/test/browser_UITour_panel_close_annotation.js => browser/components/uitour/test/browser_UITour_panel_close_annotation.js
rename : browser/modules/test/browser_UITour_registerPageID.js => browser/components/uitour/test/browser_UITour_registerPageID.js
rename : browser/modules/test/browser_UITour_resetProfile.js => browser/components/uitour/test/browser_UITour_resetProfile.js
rename : browser/modules/test/browser_UITour_sync.js => browser/components/uitour/test/browser_UITour_sync.js
rename : browser/modules/test/head.js => browser/components/uitour/test/head.js
rename : browser/modules/test/image.png => browser/components/uitour/test/image.png
rename : browser/modules/test/uitour.html => browser/components/uitour/test/uitour.html
2015-01-06 19:13:46 +13:00

34 lines
880 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);
}
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" + e.stack : ""));
});
}