| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 5 #include "chrome/test/chromedriver/session.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/test/chromedriver/chrome.h" | 10 #include "chrome/test/chromedriver/chrome.h" |
| 11 #include "chrome/test/chromedriver/status.h" | 11 #include "chrome/test/chromedriver/status.h" |
| 12 #include "chrome/test/chromedriver/version.h" | 12 #include "chrome/test/chromedriver/version.h" |
| 13 #include "chrome/test/chromedriver/web_view.h" | 13 #include "chrome/test/chromedriver/web_view.h" |
| 14 | 14 |
| 15 FrameInfo::FrameInfo(const std::string& parent_frame_id, |
| 16 const std::string& frame_id, |
| 17 const std::string& chromedriver_frame_id) |
| 18 : parent_frame_id(parent_frame_id), |
| 19 frame_id(frame_id), |
| 20 chromedriver_frame_id(chromedriver_frame_id) {} |
| 21 |
| 15 Session::Session(const std::string& id) | 22 Session::Session(const std::string& id) |
| 16 : id(id), | 23 : id(id), |
| 17 mouse_position(0, 0), | 24 mouse_position(0, 0), |
| 18 implicit_wait(0), | 25 implicit_wait(0), |
| 19 page_load_timeout(0), | 26 page_load_timeout(0), |
| 20 script_timeout(0) { | 27 script_timeout(0) { |
| 21 } | 28 } |
| 22 | 29 |
| 23 Session::Session(const std::string& id, scoped_ptr<Chrome> chrome) | 30 Session::Session(const std::string& id, scoped_ptr<Chrome> chrome) |
| 24 : id(id), | 31 : id(id), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 44 for (std::list<WebView*>::const_iterator it = web_views.begin(); | 51 for (std::list<WebView*>::const_iterator it = web_views.begin(); |
| 45 it != web_views.end(); ++it) { | 52 it != web_views.end(); ++it) { |
| 46 if ((*it)->GetId() == window) { | 53 if ((*it)->GetId() == window) { |
| 47 *web_view = *it; | 54 *web_view = *it; |
| 48 return Status(kOk); | 55 return Status(kOk); |
| 49 } | 56 } |
| 50 } | 57 } |
| 51 return Status(kNoSuchWindow, "target window already closed"); | 58 return Status(kNoSuchWindow, "target window already closed"); |
| 52 } | 59 } |
| 53 | 60 |
| 61 void Session::SwitchToTopFrame() { |
| 62 frames.clear(); |
| 63 } |
| 64 |
| 65 void Session::SwitchToSubFrame(const std::string& frame_id, |
| 66 const std::string& chromedriver_frame_id) { |
| 67 std::string parent_frame_id; |
| 68 if (!frames.empty()) |
| 69 parent_frame_id = frames.back().frame_id; |
| 70 frames.push_back(FrameInfo(parent_frame_id, frame_id, chromedriver_frame_id)); |
| 71 } |
| 72 |
| 73 std::string Session::GetCurrentFrameId() const { |
| 74 if (frames.empty()) |
| 75 return ""; |
| 76 return frames.back().frame_id; |
| 77 } |
| 78 |
| 54 scoped_ptr<base::DictionaryValue> Session::CreateCapabilities() { | 79 scoped_ptr<base::DictionaryValue> Session::CreateCapabilities() { |
| 55 scoped_ptr<base::DictionaryValue> caps(new base::DictionaryValue()); | 80 scoped_ptr<base::DictionaryValue> caps(new base::DictionaryValue()); |
| 56 caps->SetString("browserName", "chrome"); | 81 caps->SetString("browserName", "chrome"); |
| 57 caps->SetString("version", chrome->GetVersion()); | 82 caps->SetString("version", chrome->GetVersion()); |
| 58 caps->SetString("driverVersion", kChromeDriverVersion); | 83 caps->SetString("driverVersion", kChromeDriverVersion); |
| 59 caps->SetString("platform", chrome->GetOperatingSystemName()); | 84 caps->SetString("platform", chrome->GetOperatingSystemName()); |
| 60 caps->SetBoolean("javascriptEnabled", true); | 85 caps->SetBoolean("javascriptEnabled", true); |
| 61 caps->SetBoolean("takesScreenshot", true); | 86 caps->SetBoolean("takesScreenshot", true); |
| 62 caps->SetBoolean("handlesAlerts", true); | 87 caps->SetBoolean("handlesAlerts", true); |
| 63 caps->SetBoolean("databaseEnabled", true); | 88 caps->SetBoolean("databaseEnabled", true); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 74 | 99 |
| 75 SessionAccessorImpl::SessionAccessorImpl(scoped_ptr<Session> session) | 100 SessionAccessorImpl::SessionAccessorImpl(scoped_ptr<Session> session) |
| 76 : session_(session.Pass()) {} | 101 : session_(session.Pass()) {} |
| 77 | 102 |
| 78 Session* SessionAccessorImpl::Access(scoped_ptr<base::AutoLock>* lock) { | 103 Session* SessionAccessorImpl::Access(scoped_ptr<base::AutoLock>* lock) { |
| 79 lock->reset(new base::AutoLock(session_lock_)); | 104 lock->reset(new base::AutoLock(session_lock_)); |
| 80 return session_.get(); | 105 return session_.get(); |
| 81 } | 106 } |
| 82 | 107 |
| 83 SessionAccessorImpl::~SessionAccessorImpl() {} | 108 SessionAccessorImpl::~SessionAccessorImpl() {} |
| OLD | NEW |