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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/test/chromedriver/chrome/browser_info.h" | 10 #include "chrome/test/chromedriver/chrome/browser_info.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 257 |
258 class FailToEvalScriptDevToolsClient : public StubDevToolsClient { | 258 class FailToEvalScriptDevToolsClient : public StubDevToolsClient { |
259 public: | 259 public: |
260 FailToEvalScriptDevToolsClient() : is_dom_getDocument_requested_(false) {} | 260 FailToEvalScriptDevToolsClient() : is_dom_getDocument_requested_(false) {} |
261 | 261 |
262 virtual ~FailToEvalScriptDevToolsClient() {} | 262 virtual ~FailToEvalScriptDevToolsClient() {} |
263 | 263 |
264 virtual Status SendCommandAndGetResult( | 264 virtual Status SendCommandAndGetResult( |
265 const std::string& method, | 265 const std::string& method, |
266 const base::DictionaryValue& params, | 266 const base::DictionaryValue& params, |
267 scoped_ptr<base::DictionaryValue>* result) OVERRIDE { | 267 scoped_ptr<base::DictionaryValue>* result) override { |
268 if (!is_dom_getDocument_requested_ && method == "DOM.getDocument") { | 268 if (!is_dom_getDocument_requested_ && method == "DOM.getDocument") { |
269 is_dom_getDocument_requested_ = true; | 269 is_dom_getDocument_requested_ = true; |
270 base::DictionaryValue result_dict; | 270 base::DictionaryValue result_dict; |
271 result_dict.SetString("root.baseURL", "http://test"); | 271 result_dict.SetString("root.baseURL", "http://test"); |
272 result->reset(result_dict.DeepCopy()); | 272 result->reset(result_dict.DeepCopy()); |
273 return Status(kOk); | 273 return Status(kOk); |
274 } | 274 } |
275 EXPECT_STREQ("Runtime.evaluate", method.c_str()); | 275 EXPECT_STREQ("Runtime.evaluate", method.c_str()); |
276 return Status(kUnknownError, "failed to eval script"); | 276 return Status(kUnknownError, "failed to eval script"); |
277 } | 277 } |
(...skipping 25 matching lines...) Expand all Loading... |
303 : has_empty_base_url_(has_empty_base_url), | 303 : has_empty_base_url_(has_empty_base_url), |
304 is_loading_(is_loading), | 304 is_loading_(is_loading), |
305 send_event_first_(send_event_first), | 305 send_event_first_(send_event_first), |
306 send_event_first_params_(send_event_first_params) {} | 306 send_event_first_params_(send_event_first_params) {} |
307 | 307 |
308 virtual ~DeterminingLoadStateDevToolsClient() {} | 308 virtual ~DeterminingLoadStateDevToolsClient() {} |
309 | 309 |
310 virtual Status SendCommandAndGetResult( | 310 virtual Status SendCommandAndGetResult( |
311 const std::string& method, | 311 const std::string& method, |
312 const base::DictionaryValue& params, | 312 const base::DictionaryValue& params, |
313 scoped_ptr<base::DictionaryValue>* result) OVERRIDE { | 313 scoped_ptr<base::DictionaryValue>* result) override { |
314 if (method == "DOM.getDocument") { | 314 if (method == "DOM.getDocument") { |
315 base::DictionaryValue result_dict; | 315 base::DictionaryValue result_dict; |
316 if (has_empty_base_url_) | 316 if (has_empty_base_url_) |
317 result_dict.SetString("root.baseURL", std::string()); | 317 result_dict.SetString("root.baseURL", std::string()); |
318 else | 318 else |
319 result_dict.SetString("root.baseURL", "http://test"); | 319 result_dict.SetString("root.baseURL", "http://test"); |
320 result->reset(result_dict.DeepCopy()); | 320 result->reset(result_dict.DeepCopy()); |
321 return Status(kOk); | 321 return Status(kOk); |
322 } | 322 } |
323 | 323 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 base::DictionaryValue params; | 387 base::DictionaryValue params; |
388 params.SetString("frameId", "f"); | 388 params.SetString("frameId", "f"); |
389 DeterminingLoadStateDevToolsClient client( | 389 DeterminingLoadStateDevToolsClient client( |
390 false, true, std::string(), ¶ms); | 390 false, true, std::string(), ¶ms); |
391 BrowserInfo browser_info; | 391 BrowserInfo browser_info; |
392 NavigationTracker tracker( | 392 NavigationTracker tracker( |
393 &client, NavigationTracker::kNotLoading, &browser_info); | 393 &client, NavigationTracker::kNotLoading, &browser_info); |
394 tracker.OnCommandSuccess(&client, "Page.navigate"); | 394 tracker.OnCommandSuccess(&client, "Page.navigate"); |
395 ASSERT_NO_FATAL_FAILURE(AssertPendingState(&tracker, "f", true)); | 395 ASSERT_NO_FATAL_FAILURE(AssertPendingState(&tracker, "f", true)); |
396 } | 396 } |
OLD | NEW |