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/alert_commands.h" | 5 #include "chrome/test/chromedriver/alert_commands.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/test/chromedriver/chrome/chrome.h" | 9 #include "chrome/test/chromedriver/chrome/chrome.h" |
10 #include "chrome/test/chromedriver/chrome/devtools_client.h" | 10 #include "chrome/test/chromedriver/chrome/devtools_client.h" |
11 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" | 11 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" |
12 #include "chrome/test/chromedriver/chrome/status.h" | 12 #include "chrome/test/chromedriver/chrome/status.h" |
13 #include "chrome/test/chromedriver/chrome/web_view.h" | 13 #include "chrome/test/chromedriver/chrome/web_view.h" |
| 14 #include "chrome/test/chromedriver/net/timeout.h" |
14 #include "chrome/test/chromedriver/session.h" | 15 #include "chrome/test/chromedriver/session.h" |
15 | 16 |
16 Status ExecuteAlertCommand(const AlertCommand& alert_command, | 17 Status ExecuteAlertCommand(const AlertCommand& alert_command, |
17 Session* session, | 18 Session* session, |
18 const base::DictionaryValue& params, | 19 const base::DictionaryValue& params, |
19 std::unique_ptr<base::Value>* value) { | 20 std::unique_ptr<base::Value>* value) { |
20 WebView* web_view = NULL; | 21 WebView* web_view = NULL; |
21 Status status = session->GetTargetWindow(&web_view); | 22 Status status = session->GetTargetWindow(&web_view); |
22 if (status.IsError()) | 23 if (status.IsError()) |
23 return status; | 24 return status; |
24 | 25 |
25 status = web_view->ConnectIfNecessary(); | 26 status = web_view->ConnectIfNecessary(); |
26 if (status.IsError()) | 27 if (status.IsError()) |
27 return status; | 28 return status; |
28 | 29 |
29 status = web_view->HandleReceivedEvents(); | 30 status = web_view->HandleReceivedEvents(); |
30 if (status.IsError()) | 31 if (status.IsError()) |
31 return status; | 32 return status; |
32 | 33 |
33 status = web_view->WaitForPendingNavigations( | 34 status = web_view->WaitForPendingNavigations( |
34 session->GetCurrentFrameId(), session->page_load_timeout, true); | 35 session->GetCurrentFrameId(), Timeout(session->page_load_timeout), true); |
35 if (status.IsError() && status.code() != kUnexpectedAlertOpen) | 36 if (status.IsError() && status.code() != kUnexpectedAlertOpen) |
36 return status; | 37 return status; |
37 | 38 |
38 return alert_command.Run(session, web_view, params, value); | 39 return alert_command.Run(session, web_view, params, value); |
39 } | 40 } |
40 | 41 |
41 Status ExecuteGetAlert(Session* session, | 42 Status ExecuteGetAlert(Session* session, |
42 WebView* web_view, | 43 WebView* web_view, |
43 const base::DictionaryValue& params, | 44 const base::DictionaryValue& params, |
44 std::unique_ptr<base::Value>* value) { | 45 std::unique_ptr<base::Value>* value) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 88 |
88 Status ExecuteDismissAlert(Session* session, | 89 Status ExecuteDismissAlert(Session* session, |
89 WebView* web_view, | 90 WebView* web_view, |
90 const base::DictionaryValue& params, | 91 const base::DictionaryValue& params, |
91 std::unique_ptr<base::Value>* value) { | 92 std::unique_ptr<base::Value>* value) { |
92 Status status = web_view->GetJavaScriptDialogManager() | 93 Status status = web_view->GetJavaScriptDialogManager() |
93 ->HandleDialog(false, session->prompt_text.get()); | 94 ->HandleDialog(false, session->prompt_text.get()); |
94 session->prompt_text.reset(); | 95 session->prompt_text.reset(); |
95 return status; | 96 return status; |
96 } | 97 } |
OLD | NEW |