Chromium Code Reviews| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 if (status.IsError()) | 210 if (status.IsError()) |
| 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 |
|
samuong
2016/11/22 19:52:16
given the number of times we call GetJavaScriptDia
gmanikpure
2016/11/23 18:34:26
Done.Thank you for this suggestion, it helped opti
| |
| 221 if (web_view->GetJavaScriptDialogManager()->IsDialogOpen()) { | 221 if (web_view->GetJavaScriptDialogManager()->IsDialogOpen()) { |
| 222 std::string alert_text; | 222 std::string alert_text; |
| 223 status = | 223 status = |
| 224 web_view->GetJavaScriptDialogManager()->GetDialogMessage(&alert_text); | 224 web_view->GetJavaScriptDialogManager()->GetDialogMessage(&alert_text); |
| 225 if (status.IsError()) | 225 if (status.IsError()) |
| 226 return status; | 226 return status; |
| 227 | |
| 228 // Close the dialog depending on the unexpectedalert behaviour set by user | |
| 229 // before returning an error, so that subsequent commands do not fail. | |
| 230 std::string alert_behaviour = session->GetUnexpectedAlertBehaviour(); | |
|
gmanikpure
2016/11/04 00:23:24
As discussed, directly putting it in session inste
| |
| 231 if (alert_behaviour == Session::kAccept) | |
| 232 status = web_view->GetJavaScriptDialogManager() | |
| 233 ->HandleDialog(true, session->prompt_text.get()); | |
| 234 else if (alert_behaviour == Session::kDismiss) | |
| 235 status = web_view->GetJavaScriptDialogManager() | |
| 236 ->HandleDialog(false, session->prompt_text.get()); | |
| 237 if (status.IsError()) | |
| 238 return status; | |
| 239 | |
| 227 return Status(kUnexpectedAlertOpen, "{Alert text : " + alert_text + "}"); | 240 return Status(kUnexpectedAlertOpen, "{Alert text : " + alert_text + "}"); |
| 228 } | 241 } |
| 229 | 242 |
| 230 Status nav_status(kOk); | 243 Status nav_status(kOk); |
| 231 for (int attempt = 0; attempt < 3; attempt++) { | 244 for (int attempt = 0; attempt < 3; attempt++) { |
| 232 if (attempt == 2) { | 245 if (attempt == 2) { |
| 233 // Switch to main frame and retry command if subframe no longer exists. | 246 // Switch to main frame and retry command if subframe no longer exists. |
| 234 session->SwitchToTopFrame(); | 247 session->SwitchToTopFrame(); |
| 235 } | 248 } |
| 236 | 249 |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1064 return status; | 1077 return status; |
| 1065 } | 1078 } |
| 1066 | 1079 |
| 1067 Status ExecuteTakeHeapSnapshot(Session* session, | 1080 Status ExecuteTakeHeapSnapshot(Session* session, |
| 1068 WebView* web_view, | 1081 WebView* web_view, |
| 1069 const base::DictionaryValue& params, | 1082 const base::DictionaryValue& params, |
| 1070 std::unique_ptr<base::Value>* value, | 1083 std::unique_ptr<base::Value>* value, |
| 1071 Timeout* timeout) { | 1084 Timeout* timeout) { |
| 1072 return web_view->TakeHeapSnapshot(value); | 1085 return web_view->TakeHeapSnapshot(value); |
| 1073 } | 1086 } |
| OLD | NEW |