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

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

Issue 12093057: [ChromeDriver] Send DOM.getDocument after each DOM.documentUpdated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: actually uploaded the files 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/chrome_impl.h" 5 #include "chrome/test/chromedriver/chrome_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/process_util.h" 11 #include "base/process_util.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/test/chromedriver/devtools_client_impl.h" 16 #include "chrome/test/chromedriver/devtools_client_impl.h"
17 #include "chrome/test/chromedriver/devtools_state.h"
17 #include "chrome/test/chromedriver/dom_tracker.h" 18 #include "chrome/test/chromedriver/dom_tracker.h"
18 #include "chrome/test/chromedriver/frame_tracker.h" 19 #include "chrome/test/chromedriver/frame_tracker.h"
19 #include "chrome/test/chromedriver/js.h" 20 #include "chrome/test/chromedriver/js.h"
20 #include "chrome/test/chromedriver/navigation_tracker.h" 21 #include "chrome/test/chromedriver/navigation_tracker.h"
21 #include "chrome/test/chromedriver/net/net_util.h" 22 #include "chrome/test/chromedriver/net/net_util.h"
22 #include "chrome/test/chromedriver/net/sync_websocket_impl.h" 23 #include "chrome/test/chromedriver/net/sync_websocket_impl.h"
23 #include "chrome/test/chromedriver/net/url_request_context_getter.h" 24 #include "chrome/test/chromedriver/net/url_request_context_getter.h"
24 #include "chrome/test/chromedriver/status.h" 25 #include "chrome/test/chromedriver/status.h"
25 #include "googleurl/src/gurl.h" 26 #include "googleurl/src/gurl.h"
26 27
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 FetchPagesInfo(context_getter_, port_, &debugger_urls); 114 FetchPagesInfo(context_getter_, port_, &debugger_urls);
114 if (debugger_urls.empty()) 115 if (debugger_urls.empty())
115 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); 116 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
116 else 117 else
117 break; 118 break;
118 } 119 }
119 if (debugger_urls.empty()) 120 if (debugger_urls.empty())
120 return Status(kUnknownError, "unable to discover open pages"); 121 return Status(kUnknownError, "unable to discover open pages");
121 client_.reset(new DevToolsClientImpl( 122 client_.reset(new DevToolsClientImpl(
122 socket_factory_, debugger_urls.front())); 123 socket_factory_, debugger_urls.front()));
124 client_state_.reset(new DevToolsState(client_.get()));
125 Status status = client_state_->Init();
126 if (status.IsError())
127 return status;
123 client_->AddListener(dom_tracker_.get()); 128 client_->AddListener(dom_tracker_.get());
124 client_->AddListener(frame_tracker_.get()); 129 client_->AddListener(frame_tracker_.get());
125 client_->AddListener(navigation_tracker_.get()); 130 client_->AddListener(navigation_tracker_.get());
126 131 client_->AddListener(client_state_.get());
127 // Perform necessary configuration of the DevTools client. 132 return Status(kOk);
128 // Fetch the root document node so that Inspector will push DOM node
129 // information to the client.
130 base::DictionaryValue params;
131 Status status = client_->SendCommand("DOM.getDocument", params);
132 if (status.IsError())
133 return status;
134 // Enable page domain notifications to allow tracking navigation state.
135 status = client_->SendCommand("Page.enable", params);
136 if (status.IsError())
137 return status;
138 // Enable runtime events to allow tracking execution context creation.
139 return client_->SendCommand("Runtime.enable", params);
140 } 133 }
141 134
142 Status ChromeImpl::Load(const std::string& url) { 135 Status ChromeImpl::Load(const std::string& url) {
143 base::DictionaryValue params; 136 base::DictionaryValue params;
144 params.SetString("url", url); 137 params.SetString("url", url);
145 return client_->SendCommand("Page.navigate", params); 138 return client_->SendCommand("Page.navigate", params);
146 } 139 }
147 140
148 Status ChromeImpl::Reload() { 141 Status ChromeImpl::Reload() {
149 base::DictionaryValue params; 142 base::DictionaryValue params;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 388 }
396 if (status.IsError()) 389 if (status.IsError())
397 return status; 390 return status;
398 391
399 if (!cmd_result->GetInteger("nodeId", node_id)) 392 if (!cmd_result->GetInteger("nodeId", node_id))
400 return Status(kUnknownError, "DOM.requestNode missing int 'nodeId'"); 393 return Status(kUnknownError, "DOM.requestNode missing int 'nodeId'");
401 return Status(kOk); 394 return Status(kOk);
402 } 395 }
403 396
404 } // namespace internal 397 } // namespace internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698