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

Side by Side Diff: chrome/test/chromedriver/frame_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: 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) 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 18 matching lines...) Expand all
29 29
30 Status FrameTracker::GetContextIdForFrame( 30 Status FrameTracker::GetContextIdForFrame(
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 frame_to_context_map_.clear();
40 context_to_frame_map_.clear();
39 // Enable runtime events to allow tracking execution context creation. 41 // Enable runtime events to allow tracking execution context creation.
40 base::DictionaryValue params; 42 base::DictionaryValue params;
41 Status status = client_->SendCommand("Runtime.enable", params); 43 Status status = client_->SendCommand("Runtime.enable", params);
42 if (status.IsError()) 44 if (status.IsError())
43 return status; 45 return status;
44 return client_->SendCommand("DOM.getDocument", params); 46 return client_->SendCommand("DOM.getDocument", params);
45 } 47 }
46 48
47 void FrameTracker::OnEvent(const std::string& method, 49 void FrameTracker::OnEvent(const std::string& method,
48 const base::DictionaryValue& params) { 50 const base::DictionaryValue& params) {
(...skipping 13 matching lines...) Expand all
62 << json; 64 << json;
63 return; 65 return;
64 } 66 }
65 frame_to_context_map_.insert(std::make_pair(frame_id, context_id)); 67 frame_to_context_map_.insert(std::make_pair(frame_id, context_id));
66 context_to_frame_map_.insert(std::make_pair(context_id, frame_id)); 68 context_to_frame_map_.insert(std::make_pair(context_id, frame_id));
67 } else if (method == "DOM.documentUpdated") { 69 } else if (method == "DOM.documentUpdated") {
68 frame_to_context_map_.clear(); 70 frame_to_context_map_.clear();
69 context_to_frame_map_.clear(); 71 context_to_frame_map_.clear();
70 } 72 }
71 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698