| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/chromedriver/window_commands.h" | 5 #include "chrome/test/chromedriver/window_commands.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return status; | 211 return status; |
| 212 | 212 |
| 213 status = web_view->ConnectIfNecessary(); | 213 status = web_view->ConnectIfNecessary(); |
| 214 if (status.IsError()) | 214 if (status.IsError()) |
| 215 return status; | 215 return status; |
| 216 | 216 |
| 217 status = web_view->HandleReceivedEvents(); | 217 status = web_view->HandleReceivedEvents(); |
| 218 if (status.IsError()) | 218 if (status.IsError()) |
| 219 return status; | 219 return status; |
| 220 | 220 |
| 221 if (web_view->GetJavaScriptDialogManager()->IsDialogOpen()) { | 221 JavaScriptDialogManager* dialog_manager = |
| 222 web_view->GetJavaScriptDialogManager(); |
| 223 if (dialog_manager->IsDialogOpen()) { |
| 222 std::string alert_text; | 224 std::string alert_text; |
| 223 status = | 225 status = dialog_manager->GetDialogMessage(&alert_text); |
| 224 web_view->GetJavaScriptDialogManager()->GetDialogMessage(&alert_text); | |
| 225 if (status.IsError()) | 226 if (status.IsError()) |
| 226 return status; | 227 return status; |
| 228 |
| 229 // Close the dialog depending on the unexpectedalert behaviour set by user |
| 230 // before returning an error, so that subsequent commands do not fail. |
| 231 std::string alert_behaviour = session->unexpected_alert_behaviour; |
| 232 if (alert_behaviour == kAccept) |
| 233 status = dialog_manager->HandleDialog(true, session->prompt_text.get()); |
| 234 else if (alert_behaviour == kDismiss) |
| 235 status = dialog_manager->HandleDialog(false, session->prompt_text.get()); |
| 236 if (status.IsError()) |
| 237 return status; |
| 238 |
| 227 return Status(kUnexpectedAlertOpen, "{Alert text : " + alert_text + "}"); | 239 return Status(kUnexpectedAlertOpen, "{Alert text : " + alert_text + "}"); |
| 228 } | 240 } |
| 229 | 241 |
| 230 Status nav_status(kOk); | 242 Status nav_status(kOk); |
| 231 for (int attempt = 0; attempt < 3; attempt++) { | 243 for (int attempt = 0; attempt < 3; attempt++) { |
| 232 if (attempt == 2) { | 244 if (attempt == 2) { |
| 233 // Switch to main frame and retry command if subframe no longer exists. | 245 // Switch to main frame and retry command if subframe no longer exists. |
| 234 session->SwitchToTopFrame(); | 246 session->SwitchToTopFrame(); |
| 235 } | 247 } |
| 236 | 248 |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 return status; | 1076 return status; |
| 1065 } | 1077 } |
| 1066 | 1078 |
| 1067 Status ExecuteTakeHeapSnapshot(Session* session, | 1079 Status ExecuteTakeHeapSnapshot(Session* session, |
| 1068 WebView* web_view, | 1080 WebView* web_view, |
| 1069 const base::DictionaryValue& params, | 1081 const base::DictionaryValue& params, |
| 1070 std::unique_ptr<base::Value>* value, | 1082 std::unique_ptr<base::Value>* value, |
| 1071 Timeout* timeout) { | 1083 Timeout* timeout) { |
| 1072 return web_view->TakeHeapSnapshot(value); | 1084 return web_view->TakeHeapSnapshot(value); |
| 1073 } | 1085 } |
| OLD | NEW |