OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <utility> |
6 | 7 |
7 #include "base/base64.h" | 8 #include "base/base64.h" |
8 #include "base/command_line.h" | 9 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "content/public/browser/devtools_agent_host.h" | 14 #include "content/public/browser/devtools_agent_host.h" |
14 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
(...skipping 24 matching lines...) Expand all Loading... |
40 public: | 41 public: |
41 DevToolsProtocolTest() | 42 DevToolsProtocolTest() |
42 : last_sent_id_(0), | 43 : last_sent_id_(0), |
43 waiting_for_command_result_id_(0), | 44 waiting_for_command_result_id_(0), |
44 in_dispatch_(false) { | 45 in_dispatch_(false) { |
45 } | 46 } |
46 | 47 |
47 protected: | 48 protected: |
48 void SendCommand(const std::string& method, | 49 void SendCommand(const std::string& method, |
49 scoped_ptr<base::DictionaryValue> params) { | 50 scoped_ptr<base::DictionaryValue> params) { |
50 SendCommand(method, params.Pass(), true); | 51 SendCommand(method, std::move(params), true); |
51 } | 52 } |
52 | 53 |
53 void SendCommand(const std::string& method, | 54 void SendCommand(const std::string& method, |
54 scoped_ptr<base::DictionaryValue> params, | 55 scoped_ptr<base::DictionaryValue> params, |
55 bool wait) { | 56 bool wait) { |
56 in_dispatch_ = true; | 57 in_dispatch_ = true; |
57 base::DictionaryValue command; | 58 base::DictionaryValue command; |
58 command.SetInteger(kIdParam, ++last_sent_id_); | 59 command.SetInteger(kIdParam, ++last_sent_id_); |
59 command.SetString(kMethodParam, method); | 60 command.SetString(kMethodParam, method); |
60 if (params) | 61 if (params) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 protected: | 161 protected: |
161 void SendKeyEvent(const std::string& type, | 162 void SendKeyEvent(const std::string& type, |
162 int modifier, | 163 int modifier, |
163 int windowsKeyCode, | 164 int windowsKeyCode, |
164 int nativeKeyCode) { | 165 int nativeKeyCode) { |
165 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 166 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
166 params->SetString("type", type); | 167 params->SetString("type", type); |
167 params->SetInteger("modifiers", modifier); | 168 params->SetInteger("modifiers", modifier); |
168 params->SetInteger("windowsVirtualKeyCode", windowsKeyCode); | 169 params->SetInteger("windowsVirtualKeyCode", windowsKeyCode); |
169 params->SetInteger("nativeVirtualKeyCode", nativeKeyCode); | 170 params->SetInteger("nativeVirtualKeyCode", nativeKeyCode); |
170 SendCommand("Input.dispatchKeyEvent", params.Pass()); | 171 SendCommand("Input.dispatchKeyEvent", std::move(params)); |
171 } | 172 } |
172 }; | 173 }; |
173 | 174 |
174 IN_PROC_BROWSER_TEST_F(SyntheticKeyEventTest, KeyEventSynthesizeKeyIdentifier) { | 175 IN_PROC_BROWSER_TEST_F(SyntheticKeyEventTest, KeyEventSynthesizeKeyIdentifier) { |
175 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 176 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
176 Attach(); | 177 Attach(); |
177 ASSERT_TRUE(content::ExecuteScript( | 178 ASSERT_TRUE(content::ExecuteScript( |
178 shell()->web_contents()->GetRenderViewHost(), | 179 shell()->web_contents()->GetRenderViewHost(), |
179 "function handleKeyEvent(event) {" | 180 "function handleKeyEvent(event) {" |
180 "domAutomationController.setAutomationId(0);" | 181 "domAutomationController.setAutomationId(0);" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, NavigationPreservesMessages) { | 337 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, NavigationPreservesMessages) { |
337 ASSERT_TRUE(embedded_test_server()->Start()); | 338 ASSERT_TRUE(embedded_test_server()->Start()); |
338 GURL test_url = embedded_test_server()->GetURL("/devtools/navigation.html"); | 339 GURL test_url = embedded_test_server()->GetURL("/devtools/navigation.html"); |
339 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 340 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
340 Attach(); | 341 Attach(); |
341 SendCommand("Page.enable", nullptr, false); | 342 SendCommand("Page.enable", nullptr, false); |
342 | 343 |
343 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 344 scoped_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
344 test_url = GetTestUrl("devtools", "navigation.html"); | 345 test_url = GetTestUrl("devtools", "navigation.html"); |
345 params->SetString("url", test_url.spec()); | 346 params->SetString("url", test_url.spec()); |
346 SendCommand("Page.navigate", params.Pass(), true); | 347 SendCommand("Page.navigate", std::move(params), true); |
347 | 348 |
348 bool enough_results = result_ids_.size() >= 2u; | 349 bool enough_results = result_ids_.size() >= 2u; |
349 EXPECT_TRUE(enough_results); | 350 EXPECT_TRUE(enough_results); |
350 if (enough_results) { | 351 if (enough_results) { |
351 EXPECT_EQ(1, result_ids_[0]); // Page.enable | 352 EXPECT_EQ(1, result_ids_[0]); // Page.enable |
352 EXPECT_EQ(2, result_ids_[1]); // Page.navigate | 353 EXPECT_EQ(2, result_ids_[1]); // Page.navigate |
353 } | 354 } |
354 | 355 |
355 enough_results = notifications_.size() >= 1u; | 356 enough_results = notifications_.size() >= 1u; |
356 EXPECT_TRUE(enough_results); | 357 EXPECT_TRUE(enough_results); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 GURL("javascript:x=1"), | 480 GURL("javascript:x=1"), |
480 nullptr, | 481 nullptr, |
481 gfx::Size()); | 482 gfx::Size()); |
482 WaitForLoadStop(window->web_contents()); | 483 WaitForLoadStop(window->web_contents()); |
483 Attach(); | 484 Attach(); |
484 SendCommand("Page.reload", nullptr, false); | 485 SendCommand("Page.reload", nullptr, false); |
485 // Should not crash at this point. | 486 // Should not crash at this point. |
486 } | 487 } |
487 | 488 |
488 } // namespace content | 489 } // namespace content |
OLD | NEW |