Skip to content

Commit

Permalink
actually fix safari alert issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps authored and AmitKumar5 committed Jul 23, 2013
1 parent 9ceb6eb commit f5ce7d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
40 changes: 25 additions & 15 deletions app/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,21 +590,6 @@ IOS.prototype.push = function(elem) {
var me = this;

var next = function() {
if (me.selectingNewPage && me.curWindowHandle) {
logger.info("We're in the middle of selecting a new page, " +
"waiting to run next command until done");
setTimeout(next, 500);
return;
} else if (me.curWindowHandle && me.processingRemoteCmd &&
elem !== "au.alertIsPresent()" && elem !== "au.getAlertText()" &&
elem !== "au.acceptAlert()" && elem !== "au.dismissAlert()" &&
elem !== "au.setAlertText()" && elem !== "au.waitForAlertToClose") {
logger.info("We're in the middle of processing a remote debugger " +
"command, waiting to run next command until done");
setTimeout(next, 500);
return;
}

if (me.queue.length <= 0 || me.progress > 0) {
return;
}
Expand All @@ -613,6 +598,31 @@ IOS.prototype.push = function(elem) {
, command = target[0]
, cb = target[1];

if (me.selectingNewPage && me.curWindowHandle) {
logger.info("We're in the middle of selecting a new page, " +
"waiting to run next command until done");
setTimeout(next, 500);
me.queue.unshift(target);
return;
} else if (me.curWindowHandle && me.processingRemoteCmd) {
var matches = ["au.alertIsPresent", "au.getAlertText", "au.acceptAlert",
"au.dismissAlert", "au.setAlertText",
"au.waitForAlertToClose"];
var matched = false;
_.each(matches, function(match) {
if (command.indexOf(match) === 0) {
matched = true;
}
});
if (!matched) {
logger.info("We're in the middle of processing a remote debugger " +
"command, waiting to run next command until done");
setTimeout(next, 500);
me.queue.unshift(target);
return;
}
}

me.cbForCurrentCmd = cb;

me.progress++;
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ module.exports.buildTests = function(webviewType) {
});
});
});
it('should dismiss', function(done) {
it('should dismiss alert', function(done) {
loadWebView(h.driver, function() {
h.driver.elementById('alert1', function(err, link) {
link.click(function(err) {
Expand Down

0 comments on commit f5ce7d5

Please sign in to comment.