use node-style callbacks and fix undefined logic

This commit is contained in:
Jonathan Lipps
2014-06-18 11:47:16 -07:00
parent 4ed4c774ae
commit 3773735fa0

View File

@@ -10,14 +10,14 @@ var iOSHybrid = {};
iOSHybrid.closeAlertBeforeTest = function (cb) {
this.proxy("au.alertIsPresent()", function (err, res) {
if (!err && res !== null && typeof res.value !== "undefined" && res.value === true) {
if (!err && res !== null && typeof res !== "undefined" && res.value === true) {
logger.debug("Alert present before starting test, let's banish it");
this.proxy("au.dismissAlert()", function () {
logger.debug("Alert banished!");
cb(true);
cb(null, true);
});
} else {
cb(false);
cb(null, false);
}
}.bind(this));
};
@@ -69,7 +69,7 @@ iOSHybrid.listWebFrames = function (cb, exitCb) {
var loopClose = function () {
loopCloseRuns++;
if (!isDone && loopCloseRuns < 3) {
this.closeAlertBeforeTest(function (didDismiss) {
this.closeAlertBeforeTest(function (err, didDismiss) {
if (!didDismiss) {
setTimeout(loopClose, 1000);
}