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/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 Loading... |
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 Loading... |
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 } |
OLD | NEW |