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

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

Issue 1827003004: [Chromedriver] Chromedriver should handle unexpected alert automatically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove getter, use variable directly. Created 4 years 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
« no previous file with comments | « chrome/test/chromedriver/session.h ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 device_manager(device_manager), 97 device_manager(device_manager),
98 port_server(port_server), 98 port_server(port_server),
99 port_manager(port_manager) {} 99 port_manager(port_manager) {}
100 100
101 InitSessionParams::InitSessionParams(const InitSessionParams& other) = default; 101 InitSessionParams::InitSessionParams(const InitSessionParams& other) = default;
102 102
103 InitSessionParams::~InitSessionParams() {} 103 InitSessionParams::~InitSessionParams() {}
104 104
105 namespace { 105 namespace {
106 106
107 std::unique_ptr<base::DictionaryValue> CreateCapabilities(Chrome* chrome) { 107 std::unique_ptr<base::DictionaryValue> CreateCapabilities(Session* session) {
108 std::unique_ptr<base::DictionaryValue> caps(new base::DictionaryValue()); 108 std::unique_ptr<base::DictionaryValue> caps(new base::DictionaryValue());
109 caps->SetString("browserName", "chrome"); 109 caps->SetString("browserName", "chrome");
110 caps->SetString("version", chrome->GetBrowserInfo()->browser_version); 110 caps->SetString("version",
111 session->chrome->GetBrowserInfo()->browser_version);
111 caps->SetString("chrome.chromedriverVersion", kChromeDriverVersion); 112 caps->SetString("chrome.chromedriverVersion", kChromeDriverVersion);
112 caps->SetString("platform", chrome->GetOperatingSystemName()); 113 caps->SetString("platform", session->chrome->GetOperatingSystemName());
113 caps->SetString("pageLoadStrategy", chrome->page_load_strategy()); 114 caps->SetString("pageLoadStrategy", session->chrome->page_load_strategy());
114 caps->SetBoolean("javascriptEnabled", true); 115 caps->SetBoolean("javascriptEnabled", true);
115 caps->SetBoolean("takesScreenshot", true); 116 caps->SetBoolean("takesScreenshot", true);
116 caps->SetBoolean("takesHeapSnapshot", true); 117 caps->SetBoolean("takesHeapSnapshot", true);
117 caps->SetBoolean("handlesAlerts", true); 118 caps->SetBoolean("handlesAlerts", true);
118 caps->SetBoolean("databaseEnabled", false); 119 caps->SetBoolean("databaseEnabled", false);
119 caps->SetBoolean("locationContextEnabled", true); 120 caps->SetBoolean("locationContextEnabled", true);
120 caps->SetBoolean("mobileEmulationEnabled", 121 caps->SetBoolean("mobileEmulationEnabled",
121 chrome->IsMobileEmulationEnabled()); 122 session->chrome->IsMobileEmulationEnabled());
122 caps->SetBoolean("applicationCacheEnabled", false); 123 caps->SetBoolean("applicationCacheEnabled", false);
123 caps->SetBoolean("browserConnectionEnabled", false); 124 caps->SetBoolean("browserConnectionEnabled", false);
124 caps->SetBoolean("cssSelectorsEnabled", true); 125 caps->SetBoolean("cssSelectorsEnabled", true);
125 caps->SetBoolean("webStorageEnabled", true); 126 caps->SetBoolean("webStorageEnabled", true);
126 caps->SetBoolean("rotatable", false); 127 caps->SetBoolean("rotatable", false);
127 caps->SetBoolean("acceptSslCerts", true); 128 caps->SetBoolean("acceptSslCerts", true);
128 caps->SetBoolean("nativeEvents", true); 129 caps->SetBoolean("nativeEvents", true);
129 caps->SetBoolean("hasTouchScreen", chrome->HasTouchScreen()); 130 caps->SetBoolean("hasTouchScreen", session->chrome->HasTouchScreen());
131 caps->SetString("unexpectedAlertBehaviour",
132 session->unexpected_alert_behaviour);
130 133
131 ChromeDesktopImpl* desktop = NULL; 134 ChromeDesktopImpl* desktop = NULL;
132 Status status = chrome->GetAsDesktop(&desktop); 135 Status status = session->chrome->GetAsDesktop(&desktop);
133 if (status.IsOk()) { 136 if (status.IsOk()) {
134 caps->SetString("chrome.userDataDir", 137 caps->SetString("chrome.userDataDir",
135 desktop->command().GetSwitchValueNative("user-data-dir")); 138 desktop->command().GetSwitchValueNative("user-data-dir"));
136 caps->SetBoolean("networkConnectionEnabled", 139 caps->SetBoolean("networkConnectionEnabled",
137 desktop->IsNetworkConnectionEnabled()); 140 desktop->IsNetworkConnectionEnabled());
138 } 141 }
139 142
140 return caps; 143 return caps;
141 } 144 }
142 145
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 session->w3c_compliant = true; 183 session->w3c_compliant = true;
181 else if (!params.GetDictionary("desiredCapabilities", &desired_caps) && 184 else if (!params.GetDictionary("desiredCapabilities", &desired_caps) &&
182 !params.GetDictionary("capabilities.desiredCapabilities", &desired_caps)) 185 !params.GetDictionary("capabilities.desiredCapabilities", &desired_caps))
183 return Status(kUnknownError, "cannot find dict 'desiredCapabilities'"); 186 return Status(kUnknownError, "cannot find dict 'desiredCapabilities'");
184 187
185 Capabilities capabilities; 188 Capabilities capabilities;
186 Status status = capabilities.Parse(*desired_caps); 189 Status status = capabilities.Parse(*desired_caps);
187 if (status.IsError()) 190 if (status.IsError())
188 return status; 191 return status;
189 192
193 desired_caps->GetString("unexpectedAlertBehaviour",
194 &session->unexpected_alert_behaviour);
195
190 Log::Level driver_level = Log::kWarning; 196 Log::Level driver_level = Log::kWarning;
191 if (capabilities.logging_prefs.count(WebDriverLog::kDriverType)) 197 if (capabilities.logging_prefs.count(WebDriverLog::kDriverType))
192 driver_level = capabilities.logging_prefs[WebDriverLog::kDriverType]; 198 driver_level = capabilities.logging_prefs[WebDriverLog::kDriverType];
193 session->driver_log->set_min_level(driver_level); 199 session->driver_log->set_min_level(driver_level);
194 200
195 // Create Log's and DevToolsEventListener's for ones that are DevTools-based. 201 // Create Log's and DevToolsEventListener's for ones that are DevTools-based.
196 // Session will own the Log's, Chrome will own the listeners. 202 // Session will own the Log's, Chrome will own the listeners.
197 // Also create |CommandListener|s for the appropriate logs. 203 // Also create |CommandListener|s for the appropriate logs.
198 ScopedVector<DevToolsEventListener> devtools_event_listeners; 204 ScopedVector<DevToolsEventListener> devtools_event_listeners;
199 ScopedVector<CommandListener> command_listeners; 205 ScopedVector<CommandListener> command_listeners;
(...skipping 18 matching lines...) Expand all
218 &session->chrome); 224 &session->chrome);
219 if (status.IsError()) 225 if (status.IsError())
220 return status; 226 return status;
221 227
222 status = session->chrome->GetWebViewIdForFirstTab(&session->window); 228 status = session->chrome->GetWebViewIdForFirstTab(&session->window);
223 if (status.IsError()) 229 if (status.IsError())
224 return status; 230 return status;
225 231
226 session->detach = capabilities.detach; 232 session->detach = capabilities.detach;
227 session->force_devtools_screenshot = capabilities.force_devtools_screenshot; 233 session->force_devtools_screenshot = capabilities.force_devtools_screenshot;
228 session->capabilities = CreateCapabilities(session->chrome.get()); 234 session->capabilities = CreateCapabilities(session);
229 value->reset(session->capabilities->DeepCopy()); 235 value->reset(session->capabilities->DeepCopy());
230 return CheckSessionCreated(session); 236 return CheckSessionCreated(session);
231 } 237 }
232 238
233 } // namespace 239 } // namespace
234 240
235 Status ExecuteInitSession(const InitSessionParams& bound_params, 241 Status ExecuteInitSession(const InitSessionParams& bound_params,
236 Session* session, 242 Session* session,
237 const base::DictionaryValue& params, 243 const base::DictionaryValue& params,
238 std::unique_ptr<base::Value>* value) { 244 std::unique_ptr<base::Value>* value) {
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 std::unique_ptr<base::Value>* value) { 882 std::unique_ptr<base::Value>* value) {
877 WebView* web_view = nullptr; 883 WebView* web_view = nullptr;
878 Status status = session->GetTargetWindow(&web_view); 884 Status status = session->GetTargetWindow(&web_view);
879 if (status.IsError()) 885 if (status.IsError())
880 return status; 886 return status;
881 status = web_view->DeleteScreenOrientation(); 887 status = web_view->DeleteScreenOrientation();
882 if (status.IsError()) 888 if (status.IsError())
883 return status; 889 return status;
884 return Status(kOk); 890 return Status(kOk);
885 } 891 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/session.h ('k') | chrome/test/chromedriver/test/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698