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

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

Issue 12224116: [ChromeDriver] Remove FrameTracker's dependency on DomTracker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « no previous file | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/frame_tracker.h" 5 #include "chrome/test/chromedriver/frame_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 20 matching lines...) Expand all
31 const std::string& frame_id, int* context_id) { 31 const std::string& frame_id, int* context_id) {
32 if (frame_to_context_map_.count(frame_id) == 0) 32 if (frame_to_context_map_.count(frame_id) == 0)
33 return Status(kUnknownError, "frame does not have execution context"); 33 return Status(kUnknownError, "frame does not have execution context");
34 *context_id = frame_to_context_map_[frame_id]; 34 *context_id = frame_to_context_map_[frame_id];
35 return Status(kOk); 35 return Status(kOk);
36 } 36 }
37 37
38 Status FrameTracker::OnConnected() { 38 Status FrameTracker::OnConnected() {
39 // Enable runtime events to allow tracking execution context creation. 39 // Enable runtime events to allow tracking execution context creation.
40 base::DictionaryValue params; 40 base::DictionaryValue params;
41 return client_->SendCommand("Runtime.enable", params); 41 Status status = client_->SendCommand("Runtime.enable", params);
42 if (status.IsError())
43 return status;
44 return client_->SendCommand("DOM.getDocument", params);
42 } 45 }
43 46
44 void FrameTracker::OnEvent(const std::string& method, 47 void FrameTracker::OnEvent(const std::string& method,
45 const base::DictionaryValue& params) { 48 const base::DictionaryValue& params) {
46 if (method == "Runtime.executionContextCreated") { 49 if (method == "Runtime.executionContextCreated") {
47 const base::DictionaryValue* context; 50 const base::DictionaryValue* context;
48 if (!params.GetDictionary("context", &context)) { 51 if (!params.GetDictionary("context", &context)) {
49 LOG(ERROR) << "Runtime.executionContextCreated missing dict 'context'"; 52 LOG(ERROR) << "Runtime.executionContextCreated missing dict 'context'";
50 return; 53 return;
51 } 54 }
52 int context_id; 55 int context_id;
53 std::string frame_id; 56 std::string frame_id;
54 if (!context->GetInteger("id", &context_id) || 57 if (!context->GetInteger("id", &context_id) ||
55 !context->GetString("frameId", &frame_id)) { 58 !context->GetString("frameId", &frame_id)) {
56 std::string json; 59 std::string json;
57 base::JSONWriter::Write(context, &json); 60 base::JSONWriter::Write(context, &json);
58 LOG(ERROR) << "Runtime.executionContextCreated has invalid 'context': " 61 LOG(ERROR) << "Runtime.executionContextCreated has invalid 'context': "
59 << json; 62 << json;
60 return; 63 return;
61 } 64 }
62 frame_to_context_map_.insert(std::make_pair(frame_id, context_id)); 65 frame_to_context_map_.insert(std::make_pair(frame_id, context_id));
63 context_to_frame_map_.insert(std::make_pair(context_id, frame_id)); 66 context_to_frame_map_.insert(std::make_pair(context_id, frame_id));
64 } else if (method == "DOM.documentUpdated") { 67 } else if (method == "DOM.documentUpdated") {
65 frame_to_context_map_.clear(); 68 frame_to_context_map_.clear();
66 context_to_frame_map_.clear(); 69 context_to_frame_map_.clear();
67 } 70 }
68 } 71 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698