Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(686)

Side by Side Diff: chrome/test/chromedriver/window_commands.cc

Issue 1827003004: [Chromedriver] Chromedriver should handle unexpected alert automatically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New modifications Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (web_view->GetJavaScriptDialogManager()->IsDialogOpen()) {
222 std::string alert_text; 222 std::string alert_text;
223 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.
223 status = 224 status =
224 web_view->GetJavaScriptDialogManager()->GetDialogMessage(&alert_text); 225 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 if (alert_behaviour == "accept")
232 status = web_view->GetJavaScriptDialogManager()
233 ->HandleDialog(true, session->prompt_text.get());
234 else if (alert_behaviour == "dismiss")
235 status = web_view->GetJavaScriptDialogManager()
236 ->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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698