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

Unified Diff: chrome/test/webdriver/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/session.h ('k') | chrome/test/webdriver/utility_functions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/session.cc
diff --git a/chrome/test/webdriver/session.cc b/chrome/test/webdriver/session.cc
index 8cb01f9ad5f74373958073876399efd25c1bb831..b4dc265a620add87ad3eef45d810de9431ee02d5 100644
--- a/chrome/test/webdriver/session.cc
+++ b/chrome/test/webdriver/session.cc
@@ -54,15 +54,22 @@ FrameId& FrameId::operator=(const FrameId& other) {
return *this;
}
-Session::Session()
+Session::Options::Options()
+ : use_native_events(false),
+ load_async(false) {
+}
+
+Session::Options::~Options() {
+}
+
+Session::Session(const Options& options)
: id_(GenerateRandomID()),
current_target_(FrameId(0, FramePath())),
thread_(id_.c_str()),
async_script_timeout_(0),
implicit_wait_(0),
- screenshot_on_error_(false),
- use_native_events_(false),
- has_alert_prompt_text_(false) {
+ has_alert_prompt_text_(false),
+ options_(options) {
SessionManager::GetInstance()->Add(this);
}
@@ -91,6 +98,19 @@ Error* Session::Init(const FilePath& browser_exe,
return error;
}
+Error* Session::BeforeExecuteCommand() {
+ Error* error = NULL;
+ if (!options_.load_async) {
+ LOG(INFO) << "Waiting for the page to stop loading";
+ error = WaitForAllTabsToStopLoading();
+ LOG(INFO) << "Done waiting for the page to stop loading";
+ }
+ if (!error) {
+ error = SwitchToTopFrameIfCurrentFrameInvalid();
+ }
+ return error;
+}
+
void Session::Terminate() {
RunSessionTask(NewRunnableMethod(
this,
@@ -228,12 +248,21 @@ Error* Session::DragAndDropFilePaths(
Error* Session::NavigateToURL(const std::string& url) {
Error* error = NULL;
- RunSessionTask(NewRunnableMethod(
- automation_.get(),
- &Automation::NavigateToURL,
- current_target_.window_id,
- url,
- &error));
+ if (options_.load_async) {
+ RunSessionTask(NewRunnableMethod(
+ automation_.get(),
+ &Automation::NavigateToURLAsync,
+ current_target_.window_id,
+ url,
+ &error));
+ } else {
+ RunSessionTask(NewRunnableMethod(
+ automation_.get(),
+ &Automation::NavigateToURL,
+ current_target_.window_id,
+ url,
+ &error));
+ }
return error;
}
@@ -1038,26 +1067,14 @@ int Session::implicit_wait() const {
return implicit_wait_;
}
-void Session::set_screenshot_on_error(bool error) {
- screenshot_on_error_ = error;
-}
-
-bool Session::screenshot_on_error() const {
- return screenshot_on_error_;
-}
-
-void Session::set_use_native_events(bool use_native_events) {
- use_native_events_ = use_native_events;
-}
-
-bool Session::use_native_events() const {
- return use_native_events_;
-}
-
const gfx::Point& Session::get_mouse_position() const {
return mouse_position_;
}
+const Session::Options& Session::options() const {
+ return options_;
+}
+
void Session::RunSessionTask(Task* task) {
base::WaitableEvent done_event(false, false);
thread_.message_loop_proxy()->PostTask(FROM_HERE, NewRunnableMethod(
@@ -1165,7 +1182,7 @@ void Session::SendKeysOnSessionThread(const string16& keys, Error** error) {
return;
}
for (size_t i = 0; i < key_events.size(); ++i) {
- if (use_native_events_) {
+ if (options_.use_native_events) {
// The automation provider will generate up/down events for us, we
// only need to call it once as compared to the WebKeyEvent method.
// Hence we filter events by their types, keeping only rawkeydown.
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | chrome/test/webdriver/utility_functions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698