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

Side by Side Diff: chrome/test/webdriver/commands/target_locator_commands.cc

Issue 5572001: Send screenshots back to the client for debugging (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fixed nit Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/target_locator_commands.h" 5 #include "chrome/test/webdriver/commands/target_locator_commands.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/test/webdriver/commands/response.h" 9 #include "chrome/test/webdriver/commands/response.h"
10 #include "chrome/test/webdriver/error_codes.h" 10 #include "chrome/test/webdriver/error_codes.h"
11 #include "chrome/test/webdriver/session.h" 11 #include "chrome/test/webdriver/session.h"
12 12
13 namespace webdriver { 13 namespace webdriver {
14 14
15 WindowHandleCommand::WindowHandleCommand( 15 WindowHandleCommand::WindowHandleCommand(
16 const std::vector<std::string>& path_segments, 16 const std::vector<std::string>& path_segments,
17 DictionaryValue* parameters) 17 DictionaryValue* parameters)
18 : WebDriverCommand(path_segments, parameters) {} 18 : WebDriverCommand(path_segments, parameters) {}
19 19
20 WindowHandleCommand::~WindowHandleCommand() {} 20 WindowHandleCommand::~WindowHandleCommand() {}
21 21
22 bool WindowHandleCommand::DoesGet() { 22 bool WindowHandleCommand::DoesGet() {
23 return true; 23 return true;
24 } 24 }
25 25
26 void WindowHandleCommand::ExecuteGet(Response* const response) { 26 void WindowHandleCommand::ExecuteGet(Response* const response) {
27 response->SetStatus(kSuccess); 27 response->SetStatus(kSuccess);
28 response->SetValue(new StringValue( 28 response->SetValue(new StringValue(
29 base::IntToString(session_->current_window_id()))); 29 base::IntToString(session_->CurrentWindowId())));
30 } 30 }
31 31
32 WindowHandlesCommand::WindowHandlesCommand( 32 WindowHandlesCommand::WindowHandlesCommand(
33 const std::vector<std::string>& path_segments, 33 const std::vector<std::string>& path_segments,
34 DictionaryValue* parameters) 34 DictionaryValue* parameters)
35 : WebDriverCommand(path_segments, parameters) {} 35 : WebDriverCommand(path_segments, parameters) {}
36 36
37 WindowHandlesCommand::~WindowHandlesCommand() {} 37 WindowHandlesCommand::~WindowHandlesCommand() {}
38 38
39 bool WindowHandlesCommand::DoesGet() { 39 bool WindowHandlesCommand::DoesGet() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 SET_WEBDRIVER_ERROR(response, "Could not switch to frame", code); 114 SET_WEBDRIVER_ERROR(response, "Could not switch to frame", code);
115 return; 115 return;
116 } 116 }
117 } else if (GetIntegerParameter("id", &index)) { 117 } else if (GetIntegerParameter("id", &index)) {
118 ErrorCode code = session_->SwitchToFrameWithIndex(index); 118 ErrorCode code = session_->SwitchToFrameWithIndex(index);
119 if (code != kSuccess) { 119 if (code != kSuccess) {
120 SET_WEBDRIVER_ERROR(response, "Could not switch to frame", code); 120 SET_WEBDRIVER_ERROR(response, "Could not switch to frame", code);
121 return; 121 return;
122 } 122 }
123 } else if (IsNullParameter("id")) { 123 } else if (IsNullParameter("id")) {
124 session_->set_current_frame_xpath(""); 124 session_->SetCurrentFrameXPath("");
125 } else { 125 } else {
126 SET_WEBDRIVER_ERROR( 126 SET_WEBDRIVER_ERROR(
127 response, "Missing or invalid 'id' parameter", kBadRequest); 127 response, "Missing or invalid 'id' parameter", kBadRequest);
128 return; 128 return;
129 } 129 }
130 response->SetStatus(kSuccess); 130 response->SetStatus(kSuccess);
131 } 131 }
132 132
133 ActiveElementCommand::ActiveElementCommand( 133 ActiveElementCommand::ActiveElementCommand(
134 const std::vector<std::string>& path_segments, 134 const std::vector<std::string>& path_segments,
135 DictionaryValue* parameters) 135 DictionaryValue* parameters)
136 : WebDriverCommand(path_segments, parameters) {} 136 : WebDriverCommand(path_segments, parameters) {}
137 137
138 ActiveElementCommand::~ActiveElementCommand() {} 138 ActiveElementCommand::~ActiveElementCommand() {}
139 139
140 bool ActiveElementCommand::DoesPost() { 140 bool ActiveElementCommand::DoesPost() {
141 return true; 141 return true;
142 } 142 }
143 143
144 void ActiveElementCommand::ExecutePost(Response* const response) { 144 void ActiveElementCommand::ExecutePost(Response* const response) {
145 ListValue args; 145 ListValue args;
146 Value* result = NULL; 146 Value* result = NULL;
147 ErrorCode status = session_->ExecuteScript( 147 ErrorCode status = session_->ExecuteScript(
148 "return document.activeElement || document.body", &args, &result); 148 "return document.activeElement || document.body", &args, &result);
149 response->SetStatus(status); 149 response->SetStatus(status);
150 response->SetValue(result); 150 response->SetValue(result);
151 } 151 }
152 152
153 } // namespace webdriver 153 } // namespace webdriver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698