| 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/session_commands.h" | 5 #include "chrome/test/chromedriver/session_commands.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/logging.h" // For CHECK macros. | 13 #include "base/logging.h" // For CHECK macros. |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/test/chromedriver/basic_types.h" | 20 #include "chrome/test/chromedriver/basic_types.h" |
| 21 #include "chrome/test/chromedriver/capabilities.h" | 21 #include "chrome/test/chromedriver/capabilities.h" |
| 22 #include "chrome/test/chromedriver/chrome/automation_extension.h" | 22 #include "chrome/test/chromedriver/chrome/automation_extension.h" |
| 23 #include "chrome/test/chromedriver/chrome/browser_info.h" | 23 #include "chrome/test/chromedriver/chrome/browser_info.h" |
| 24 #include "chrome/test/chromedriver/chrome/chrome.h" | 24 #include "chrome/test/chromedriver/chrome/chrome.h" |
| 25 #include "chrome/test/chromedriver/chrome/chrome_android_impl.h" | 25 #include "chrome/test/chromedriver/chrome/chrome_android_impl.h" |
| 26 #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" | 26 #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" |
| 27 #include "chrome/test/chromedriver/chrome/device_manager.h" | 27 #include "chrome/test/chromedriver/chrome/device_manager.h" |
| 28 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" | 28 #include "chrome/test/chromedriver/chrome/devtools_event_listener.h" |
| 29 #include "chrome/test/chromedriver/chrome/geoposition.h" | 29 #include "chrome/test/chromedriver/chrome/geoposition.h" |
| 30 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h" |
| 30 #include "chrome/test/chromedriver/chrome/status.h" | 31 #include "chrome/test/chromedriver/chrome/status.h" |
| 31 #include "chrome/test/chromedriver/chrome/web_view.h" | 32 #include "chrome/test/chromedriver/chrome/web_view.h" |
| 32 #include "chrome/test/chromedriver/chrome_launcher.h" | 33 #include "chrome/test/chromedriver/chrome_launcher.h" |
| 33 #include "chrome/test/chromedriver/command_listener.h" | 34 #include "chrome/test/chromedriver/command_listener.h" |
| 34 #include "chrome/test/chromedriver/logging.h" | 35 #include "chrome/test/chromedriver/logging.h" |
| 35 #include "chrome/test/chromedriver/net/url_request_context_getter.h" | 36 #include "chrome/test/chromedriver/net/url_request_context_getter.h" |
| 36 #include "chrome/test/chromedriver/session.h" | 37 #include "chrome/test/chromedriver/session.h" |
| 37 #include "chrome/test/chromedriver/util.h" | 38 #include "chrome/test/chromedriver/util.h" |
| 38 #include "chrome/test/chromedriver/version.h" | 39 #include "chrome/test/chromedriver/version.h" |
| 39 | 40 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 69 } | 70 } |
| 70 *web_view_id = window_handle.substr(sizeof(kWindowHandlePrefix) - 1); | 71 *web_view_id = window_handle.substr(sizeof(kWindowHandlePrefix) - 1); |
| 71 return true; | 72 return true; |
| 72 } | 73 } |
| 73 | 74 |
| 74 Status EvaluateScriptAndIgnoreResult(Session* session, std::string expression) { | 75 Status EvaluateScriptAndIgnoreResult(Session* session, std::string expression) { |
| 75 WebView* web_view = nullptr; | 76 WebView* web_view = nullptr; |
| 76 Status status = session->GetTargetWindow(&web_view); | 77 Status status = session->GetTargetWindow(&web_view); |
| 77 if (status.IsError()) | 78 if (status.IsError()) |
| 78 return status; | 79 return status; |
| 80 if (web_view->GetJavaScriptDialogManager()->IsDialogOpen()) |
| 81 return Status(kUnexpectedAlertOpen); |
| 79 std::string frame_id = session->GetCurrentFrameId(); | 82 std::string frame_id = session->GetCurrentFrameId(); |
| 80 std::unique_ptr<base::Value> result; | 83 std::unique_ptr<base::Value> result; |
| 81 return web_view->EvaluateScript(frame_id, expression, &result); | 84 return web_view->EvaluateScript(frame_id, expression, &result); |
| 82 } | 85 } |
| 83 | 86 |
| 84 } // namespace | 87 } // namespace |
| 85 | 88 |
| 86 InitSessionParams::InitSessionParams( | 89 InitSessionParams::InitSessionParams( |
| 87 scoped_refptr<URLRequestContextGetter> context_getter, | 90 scoped_refptr<URLRequestContextGetter> context_getter, |
| 88 const SyncWebSocketFactory& socket_factory, | 91 const SyncWebSocketFactory& socket_factory, |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 std::unique_ptr<base::Value>* value) { | 874 std::unique_ptr<base::Value>* value) { |
| 872 WebView* web_view = nullptr; | 875 WebView* web_view = nullptr; |
| 873 Status status = session->GetTargetWindow(&web_view); | 876 Status status = session->GetTargetWindow(&web_view); |
| 874 if (status.IsError()) | 877 if (status.IsError()) |
| 875 return status; | 878 return status; |
| 876 status = web_view->DeleteScreenOrientation(); | 879 status = web_view->DeleteScreenOrientation(); |
| 877 if (status.IsError()) | 880 if (status.IsError()) |
| 878 return status; | 881 return status; |
| 879 return Status(kOk); | 882 return Status(kOk); |
| 880 } | 883 } |
| OLD | NEW |