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

Unified Diff: chrome/test/webdriver/commands/create_session.cc

Issue 7582005: Add chrome.loadAsync capability to ChromeDriver, which allows the user not to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac Created 9 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/webdriver/automation.cc ('k') | chrome/test/webdriver/commands/session_with_id.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/commands/create_session.cc
diff --git a/chrome/test/webdriver/commands/create_session.cc b/chrome/test/webdriver/commands/create_session.cc
index 9e73e3060db61ee88502d03b8b2f0cb53f7b9e56..60b7809e0541436085df9d7abe49f5890bbc5035 100644
--- a/chrome/test/webdriver/commands/create_session.cc
+++ b/chrome/test/webdriver/commands/create_session.cc
@@ -25,6 +25,8 @@
#include "chrome/test/webdriver/session_manager.h"
#include "chrome/test/webdriver/webdriver_error.h"
+namespace webdriver {
+
namespace {
bool WriteBase64DataToFile(const FilePath& filename,
@@ -42,9 +44,18 @@ bool WriteBase64DataToFile(const FilePath& filename,
return true;
}
-} // namespace
+Error* GetBooleanCapability(
+ const base::DictionaryValue* dict, const std::string& key, bool* option) {
+ Value* value = NULL;
+ if (dict->GetWithoutPathExpansion(key, &value)) {
+ if (!value->GetAsBoolean(option)) {
+ return new Error(kUnknownError, key + " must be a boolean");
+ }
+ }
+ return NULL;
+}
-namespace webdriver {
+} // namespace
CreateSession::CreateSession(const std::vector<std::string>& path_segments,
const DictionaryValue* const parameters)
@@ -175,11 +186,24 @@ void CreateSession::ExecutePost(Response* const response) {
return;
}
+ Session::Options options;
+ Error* error = NULL;
+ error = GetBooleanCapability(capabilities, "chrome.nativeEvents",
+ &options.use_native_events);
+ if (!error) {
+ error = GetBooleanCapability(capabilities, "chrome.loadAsync",
+ &options.load_async);
+ }
+ if (error) {
+ response->SetError(error);
+ return;
+ }
+
// Session manages its own liftime, so do not call delete.
- Session* session = new Session();
- Error* error = session->Init(browser_exe,
- temp_user_data_dir,
- command_line_options);
+ Session* session = new Session(options);
+ error = session->Init(browser_exe,
+ temp_user_data_dir,
+ command_line_options);
if (error) {
response->SetError(error);
return;
@@ -194,20 +218,6 @@ void CreateSession::ExecutePost(Response* const response) {
}
}
- bool native_events_required = false;
- Value* native_events_value = NULL;
- if (capabilities->GetWithoutPathExpansion(
- "chrome.nativeEvents", &native_events_value)) {
- if (native_events_value->GetAsBoolean(&native_events_required)) {
- session->set_use_native_events(native_events_required);
- }
- }
- bool screenshot_on_error = false;
- if (capabilities->GetBoolean(
- "takeScreenshotOnError", &screenshot_on_error)) {
- session->set_screenshot_on_error(screenshot_on_error);
- }
-
LOG(INFO) << "Created session " << session->id();
// Redirect to a relative URI. Although prohibited by the HTTP standard,
// this is what the IEDriver does. Finding the actual IP address is
« no previous file with comments | « chrome/test/webdriver/automation.cc ('k') | chrome/test/webdriver/commands/session_with_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698