| 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 #include <utility> |
| 7 | 7 |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 class DevToolsProtocolTest : public ContentBrowserTest, | 134 class DevToolsProtocolTest : public ContentBrowserTest, |
| 135 public DevToolsAgentHostClient, | 135 public DevToolsAgentHostClient, |
| 136 public WebContentsDelegate { | 136 public WebContentsDelegate { |
| 137 public: | 137 public: |
| 138 DevToolsProtocolTest() | 138 DevToolsProtocolTest() |
| 139 : last_sent_id_(0), | 139 : last_sent_id_(0), |
| 140 waiting_for_command_result_id_(0), | 140 waiting_for_command_result_id_(0), |
| 141 in_dispatch_(false), | 141 in_dispatch_(false), |
| 142 last_shown_certificate_(nullptr), | 142 agent_host_can_close_(false) {} |
| 143 ok_cert_(nullptr), | |
| 144 expired_cert_(nullptr) {} | |
| 145 | 143 |
| 146 void SetUpOnMainThread() override { | 144 void SetUpOnMainThread() override { |
| 147 ok_cert_ = | 145 ok_cert_ = |
| 148 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); | 146 net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); |
| 149 expired_cert_ = net::ImportCertFromFile(net::GetTestCertsDirectory(), | 147 expired_cert_ = net::ImportCertFromFile(net::GetTestCertsDirectory(), |
| 150 "expired_cert.pem"); | 148 "expired_cert.pem"); |
| 151 } | 149 } |
| 152 | 150 |
| 153 protected: | 151 protected: |
| 154 // WebContentsDelegate method: | 152 // WebContentsDelegate method: |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 const scoped_refptr<net::X509Certificate>& last_shown_certificate() { | 334 const scoped_refptr<net::X509Certificate>& last_shown_certificate() { |
| 337 return last_shown_certificate_; | 335 return last_shown_certificate_; |
| 338 } | 336 } |
| 339 | 337 |
| 340 const scoped_refptr<net::X509Certificate>& ok_cert() { return ok_cert_; } | 338 const scoped_refptr<net::X509Certificate>& ok_cert() { return ok_cert_; } |
| 341 | 339 |
| 342 const scoped_refptr<net::X509Certificate>& expired_cert() { | 340 const scoped_refptr<net::X509Certificate>& expired_cert() { |
| 343 return expired_cert_; | 341 return expired_cert_; |
| 344 } | 342 } |
| 345 | 343 |
| 344 void set_agent_host_can_close() { agent_host_can_close_ = true; } |
| 345 |
| 346 std::unique_ptr<base::DictionaryValue> result_; | 346 std::unique_ptr<base::DictionaryValue> result_; |
| 347 scoped_refptr<DevToolsAgentHost> agent_host_; | 347 scoped_refptr<DevToolsAgentHost> agent_host_; |
| 348 int last_sent_id_; | 348 int last_sent_id_; |
| 349 std::vector<int> result_ids_; | 349 std::vector<int> result_ids_; |
| 350 std::vector<std::string> notifications_; | 350 std::vector<std::string> notifications_; |
| 351 std::vector<std::string> console_messages_; | 351 std::vector<std::string> console_messages_; |
| 352 std::vector<std::unique_ptr<base::DictionaryValue>> notification_params_; | 352 std::vector<std::unique_ptr<base::DictionaryValue>> notification_params_; |
| 353 | 353 |
| 354 private: | 354 private: |
| 355 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, | 355 void DispatchProtocolMessage(DevToolsAgentHost* agent_host, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 382 if (waiting_for_notification_ == notification) { | 382 if (waiting_for_notification_ == notification) { |
| 383 waiting_for_notification_ = std::string(); | 383 waiting_for_notification_ = std::string(); |
| 384 waiting_for_notification_params_ = base::WrapUnique( | 384 waiting_for_notification_params_ = base::WrapUnique( |
| 385 notification_params_[notification_params_.size() - 1]->DeepCopy()); | 385 notification_params_[notification_params_.size() - 1]->DeepCopy()); |
| 386 base::MessageLoop::current()->QuitNow(); | 386 base::MessageLoop::current()->QuitNow(); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override { | 391 void AgentHostClosed(DevToolsAgentHost* agent_host, bool replaced) override { |
| 392 DCHECK(false); | 392 if (!agent_host_can_close_) |
| 393 NOTREACHED(); |
| 393 } | 394 } |
| 394 | 395 |
| 395 std::string waiting_for_notification_; | 396 std::string waiting_for_notification_; |
| 396 std::unique_ptr<base::DictionaryValue> waiting_for_notification_params_; | 397 std::unique_ptr<base::DictionaryValue> waiting_for_notification_params_; |
| 397 int waiting_for_command_result_id_; | 398 int waiting_for_command_result_id_; |
| 398 bool in_dispatch_; | 399 bool in_dispatch_; |
| 399 scoped_refptr<net::X509Certificate> last_shown_certificate_; | 400 scoped_refptr<net::X509Certificate> last_shown_certificate_; |
| 400 scoped_refptr<net::X509Certificate> ok_cert_; | 401 scoped_refptr<net::X509Certificate> ok_cert_; |
| 401 scoped_refptr<net::X509Certificate> expired_cert_; | 402 scoped_refptr<net::X509Certificate> expired_cert_; |
| 403 bool agent_host_can_close_; |
| 402 }; | 404 }; |
| 403 | 405 |
| 404 class TestInterstitialDelegate : public InterstitialPageDelegate { | 406 class TestInterstitialDelegate : public InterstitialPageDelegate { |
| 405 private: | 407 private: |
| 406 // InterstitialPageDelegate: | 408 // InterstitialPageDelegate: |
| 407 std::string GetHTMLContents() override { return "<p>Interstitial</p>"; } | 409 std::string GetHTMLContents() override { return "<p>Interstitial</p>"; } |
| 408 }; | 410 }; |
| 409 | 411 |
| 410 class SyntheticKeyEventTest : public DevToolsProtocolTest { | 412 class SyntheticKeyEventTest : public DevToolsProtocolTest { |
| 411 protected: | 413 protected: |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 // Ensure that the A.com process is still alive by executing a script in the | 1003 // Ensure that the A.com process is still alive by executing a script in the |
| 1002 // original tab. | 1004 // original tab. |
| 1003 success = false; | 1005 success = false; |
| 1004 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell(), | 1006 EXPECT_TRUE(ExecuteScriptAndExtractBool(shell(), |
| 1005 "window.domAutomationController.send(" | 1007 "window.domAutomationController.send(" |
| 1006 " !!window.open('', 'foo'));", | 1008 " !!window.open('', 'foo'));", |
| 1007 &success)); | 1009 &success)); |
| 1008 EXPECT_TRUE(success); | 1010 EXPECT_TRUE(success); |
| 1009 } | 1011 } |
| 1010 | 1012 |
| 1011 // CrashTab() works differently on Windows, leading to RFH removal before | 1013 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, DoubleCrash) { |
| 1012 // RenderProcessGone is called. TODO(dgozman): figure out the problem. | 1014 set_agent_host_can_close(); |
| 1013 #if defined(OS_WIN) | |
| 1014 #define MAYBE_DoubleCrash DISABLED_DoubleCrash | |
| 1015 #else | |
| 1016 #define MAYBE_DoubleCrash DoubleCrash | |
| 1017 #endif | |
| 1018 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, MAYBE_DoubleCrash) { | |
| 1019 ASSERT_TRUE(embedded_test_server()->Start()); | 1015 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1020 GURL test_url = embedded_test_server()->GetURL("/devtools/navigation.html"); | 1016 GURL test_url = embedded_test_server()->GetURL("/devtools/navigation.html"); |
| 1021 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 1017 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| 1022 Attach(); | 1018 Attach(); |
| 1023 SendCommand("ServiceWorker.enable", nullptr); | 1019 SendCommand("ServiceWorker.enable", nullptr); |
| 1024 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 1020 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 1025 CrashTab(shell()->web_contents()); | 1021 CrashTab(shell()->web_contents()); |
| 1026 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 1022 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 1027 CrashTab(shell()->web_contents()); | 1023 CrashTab(shell()->web_contents()); |
| 1028 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 1024 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 EXPECT_EQ("polyglottal", value); | 1641 EXPECT_EQ("polyglottal", value); |
| 1646 found++; | 1642 found++; |
| 1647 } else { | 1643 } else { |
| 1648 FAIL(); | 1644 FAIL(); |
| 1649 } | 1645 } |
| 1650 } | 1646 } |
| 1651 EXPECT_EQ(2u, found); | 1647 EXPECT_EQ(2u, found); |
| 1652 } | 1648 } |
| 1653 | 1649 |
| 1654 } // namespace content | 1650 } // namespace content |
| OLD | NEW |