| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 SendCommand("Page.reload", nullptr, false); | 645 SendCommand("Page.reload", nullptr, false); |
| 646 // Should not crash at this point. | 646 // Should not crash at this point. |
| 647 } | 647 } |
| 648 | 648 |
| 649 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, EvaluateInBlankPage) { | 649 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, EvaluateInBlankPage) { |
| 650 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 650 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| 651 Attach(); | 651 Attach(); |
| 652 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 652 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 653 params->SetString("expression", "window"); | 653 params->SetString("expression", "window"); |
| 654 SendCommand("Runtime.evaluate", std::move(params), true); | 654 SendCommand("Runtime.evaluate", std::move(params), true); |
| 655 bool wasThrown = true; | 655 EXPECT_FALSE(result_->HasKey("exceptionDetails")); |
| 656 EXPECT_TRUE(result_->GetBoolean("wasThrown", &wasThrown)); | |
| 657 EXPECT_FALSE(wasThrown); | |
| 658 } | 656 } |
| 659 | 657 |
| 660 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, | 658 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, |
| 661 EvaluateInBlankPageAfterNavigation) { | 659 EvaluateInBlankPageAfterNavigation) { |
| 662 ASSERT_TRUE(embedded_test_server()->Start()); | 660 ASSERT_TRUE(embedded_test_server()->Start()); |
| 663 GURL test_url = embedded_test_server()->GetURL("/devtools/navigation.html"); | 661 GURL test_url = embedded_test_server()->GetURL("/devtools/navigation.html"); |
| 664 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); | 662 NavigateToURLBlockUntilNavigationsComplete(shell(), test_url, 1); |
| 665 Attach(); | 663 Attach(); |
| 666 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 664 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| 667 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 665 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 668 params->SetString("expression", "window"); | 666 params->SetString("expression", "window"); |
| 669 SendCommand("Runtime.evaluate", std::move(params), true); | 667 SendCommand("Runtime.evaluate", std::move(params), true); |
| 670 bool wasThrown = true; | 668 EXPECT_FALSE(result_->HasKey("exceptionDetails")); |
| 671 EXPECT_TRUE(result_->GetBoolean("wasThrown", &wasThrown)); | |
| 672 EXPECT_FALSE(wasThrown); | |
| 673 } | 669 } |
| 674 | 670 |
| 675 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, JavaScriptDialogNotifications) { | 671 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, JavaScriptDialogNotifications) { |
| 676 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 672 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| 677 Attach(); | 673 Attach(); |
| 678 TestJavaScriptDialogManager dialog_manager; | 674 TestJavaScriptDialogManager dialog_manager; |
| 679 shell()->web_contents()->SetDelegate(&dialog_manager); | 675 shell()->web_contents()->SetDelegate(&dialog_manager); |
| 680 SendCommand("Page.enable", nullptr, true); | 676 SendCommand("Page.enable", nullptr, true); |
| 681 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 677 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
| 682 params->SetString("expression", "alert('alert')"); | 678 params->SetString("expression", "alert('alert')"); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 params->SetString("policy", "advance"); | 877 params->SetString("policy", "advance"); |
| 882 params->SetInteger("budget", 1000); | 878 params->SetInteger("budget", 1000); |
| 883 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 879 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
| 884 | 880 |
| 885 WaitForNotification("Emulation.virtualTimeBudgetExpired"); | 881 WaitForNotification("Emulation.virtualTimeBudgetExpired"); |
| 886 | 882 |
| 887 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); | 883 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); |
| 888 } | 884 } |
| 889 | 885 |
| 890 } // namespace content | 886 } // namespace content |
| OLD | NEW |