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

Side by Side Diff: chrome/test/chromedriver/devtools_client_impl.cc

Issue 12226026: [ChromeDriver] Select the main frame if a non-existant child frame is targeted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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
« no previous file with comments | « chrome/test/chromedriver/commands_unittest.cc ('k') | chrome/test/chromedriver/run_py_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/devtools_client_impl.h" 5 #include "chrome/test/chromedriver/devtools_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/test/chromedriver/devtools_event_listener.h" 12 #include "chrome/test/chromedriver/devtools_event_listener.h"
13 #include "chrome/test/chromedriver/net/sync_websocket.h" 13 #include "chrome/test/chromedriver/net/sync_websocket.h"
14 #include "chrome/test/chromedriver/net/url_request_context_getter.h" 14 #include "chrome/test/chromedriver/net/url_request_context_getter.h"
15 #include "chrome/test/chromedriver/status.h" 15 #include "chrome/test/chromedriver/status.h"
16 16
17 namespace {
18
19 const char* kInspectorContextError =
20 "Execution context with given id not found.";
21
22 Status ParseInspectorError(const std::string& error_json) {
23 scoped_ptr<base::Value> error(base::JSONReader::Read(error_json));
24 base::DictionaryValue* error_dict;
25 if (!error || !error->GetAsDictionary(&error_dict))
26 return Status(kUnknownError, "inspector error with no error message");
27 std::string error_message;
28 if (error_dict->GetString("message", &error_message) &&
29 error_message == kInspectorContextError) {
30 return Status(kNoSuchFrame);
31 }
32 return Status(kUnknownError, "unhandled inspector error: " + error_json);
33 }
34
35 } // namespace
36
17 namespace internal { 37 namespace internal {
18 38
19 InspectorEvent::InspectorEvent() {} 39 InspectorEvent::InspectorEvent() {}
20 40
21 InspectorEvent::~InspectorEvent() {} 41 InspectorEvent::~InspectorEvent() {}
22 42
23 InspectorCommandResponse::InspectorCommandResponse() {} 43 InspectorCommandResponse::InspectorCommandResponse() {}
24 44
25 InspectorCommandResponse::~InspectorCommandResponse() {} 45 InspectorCommandResponse::~InspectorCommandResponse() {}
26 46
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (!parser_func_.Run(message, expected_id, type, event, response)) 173 if (!parser_func_.Run(message, expected_id, type, event, response))
154 return Status(kUnknownError, "bad inspector message: " + message); 174 return Status(kUnknownError, "bad inspector message: " + message);
155 if (*type == internal::kEventMessageType) 175 if (*type == internal::kEventMessageType)
156 return NotifyEventListeners(event->method, *event->params); 176 return NotifyEventListeners(event->method, *event->params);
157 if (*type == internal::kCommandResponseMessageType) { 177 if (*type == internal::kCommandResponseMessageType) {
158 if (cmd_response_map_.count(response->id) == 0) { 178 if (cmd_response_map_.count(response->id) == 0) {
159 return Status(kUnknownError, "unexpected command message"); 179 return Status(kUnknownError, "unexpected command message");
160 } else if (response->result) { 180 } else if (response->result) {
161 cmd_response_map_[response->id] = response->result.release(); 181 cmd_response_map_[response->id] = response->result.release();
162 } else { 182 } else {
163 return Status(kUnknownError, "inspector error: " + response->error); 183 cmd_response_map_.erase(response->id);
184 return ParseInspectorError(response->error);
164 } 185 }
165 } 186 }
166 return Status(kOk); 187 return Status(kOk);
167 } 188 }
168 189
169 Status DevToolsClientImpl::NotifyEventListeners( 190 Status DevToolsClientImpl::NotifyEventListeners(
170 const std::string& method, 191 const std::string& method,
171 const base::DictionaryValue& params) { 192 const base::DictionaryValue& params) {
172 for (std::list<DevToolsEventListener*>::iterator iter = listeners_.begin(); 193 for (std::list<DevToolsEventListener*>::iterator iter = listeners_.begin();
173 iter != listeners_.end(); ++iter) { 194 iter != listeners_.end(); ++iter) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if (unscoped_result) 241 if (unscoped_result)
221 command_response->result.reset(unscoped_result->DeepCopy()); 242 command_response->result.reset(unscoped_result->DeepCopy());
222 else 243 else
223 base::JSONWriter::Write(unscoped_error, &command_response->error); 244 base::JSONWriter::Write(unscoped_error, &command_response->error);
224 return true; 245 return true;
225 } 246 }
226 return false; 247 return false;
227 } 248 }
228 249
229 } // namespace internal 250 } // namespace internal
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/commands_unittest.cc ('k') | chrome/test/chromedriver/run_py_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698