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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 TestJavaScriptDialogManager dialog_manager; | 678 TestJavaScriptDialogManager dialog_manager; |
679 shell()->web_contents()->SetDelegate(&dialog_manager); | 679 shell()->web_contents()->SetDelegate(&dialog_manager); |
680 SendCommand("Page.enable", nullptr, true); | 680 SendCommand("Page.enable", nullptr, true); |
681 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 681 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
682 params->SetString("expression", "alert('alert')"); | 682 params->SetString("expression", "alert('alert')"); |
683 SendCommand("Runtime.evaluate", std::move(params), false); | 683 SendCommand("Runtime.evaluate", std::move(params), false); |
684 WaitForNotification("Page.javascriptDialogOpening"); | 684 WaitForNotification("Page.javascriptDialogOpening"); |
685 dialog_manager.Handle(); | 685 dialog_manager.Handle(); |
686 } | 686 } |
687 | 687 |
688 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, BrowserCreateTarget) { | 688 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, BrowserCreateAndCloseTarget) { |
689 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 689 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
690 Attach(); | 690 Attach(); |
691 EXPECT_EQ(1u, shell()->windows().size()); | 691 EXPECT_EQ(1u, shell()->windows().size()); |
692 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 692 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
693 params->SetString("url", "about:blank"); | 693 params->SetString("url", "about:blank"); |
694 SendCommand("Browser.createTarget", std::move(params), true); | 694 SendCommand("Browser.createTarget", std::move(params), true); |
| 695 std::string target_id; |
| 696 EXPECT_TRUE(result_->GetString("targetId", &target_id)); |
695 EXPECT_EQ(2u, shell()->windows().size()); | 697 EXPECT_EQ(2u, shell()->windows().size()); |
| 698 |
| 699 // TODO(eseckler): Since the RenderView is closed asynchronously, we currently |
| 700 // don't verify that the command actually closes the shell. |
| 701 bool success; |
| 702 params.reset(new base::DictionaryValue()); |
| 703 params->SetString("targetId", target_id); |
| 704 SendCommand("Browser.closeTarget", std::move(params), true); |
| 705 EXPECT_TRUE(result_->GetBoolean("success", &success)); |
| 706 EXPECT_TRUE(success); |
| 707 } |
| 708 |
| 709 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, BrowserGetTargets) { |
| 710 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
| 711 Attach(); |
| 712 SendCommand("Browser.getTargets", nullptr, true); |
| 713 base::ListValue* target_infos; |
| 714 EXPECT_TRUE(result_->GetList("targetInfo", &target_infos)); |
| 715 EXPECT_EQ(1u, target_infos->GetSize()); |
| 716 base::DictionaryValue* target_info; |
| 717 EXPECT_TRUE(target_infos->GetDictionary(0u, &target_info)); |
| 718 std::string target_id, type, title, url; |
| 719 EXPECT_TRUE(target_info->GetString("targetId", &target_id)); |
| 720 EXPECT_TRUE(target_info->GetString("type", &type)); |
| 721 EXPECT_TRUE(target_info->GetString("title", &title)); |
| 722 EXPECT_TRUE(target_info->GetString("url", &url)); |
| 723 EXPECT_EQ(type, "web_contents"); |
| 724 EXPECT_EQ(title, "about:blank"); |
| 725 EXPECT_EQ(url, "about:blank"); |
696 } | 726 } |
697 | 727 |
698 namespace { | 728 namespace { |
699 class NavigationFinishedObserver : public content::WebContentsObserver { | 729 class NavigationFinishedObserver : public content::WebContentsObserver { |
700 public: | 730 public: |
701 explicit NavigationFinishedObserver(WebContents* web_contents) | 731 explicit NavigationFinishedObserver(WebContents* web_contents) |
702 : WebContentsObserver(web_contents), | 732 : WebContentsObserver(web_contents), |
703 num_finished_(0), | 733 num_finished_(0), |
704 num_to_wait_for_(0) {} | 734 num_to_wait_for_(0) {} |
705 | 735 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 params->SetString("policy", "advance"); | 911 params->SetString("policy", "advance"); |
882 params->SetInteger("budget", 1000); | 912 params->SetInteger("budget", 1000); |
883 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 913 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
884 | 914 |
885 WaitForNotification("Emulation.virtualTimeBudgetExpired"); | 915 WaitForNotification("Emulation.virtualTimeBudgetExpired"); |
886 | 916 |
887 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); | 917 EXPECT_THAT(console_messages_, ElementsAre("before", "done", "after")); |
888 } | 918 } |
889 | 919 |
890 } // namespace content | 920 } // namespace content |
OLD | NEW |