OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webdriver/commands/webdriver_command.h" | 5 #include "chrome/test/webdriver/commands/webdriver_command.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 bool WebDriverCommand::Init(Response* const response) { | 28 bool WebDriverCommand::Init(Response* const response) { |
29 // There should be at least 3 path segments to match "/session/$id". | 29 // There should be at least 3 path segments to match "/session/$id". |
30 std::string session_id = GetPathVariable(2); | 30 std::string session_id = GetPathVariable(2); |
31 if (session_id.length() == 0) { | 31 if (session_id.length() == 0) { |
32 response->SetError( | 32 response->SetError( |
33 new Error(kBadRequest, "No session ID specified")); | 33 new Error(kBadRequest, "No session ID specified")); |
34 return false; | 34 return false; |
35 } | 35 } |
36 | 36 |
37 VLOG(1) << "Fetching session: " << session_id; | |
38 session_ = SessionManager::GetInstance()->GetSession(session_id); | 37 session_ = SessionManager::GetInstance()->GetSession(session_id); |
39 if (session_ == NULL) { | 38 if (session_ == NULL) { |
40 response->SetError( | 39 response->SetError( |
41 new Error(kSessionNotFound, "Session not found: " + session_id)); | 40 new Error(kSessionNotFound, "Session not found: " + session_id)); |
42 return false; | 41 return false; |
43 } | 42 } |
44 | 43 |
45 // TODO(kkania): Do not use the standard automation timeout for this, | 44 LOG(INFO) << "Waiting for the page to stop loading"; |
46 // and throw an error if it does not succeed. | 45 Error* error = session_->WaitForAllTabsToStopLoading(); |
47 scoped_ptr<Error> error(session_->WaitForAllTabsToStopLoading()); | 46 if (error) { |
48 if (error.get()) { | 47 response->SetError(error); |
49 LOG(WARNING) << error->ToString(); | 48 return false; |
50 } | 49 } |
51 error.reset(session_->SwitchToTopFrameIfCurrentFrameInvalid()); | 50 LOG(INFO) << "Done waiting for the page to stop loading"; |
52 if (error.get()) { | 51 error = session_->SwitchToTopFrameIfCurrentFrameInvalid(); |
53 LOG(WARNING) << error->ToString(); | 52 if (error) { |
| 53 response->SetError(error); |
| 54 return false; |
54 } | 55 } |
55 | 56 |
56 response->SetField("sessionId", Value::CreateStringValue(session_id)); | 57 response->SetField("sessionId", Value::CreateStringValue(session_id)); |
57 return true; | 58 return true; |
58 } | 59 } |
59 | 60 |
60 } // namespace webdriver | 61 } // namespace webdriver |
OLD | NEW |