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

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

Issue 12230021: [chromedriver] Send all OnConnected before any OnEvent when connected. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. 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
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/dom_tracker.h" 5 #include "chrome/test/chromedriver/dom_tracker.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 10 matching lines...) Expand all
21 21
22 Status DomTracker::GetFrameIdForNode( 22 Status DomTracker::GetFrameIdForNode(
23 int node_id, std::string* frame_id) { 23 int node_id, std::string* frame_id) {
24 if (node_to_frame_map_.count(node_id) == 0) 24 if (node_to_frame_map_.count(node_id) == 0)
25 return Status(kUnknownError, "element is not a frame"); 25 return Status(kUnknownError, "element is not a frame");
26 *frame_id = node_to_frame_map_[node_id]; 26 *frame_id = node_to_frame_map_[node_id];
27 return Status(kOk); 27 return Status(kOk);
28 } 28 }
29 29
30 Status DomTracker::OnConnected() { 30 Status DomTracker::OnConnected() {
31 node_to_frame_map_.clear();
31 // Fetch the root document node so that Inspector will push DOM node 32 // Fetch the root document node so that Inspector will push DOM node
32 // information to the client. 33 // information to the client.
33 base::DictionaryValue params; 34 base::DictionaryValue params;
34 return client_->SendCommand("DOM.getDocument", params); 35 return client_->SendCommand("DOM.getDocument", params);
35 } 36 }
36 37
37 void DomTracker::OnEvent(const std::string& method, 38 void DomTracker::OnEvent(const std::string& method,
38 const base::DictionaryValue& params) { 39 const base::DictionaryValue& params) {
39 if (method == "DOM.setChildNodes") { 40 if (method == "DOM.setChildNodes") {
40 const base::Value* nodes; 41 const base::Value* nodes;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return false; 78 return false;
78 std::string frame_id; 79 std::string frame_id;
79 if (dict->GetString("frameId", &frame_id)) 80 if (dict->GetString("frameId", &frame_id))
80 node_to_frame_map_.insert(std::make_pair(node_id, frame_id)); 81 node_to_frame_map_.insert(std::make_pair(node_id, frame_id));
81 82
82 const base::Value* children; 83 const base::Value* children;
83 if (dict->Get("children", &children)) 84 if (dict->Get("children", &children))
84 return ProcessNodeList(children); 85 return ProcessNodeList(children);
85 return true; 86 return true;
86 } 87 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/devtools_client_impl_unittest.cc ('k') | chrome/test/chromedriver/frame_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698