Skip to content

Commit 6d505cc

Browse files
committed
Revert behavior of user prompts appearing during JavaScript execution.
This behavior causes too many problems in too many scenarios where a prompt can appear. Reverting to the previous behavior, which is that encountering a user prompt ('alert', 'confirm', 'prompt') when calling JavaScript with executeScript will immediately return control back to the WebDriver code (returning null), and rely on the immediately following command to handle the user prompt.
1 parent f479501 commit 6d505cc

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

cpp/iedriver/IECommandExecutor.cpp

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -399,37 +399,23 @@ LRESULT IECommandExecutor::OnScriptWait(UINT uMsg,
399399
}
400400
} else {
401401
Response response;
402-
if (is_alert_active) {
403-
std::string alert_text;
404-
bool is_notify_unexpected_alert = this->HandleUnexpectedAlert(browser,
405-
alert_handle,
406-
false,
407-
&alert_text);
408-
if (is_notify_unexpected_alert) {
409-
// To keep pace with what Firefox does, we'll return the text of the
410-
// alert in the error response.
411-
response.SetErrorResponse(EUNEXPECTEDALERTOPEN, "Modal dialog present");
412-
response.AddAdditionalData("text", alert_text);
402+
Json::Value script_result;
403+
::SendMessage(browser->script_executor_handle(),
404+
WD_ASYNC_SCRIPT_DETACH_LISTENTER,
405+
NULL,
406+
NULL);
407+
int status_code = static_cast<int>(::SendMessage(browser->script_executor_handle(),
408+
WD_ASYNC_SCRIPT_GET_RESULT,
409+
NULL,
410+
reinterpret_cast<LPARAM>(&script_result)));
411+
if (status_code != WD_SUCCESS) {
412+
std::string error_message = "Error executing JavaScript";
413+
if (script_result.isString()) {
414+
error_message = script_result.asString();
413415
}
416+
response.SetErrorResponse(status_code, error_message);
414417
} else {
415-
Json::Value script_result;
416-
::SendMessage(browser->script_executor_handle(),
417-
WD_ASYNC_SCRIPT_DETACH_LISTENTER,
418-
NULL,
419-
NULL);
420-
int status_code = static_cast<int>(::SendMessage(browser->script_executor_handle(),
421-
WD_ASYNC_SCRIPT_GET_RESULT,
422-
NULL,
423-
reinterpret_cast<LPARAM>(&script_result)));
424-
if (status_code != WD_SUCCESS) {
425-
std::string error_message = "Error executing JavaScript";
426-
if (script_result.isString()) {
427-
error_message = script_result.asString();
428-
}
429-
response.SetErrorResponse(status_code, error_message);
430-
} else {
431-
response.SetSuccessResponse(script_result);
432-
}
418+
response.SetSuccessResponse(script_result);
433419
}
434420
::SendMessage(browser->script_executor_handle(), WM_CLOSE, NULL, NULL);
435421
browser->set_script_executor_handle(NULL);

0 commit comments

Comments
 (0)