Chromium Code Reviews| Index: chrome/test/chromedriver/window_commands.cc |
| diff --git a/chrome/test/chromedriver/window_commands.cc b/chrome/test/chromedriver/window_commands.cc |
| index ac2598a6dba354b1b9fc0a03acb23ea73e2fd4e1..f6ac8615cb006b48617251002ade3e1c544c34dd 100644 |
| --- a/chrome/test/chromedriver/window_commands.cc |
| +++ b/chrome/test/chromedriver/window_commands.cc |
| @@ -220,10 +220,23 @@ Status ExecuteWindowCommand(const WindowCommand& command, |
| if (web_view->GetJavaScriptDialogManager()->IsDialogOpen()) { |
| std::string alert_text; |
| + std::string alert_behaviour = session->chrome->UnexpectedAlertBehaviour(); |
|
samuong
2016/11/02 22:48:48
nit: do this just before the if statement on line
gmanikpure
2016/11/04 00:23:24
Done.
|
| status = |
| web_view->GetJavaScriptDialogManager()->GetDialogMessage(&alert_text); |
| if (status.IsError()) |
| return status; |
| + |
| + // Close the dialog depending on the unexpectedalert behaviour set by user |
| + // before returning an error, so that subsequent commands do not fail. |
| + if (alert_behaviour == "accept") |
| + status = web_view->GetJavaScriptDialogManager() |
| + ->HandleDialog(true, session->prompt_text.get()); |
| + else if (alert_behaviour == "dismiss") |
| + status = web_view->GetJavaScriptDialogManager() |
| + ->HandleDialog(false, session->prompt_text.get()); |
|
samuong
2016/11/02 22:48:48
does "ignore" mean "don't throw an error", or shou
gmanikpure
2016/11/04 00:23:24
As discussed, we will be throwing unexpected alert
|
| + if (status.IsError()) |
| + return status; |
| + |
| return Status(kUnexpectedAlertOpen, "{Alert text : " + alert_text + "}"); |
| } |