| 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/chrome/chrome_desktop_impl.h" | 5 #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 LOG(WARNING) << "chrome user data directory: " << user_data_dir.value(); | 104 LOG(WARNING) << "chrome user data directory: " << user_data_dir.value(); |
| 105 if (extension_dir_.IsValid()) | 105 if (extension_dir_.IsValid()) |
| 106 LOG(WARNING) << "chromedriver automation extension directory: " | 106 LOG(WARNING) << "chromedriver automation extension directory: " |
| 107 << extension_dir.value(); | 107 << extension_dir.value(); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 Status ChromeDesktopImpl::WaitForPageToLoad( | 111 Status ChromeDesktopImpl::WaitForPageToLoad( |
| 112 const std::string& url, | 112 const std::string& url, |
| 113 const base::TimeDelta& timeout_raw, | 113 const base::TimeDelta& timeout_raw, |
| 114 std::unique_ptr<WebView>* web_view) { | 114 std::unique_ptr<WebView>* web_view, |
| 115 bool w3c_compliant) { |
| 115 Timeout timeout(timeout_raw); | 116 Timeout timeout(timeout_raw); |
| 116 std::string id; | 117 std::string id; |
| 117 WebViewInfo::Type type = WebViewInfo::Type::kPage; | 118 WebViewInfo::Type type = WebViewInfo::Type::kPage; |
| 118 while (timeout.GetRemainingTime() > base::TimeDelta()) { | 119 while (timeout.GetRemainingTime() > base::TimeDelta()) { |
| 119 WebViewsInfo views_info; | 120 WebViewsInfo views_info; |
| 120 Status status = devtools_http_client_->GetWebViewsInfo(&views_info); | 121 Status status = devtools_http_client_->GetWebViewsInfo(&views_info); |
| 121 if (status.IsError()) | 122 if (status.IsError()) |
| 122 return status; | 123 return status; |
| 123 | 124 |
| 124 for (size_t i = 0; i < views_info.GetSize(); ++i) { | 125 for (size_t i = 0; i < views_info.GetSize(); ++i) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 139 const DeviceMetrics* device_metrics = devtools_http_client_->device_metrics(); | 140 const DeviceMetrics* device_metrics = devtools_http_client_->device_metrics(); |
| 140 if (type == WebViewInfo::Type::kApp || | 141 if (type == WebViewInfo::Type::kApp || |
| 141 type == WebViewInfo::Type::kBackgroundPage) { | 142 type == WebViewInfo::Type::kBackgroundPage) { |
| 142 // Apps and extensions don't work on Android, so it doesn't make sense to | 143 // Apps and extensions don't work on Android, so it doesn't make sense to |
| 143 // provide override device metrics in mobile emulation mode, and can also | 144 // provide override device metrics in mobile emulation mode, and can also |
| 144 // potentially crash the renderer, for more details see: | 145 // potentially crash the renderer, for more details see: |
| 145 // https://code.google.com/p/chromedriver/issues/detail?id=1205 | 146 // https://code.google.com/p/chromedriver/issues/detail?id=1205 |
| 146 device_metrics = nullptr; | 147 device_metrics = nullptr; |
| 147 } | 148 } |
| 148 std::unique_ptr<WebView> web_view_tmp( | 149 std::unique_ptr<WebView> web_view_tmp( |
| 149 new WebViewImpl(id, devtools_http_client_->browser_info(), | 150 new WebViewImpl(id, w3c_compliant, devtools_http_client_->browser_info(), |
| 150 devtools_http_client_->CreateClient(id), device_metrics, | 151 devtools_http_client_->CreateClient(id), device_metrics, |
| 151 page_load_strategy())); | 152 page_load_strategy())); |
| 152 Status status = web_view_tmp->ConnectIfNecessary(); | 153 Status status = web_view_tmp->ConnectIfNecessary(); |
| 153 if (status.IsError()) | 154 if (status.IsError()) |
| 154 return status; | 155 return status; |
| 155 | 156 |
| 156 status = web_view_tmp->WaitForPendingNavigations( | 157 status = web_view_tmp->WaitForPendingNavigations( |
| 157 std::string(), timeout, false); | 158 std::string(), timeout, false); |
| 158 if (status.IsOk()) | 159 if (status.IsOk()) |
| 159 *web_view = std::move(web_view_tmp); | 160 *web_view = std::move(web_view_tmp); |
| 160 return status; | 161 return status; |
| 161 } | 162 } |
| 162 | 163 |
| 163 Status ChromeDesktopImpl::GetAutomationExtension( | 164 Status ChromeDesktopImpl::GetAutomationExtension( |
| 164 AutomationExtension** extension) { | 165 AutomationExtension** extension, |
| 166 bool w3c_compliant) { |
| 165 if (!automation_extension_) { | 167 if (!automation_extension_) { |
| 166 std::unique_ptr<WebView> web_view; | 168 std::unique_ptr<WebView> web_view; |
| 167 Status status = WaitForPageToLoad( | 169 Status status = WaitForPageToLoad( |
| 168 "chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/" | 170 "chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/" |
| 169 "_generated_background_page.html", | 171 "_generated_background_page.html", |
| 170 base::TimeDelta::FromSeconds(10), | 172 base::TimeDelta::FromSeconds(10), |
| 171 &web_view); | 173 &web_view, |
| 174 w3c_compliant); |
| 172 if (status.IsError()) | 175 if (status.IsError()) |
| 173 return Status(kUnknownError, "cannot get automation extension", status); | 176 return Status(kUnknownError, "cannot get automation extension", status); |
| 174 | 177 |
| 175 automation_extension_.reset(new AutomationExtension(std::move(web_view))); | 178 automation_extension_.reset(new AutomationExtension(std::move(web_view))); |
| 176 } | 179 } |
| 177 *extension = automation_extension_.get(); | 180 *extension = automation_extension_.get(); |
| 178 return Status(kOk); | 181 return Status(kOk); |
| 179 } | 182 } |
| 180 | 183 |
| 181 Status ChromeDesktopImpl::GetAsDesktop(ChromeDesktopImpl** desktop) { | 184 Status ChromeDesktopImpl::GetAsDesktop(ChromeDesktopImpl** desktop) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 218 } |
| 216 | 219 |
| 217 int ChromeDesktopImpl::GetNetworkConnection() const { | 220 int ChromeDesktopImpl::GetNetworkConnection() const { |
| 218 return network_connection_; | 221 return network_connection_; |
| 219 } | 222 } |
| 220 | 223 |
| 221 void ChromeDesktopImpl::SetNetworkConnection( | 224 void ChromeDesktopImpl::SetNetworkConnection( |
| 222 int network_connection) { | 225 int network_connection) { |
| 223 network_connection_ = network_connection; | 226 network_connection_ = network_connection; |
| 224 } | 227 } |
| OLD | NEW |