| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <vector> |
| 6 | 7 |
| 7 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 8 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" |
| 9 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 12 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/devtools/devtools_window_testing.h" | 16 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 15 #include "chrome/browser/extensions/extension_browsertest.h" | 17 #include "chrome/browser/extensions/extension_browsertest.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
| 18 #include "chrome/browser/notifications/notification.h" | 20 #include "chrome/browser/notifications/notification.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 #include "components/infobars/core/infobar.h" | 40 #include "components/infobars/core/infobar.h" |
| 39 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 40 #include "content/public/browser/page_navigator.h" | 42 #include "content/public/browser/page_navigator.h" |
| 41 #include "content/public/browser/render_frame_host.h" | 43 #include "content/public/browser/render_frame_host.h" |
| 42 #include "content/public/test/browser_test_utils.h" | 44 #include "content/public/test/browser_test_utils.h" |
| 43 #include "content/public/test/content_browser_test_utils.h" | 45 #include "content/public/test/content_browser_test_utils.h" |
| 44 #include "extensions/browser/extension_system.h" | 46 #include "extensions/browser/extension_system.h" |
| 45 #include "extensions/common/extension.h" | 47 #include "extensions/common/extension.h" |
| 46 #include "net/dns/mock_host_resolver.h" | 48 #include "net/dns/mock_host_resolver.h" |
| 47 #include "net/test/embedded_test_server/embedded_test_server.h" | 49 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 50 #include "testing/gmock/include/gmock/gmock.h" |
| 48 #include "testing/gtest/include/gtest/gtest.h" | 51 #include "testing/gtest/include/gtest/gtest.h" |
| 49 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" |
| 50 #include "ui/base/page_transition_types.h" | 53 #include "ui/base/page_transition_types.h" |
| 51 | 54 |
| 52 using content::WebContents; | 55 using content::WebContents; |
| 53 using task_management::browsertest_util::ColumnSpecifier; | 56 using task_management::browsertest_util::ColumnSpecifier; |
| 54 using task_management::browsertest_util::MatchAboutBlankTab; | 57 using task_management::browsertest_util::MatchAboutBlankTab; |
| 55 using task_management::browsertest_util::MatchAnyApp; | 58 using task_management::browsertest_util::MatchAnyApp; |
| 56 using task_management::browsertest_util::MatchAnyExtension; | 59 using task_management::browsertest_util::MatchAnyExtension; |
| 57 using task_management::browsertest_util::MatchAnySubframe; | 60 using task_management::browsertest_util::MatchAnySubframe; |
| 58 using task_management::browsertest_util::MatchAnyTab; | 61 using task_management::browsertest_util::MatchAnyTab; |
| 59 using task_management::browsertest_util::MatchAnyUtility; | 62 using task_management::browsertest_util::MatchAnyUtility; |
| 60 using task_management::browsertest_util::MatchApp; | 63 using task_management::browsertest_util::MatchApp; |
| 61 using task_management::browsertest_util::MatchExtension; | 64 using task_management::browsertest_util::MatchExtension; |
| 62 using task_management::browsertest_util::MatchSubframe; | 65 using task_management::browsertest_util::MatchSubframe; |
| 63 using task_management::browsertest_util::MatchTab; | 66 using task_management::browsertest_util::MatchTab; |
| 64 using task_management::browsertest_util::MatchUtility; | 67 using task_management::browsertest_util::MatchUtility; |
| 65 using task_management::browsertest_util::WaitForTaskManagerRows; | 68 using task_management::browsertest_util::WaitForTaskManagerRows; |
| 66 using task_management::browsertest_util::WaitForTaskManagerStatToExceed; | 69 using task_management::browsertest_util::WaitForTaskManagerStatToExceed; |
| 67 | 70 |
| 68 namespace { | 71 namespace { |
| 69 | 72 |
| 70 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); | 73 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); |
| 71 | 74 |
| 72 } // namespace | 75 } // namespace |
| 73 | 76 |
| 74 // TODO(nick): Move this file into task_management. https://crbug.com/606963 | |
| 75 class TaskManagerBrowserTest : public ExtensionBrowserTest { | 77 class TaskManagerBrowserTest : public ExtensionBrowserTest { |
| 76 public: | 78 public: |
| 77 TaskManagerBrowserTest() {} | 79 TaskManagerBrowserTest() {} |
| 78 ~TaskManagerBrowserTest() override {} | 80 ~TaskManagerBrowserTest() override {} |
| 79 | 81 |
| 80 task_management::TaskManagerTester* model() { return model_.get(); } | 82 task_management::TaskManagerTester* model() { return model_.get(); } |
| 81 | 83 |
| 82 void ShowTaskManager() { | 84 void ShowTaskManager() { |
| 83 // Show the task manager. This populates the model, and helps with debugging | 85 // Show the task manager. This populates the model, and helps with debugging |
| 84 // (you see the task manager). | 86 // (you see the task manager). |
| (...skipping 30 matching lines...) Expand all Loading... |
| 115 protected: | 117 protected: |
| 116 void SetUpCommandLine(base::CommandLine* command_line) override { | 118 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 117 ExtensionBrowserTest::SetUpCommandLine(command_line); | 119 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 118 | 120 |
| 119 // Do not launch device discovery process. | 121 // Do not launch device discovery process. |
| 120 command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); | 122 command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void TearDownOnMainThread() override { model_.reset(); } | 125 void TearDownOnMainThread() override { model_.reset(); } |
| 124 | 126 |
| 127 void SetUpOnMainThread() override { |
| 128 host_resolver()->AddRule("*", "127.0.0.1"); |
| 129 |
| 130 // Add content/test/data so we can use cross_site_iframe_factory.html |
| 131 base::FilePath test_data_dir; |
| 132 ASSERT_TRUE(base::PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)); |
| 133 embedded_test_server()->ServeFilesFromDirectory( |
| 134 test_data_dir.AppendASCII("content/test/data/")); |
| 135 ASSERT_TRUE(embedded_test_server()->Start()); |
| 136 content::SetupCrossSiteRedirector(embedded_test_server()); |
| 137 } |
| 138 |
| 125 private: | 139 private: |
| 126 std::unique_ptr<task_management::TaskManagerTester> model_; | 140 std::unique_ptr<task_management::TaskManagerTester> model_; |
| 127 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserTest); | 141 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserTest); |
| 128 }; | 142 }; |
| 129 | 143 |
| 130 class TaskManagerUtilityProcessBrowserTest : public TaskManagerBrowserTest { | 144 class TaskManagerUtilityProcessBrowserTest : public TaskManagerBrowserTest { |
| 131 public: | 145 public: |
| 132 TaskManagerUtilityProcessBrowserTest() {} | 146 TaskManagerUtilityProcessBrowserTest() {} |
| 133 | 147 |
| 134 protected: | 148 protected: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 236 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 223 | 237 |
| 224 // Tab should reappear in task manager upon reload. | 238 // Tab should reappear in task manager upon reload. |
| 225 chrome::Reload(browser(), CURRENT_TAB); | 239 chrome::Reload(browser(), CURRENT_TAB); |
| 226 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); | 240 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); |
| 227 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); | 241 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
| 228 } | 242 } |
| 229 | 243 |
| 230 // Regression test for http://crbug.com/444945. | 244 // Regression test for http://crbug.com/444945. |
| 231 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NavigateAwayFromHungRenderer) { | 245 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NavigateAwayFromHungRenderer) { |
| 232 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 233 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 234 ShowTaskManager(); | 246 ShowTaskManager(); |
| 235 | 247 |
| 236 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 248 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
| 237 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 249 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 238 | 250 |
| 239 GURL url1(embedded_test_server()->GetURL("/title2.html")); | 251 GURL url1(embedded_test_server()->GetURL("/title2.html")); |
| 240 GURL url3(embedded_test_server()->GetURL("a.com", "/iframe.html")); | 252 GURL url3(embedded_test_server()->GetURL("a.com", "/iframe.html")); |
| 241 | 253 |
| 242 // Open a new tab and make sure the task manager notices it. | 254 // Open a new tab and make sure the task manager notices it. |
| 243 AddTabAtIndex(0, url1, ui::PAGE_TRANSITION_TYPED); | 255 AddTabAtIndex(0, url1, ui::PAGE_TRANSITION_TYPED); |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 int app_tab = FindResourceIndex(MatchApp("Packaged App Test")); | 647 int app_tab = FindResourceIndex(MatchApp("Packaged App Test")); |
| 636 ASSERT_NE(-1, app_tab); | 648 ASSERT_NE(-1, app_tab); |
| 637 ASSERT_NE(-1, model()->GetTabId(app_tab)); | 649 ASSERT_NE(-1, model()->GetTabId(app_tab)); |
| 638 } | 650 } |
| 639 | 651 |
| 640 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabChanges) { | 652 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabChanges) { |
| 641 ShowTaskManager(); | 653 ShowTaskManager(); |
| 642 | 654 |
| 643 // The app under test acts on URLs whose host is "localhost", | 655 // The app under test acts on URLs whose host is "localhost", |
| 644 // so the URLs we navigate to must have host "localhost". | 656 // so the URLs we navigate to must have host "localhost". |
| 645 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 646 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 647 GURL::Replacements replace_host; | 657 GURL::Replacements replace_host; |
| 648 replace_host.SetHostStr("localhost"); | 658 replace_host.SetHostStr("localhost"); |
| 649 GURL base_url = embedded_test_server()->GetURL( | 659 GURL base_url = embedded_test_server()->GetURL( |
| 650 "/extensions/api_test/app_process/"); | 660 "/extensions/api_test/app_process/"); |
| 651 base_url = base_url.ReplaceComponents(replace_host); | 661 base_url = base_url.ReplaceComponents(replace_host); |
| 652 | 662 |
| 653 // Open a new tab to an app URL before the app is loaded. | 663 // Open a new tab to an app URL before the app is loaded. |
| 654 GURL url(base_url.Resolve("path1/empty.html")); | 664 GURL url(base_url.Resolve("path1/empty.html")); |
| 655 content::WindowedNotificationObserver observer( | 665 content::WindowedNotificationObserver observer( |
| 656 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 666 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); | 700 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
| 691 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); | 701 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
| 692 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("Unmodified"))); | 702 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("Unmodified"))); |
| 693 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); | 703 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); |
| 694 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); | 704 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); |
| 695 } | 705 } |
| 696 | 706 |
| 697 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabAfterReload) { | 707 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabAfterReload) { |
| 698 // The app under test acts on URLs whose host is "localhost", | 708 // The app under test acts on URLs whose host is "localhost", |
| 699 // so the URLs we navigate to must have host "localhost". | 709 // so the URLs we navigate to must have host "localhost". |
| 700 host_resolver()->AddRule("*", "127.0.0.1"); | 710 GURL base_url = embedded_test_server()->GetURL( |
| 701 ASSERT_TRUE(embedded_test_server()->Start()); | 711 "localhost", "/extensions/api_test/app_process/"); |
| 702 GURL::Replacements replace_host; | |
| 703 replace_host.SetHostStr("localhost"); | |
| 704 GURL base_url = | |
| 705 embedded_test_server()->GetURL("/extensions/api_test/app_process/"); | |
| 706 base_url = base_url.ReplaceComponents(replace_host); | |
| 707 | 712 |
| 708 // Open a new tab to an app URL before the app is loaded. | 713 // Open a new tab to an app URL before the app is loaded. |
| 709 GURL url(base_url.Resolve("path1/empty.html")); | 714 GURL url(base_url.Resolve("path1/empty.html")); |
| 710 content::WindowedNotificationObserver observer( | 715 content::WindowedNotificationObserver observer( |
| 711 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 716 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 712 content::NotificationService::AllSources()); | 717 content::NotificationService::AllSources()); |
| 713 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); | 718 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); |
| 714 observer.Wait(); | 719 observer.Wait(); |
| 715 | 720 |
| 716 // Load the hosted app and make sure it still starts with "Tab:", | 721 // Load the hosted app and make sure it still starts with "Tab:", |
| 717 // since it hasn't changed to an app process yet. | 722 // since it hasn't changed to an app process yet. |
| 718 ASSERT_TRUE(LoadExtension( | 723 ASSERT_TRUE(LoadExtension( |
| 719 test_data_dir_.AppendASCII("api_test").AppendASCII("app_process"))); | 724 test_data_dir_.AppendASCII("api_test").AppendASCII("app_process"))); |
| 720 | 725 |
| 721 // Now reload, which should transition this tab to being an App. | 726 // Now reload, which should transition this tab to being an App. |
| 722 ui_test_utils::NavigateToURL(browser(), url); | 727 ui_test_utils::NavigateToURL(browser(), url); |
| 723 | 728 |
| 724 ShowTaskManager(); | 729 ShowTaskManager(); |
| 725 | 730 |
| 726 // The TaskManager should show this as an "App: " | 731 // The TaskManager should show this as an "App: " |
| 727 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 732 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 728 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); | 733 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); |
| 729 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); | 734 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); |
| 730 } | 735 } |
| 731 | 736 |
| 732 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabBeforeReload) { | 737 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabBeforeReload) { |
| 733 // The app under test acts on URLs whose host is "localhost", | 738 // The app under test acts on URLs whose host is "localhost", |
| 734 // so the URLs we navigate to must have host "localhost". | 739 // so the URLs we navigate to must have host "localhost". |
| 735 host_resolver()->AddRule("*", "127.0.0.1"); | 740 GURL base_url = embedded_test_server()->GetURL( |
| 736 ASSERT_TRUE(embedded_test_server()->Start()); | 741 "localhost", "/extensions/api_test/app_process/"); |
| 737 GURL::Replacements replace_host; | |
| 738 replace_host.SetHostStr("localhost"); | |
| 739 GURL base_url = | |
| 740 embedded_test_server()->GetURL("/extensions/api_test/app_process/"); | |
| 741 base_url = base_url.ReplaceComponents(replace_host); | |
| 742 | 742 |
| 743 // Open a new tab to an app URL before the app is loaded. | 743 // Open a new tab to an app URL before the app is loaded. |
| 744 GURL url(base_url.Resolve("path1/empty.html")); | 744 GURL url(base_url.Resolve("path1/empty.html")); |
| 745 content::WindowedNotificationObserver observer( | 745 content::WindowedNotificationObserver observer( |
| 746 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 746 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 747 content::NotificationService::AllSources()); | 747 content::NotificationService::AllSources()); |
| 748 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); | 748 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); |
| 749 observer.Wait(); | 749 observer.Wait(); |
| 750 | 750 |
| 751 // Load the hosted app and make sure it still starts with "Tab:", | 751 // Load the hosted app and make sure it still starts with "Tab:", |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); | 907 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); |
| 908 ShowTaskManager(); // Task manager shown AFTER dev tools window. | 908 ShowTaskManager(); // Task manager shown AFTER dev tools window. |
| 909 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); | 909 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); |
| 910 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); | 910 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); |
| 911 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); | 911 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
| 912 } | 912 } |
| 913 | 913 |
| 914 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, KillSubframe) { | 914 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, KillSubframe) { |
| 915 ShowTaskManager(); | 915 ShowTaskManager(); |
| 916 | 916 |
| 917 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 918 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 919 content::SetupCrossSiteRedirector(embedded_test_server()); | |
| 920 | |
| 921 GURL main_url(embedded_test_server()->GetURL( | 917 GURL main_url(embedded_test_server()->GetURL( |
| 922 "/cross-site/a.com/iframe_cross_site.html")); | 918 "/cross-site/a.com/iframe_cross_site.html")); |
| 923 browser()->OpenURL(content::OpenURLParams(main_url, content::Referrer(), | 919 browser()->OpenURL(content::OpenURLParams(main_url, content::Referrer(), |
| 924 CURRENT_TAB, | 920 CURRENT_TAB, |
| 925 ui::PAGE_TRANSITION_TYPED, false)); | 921 ui::PAGE_TRANSITION_TYPED, false)); |
| 926 | 922 |
| 927 ASSERT_NO_FATAL_FAILURE( | 923 ASSERT_NO_FATAL_FAILURE( |
| 928 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | 924 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); |
| 929 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 925 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 930 | 926 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 ASSERT_NO_FATAL_FAILURE( | 961 ASSERT_NO_FATAL_FAILURE( |
| 966 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | 962 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); |
| 967 } | 963 } |
| 968 } | 964 } |
| 969 | 965 |
| 970 // Tests what happens when a tab navigates to a site (a.com) that it previously | 966 // Tests what happens when a tab navigates to a site (a.com) that it previously |
| 971 // has a cross-process subframe into (b.com). | 967 // has a cross-process subframe into (b.com). |
| 972 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, NavigateToSubframeProcess) { | 968 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, NavigateToSubframeProcess) { |
| 973 ShowTaskManager(); | 969 ShowTaskManager(); |
| 974 | 970 |
| 975 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 976 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 977 content::SetupCrossSiteRedirector(embedded_test_server()); | |
| 978 | |
| 979 // Navigate the tab to a page on a.com with cross-process subframes to | 971 // Navigate the tab to a page on a.com with cross-process subframes to |
| 980 // b.com and c.com. | 972 // b.com and c.com. |
| 981 GURL a_dotcom(embedded_test_server()->GetURL( | 973 GURL a_dotcom(embedded_test_server()->GetURL( |
| 982 "/cross-site/a.com/iframe_cross_site.html")); | 974 "/cross-site/a.com/iframe_cross_site.html")); |
| 983 browser()->OpenURL(content::OpenURLParams(a_dotcom, content::Referrer(), | 975 browser()->OpenURL(content::OpenURLParams(a_dotcom, content::Referrer(), |
| 984 CURRENT_TAB, | 976 CURRENT_TAB, |
| 985 ui::PAGE_TRANSITION_TYPED, false)); | 977 ui::PAGE_TRANSITION_TYPED, false)); |
| 986 | 978 |
| 987 ASSERT_NO_FATAL_FAILURE( | 979 ASSERT_NO_FATAL_FAILURE( |
| 988 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | 980 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1014 ShowTaskManager(); | 1006 ShowTaskManager(); |
| 1015 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); | 1007 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); |
| 1016 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 1008 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 1017 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 1009 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 1018 } | 1010 } |
| 1019 | 1011 |
| 1020 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, | 1012 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, |
| 1021 NavigateToSiteWithSubframeToOriginalSite) { | 1013 NavigateToSiteWithSubframeToOriginalSite) { |
| 1022 ShowTaskManager(); | 1014 ShowTaskManager(); |
| 1023 | 1015 |
| 1024 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 1025 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1026 content::SetupCrossSiteRedirector(embedded_test_server()); | |
| 1027 | |
| 1028 // Navigate to a page on b.com with a simple (same-site) iframe. | 1016 // Navigate to a page on b.com with a simple (same-site) iframe. |
| 1029 // This should not show any subframe resources in the task manager. | 1017 // This should not show any subframe resources in the task manager. |
| 1030 GURL b_dotcom( | 1018 GURL b_dotcom( |
| 1031 embedded_test_server()->GetURL("/cross-site/b.com/iframe.html")); | 1019 embedded_test_server()->GetURL("/cross-site/b.com/iframe.html")); |
| 1032 | 1020 |
| 1033 browser()->OpenURL(content::OpenURLParams(b_dotcom, content::Referrer(), | 1021 browser()->OpenURL(content::OpenURLParams(b_dotcom, content::Referrer(), |
| 1034 CURRENT_TAB, | 1022 CURRENT_TAB, |
| 1035 ui::PAGE_TRANSITION_TYPED, false)); | 1023 ui::PAGE_TRANSITION_TYPED, false)); |
| 1036 | 1024 |
| 1037 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); | 1025 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnySubframe())); | 1061 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnySubframe())); |
| 1074 } | 1062 } |
| 1075 } | 1063 } |
| 1076 | 1064 |
| 1077 // Tests what happens when a tab navigates a cross-frame iframe (to b.com) | 1065 // Tests what happens when a tab navigates a cross-frame iframe (to b.com) |
| 1078 // back to the site of the parent document (a.com). | 1066 // back to the site of the parent document (a.com). |
| 1079 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, | 1067 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, |
| 1080 CrossSiteIframeBecomesSameSite) { | 1068 CrossSiteIframeBecomesSameSite) { |
| 1081 ShowTaskManager(); | 1069 ShowTaskManager(); |
| 1082 | 1070 |
| 1083 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 1084 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1085 content::SetupCrossSiteRedirector(embedded_test_server()); | |
| 1086 | |
| 1087 // Navigate the tab to a page on a.com with cross-process subframes to | 1071 // Navigate the tab to a page on a.com with cross-process subframes to |
| 1088 // b.com and c.com. | 1072 // b.com and c.com. |
| 1089 GURL a_dotcom(embedded_test_server()->GetURL( | 1073 GURL a_dotcom(embedded_test_server()->GetURL( |
| 1090 "/cross-site/a.com/iframe_cross_site.html")); | 1074 "/cross-site/a.com/iframe_cross_site.html")); |
| 1091 browser()->OpenURL(content::OpenURLParams(a_dotcom, content::Referrer(), | 1075 browser()->OpenURL(content::OpenURLParams(a_dotcom, content::Referrer(), |
| 1092 CURRENT_TAB, | 1076 CURRENT_TAB, |
| 1093 ui::PAGE_TRANSITION_TYPED, false)); | 1077 ui::PAGE_TRANSITION_TYPED, false)); |
| 1094 | 1078 |
| 1095 ASSERT_NO_FATAL_FAILURE( | 1079 ASSERT_NO_FATAL_FAILURE( |
| 1096 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | 1080 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); | 1122 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); |
| 1139 } | 1123 } |
| 1140 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac"))); | 1124 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac"))); |
| 1141 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 1125 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 1142 } | 1126 } |
| 1143 | 1127 |
| 1144 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, | 1128 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, |
| 1145 LeavePageWithCrossSiteIframes) { | 1129 LeavePageWithCrossSiteIframes) { |
| 1146 ShowTaskManager(); | 1130 ShowTaskManager(); |
| 1147 | 1131 |
| 1148 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 1149 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1150 content::SetupCrossSiteRedirector(embedded_test_server()); | |
| 1151 | |
| 1152 // Navigate the tab to a page on a.com with cross-process subframes. | 1132 // Navigate the tab to a page on a.com with cross-process subframes. |
| 1153 GURL a_dotcom_with_iframes(embedded_test_server()->GetURL( | 1133 GURL a_dotcom_with_iframes(embedded_test_server()->GetURL( |
| 1154 "/cross-site/a.com/iframe_cross_site.html")); | 1134 "/cross-site/a.com/iframe_cross_site.html")); |
| 1155 browser()->OpenURL(content::OpenURLParams(a_dotcom_with_iframes, | 1135 browser()->OpenURL(content::OpenURLParams(a_dotcom_with_iframes, |
| 1156 content::Referrer(), CURRENT_TAB, | 1136 content::Referrer(), CURRENT_TAB, |
| 1157 ui::PAGE_TRANSITION_TYPED, false)); | 1137 ui::PAGE_TRANSITION_TYPED, false)); |
| 1158 | 1138 |
| 1159 ASSERT_NO_FATAL_FAILURE( | 1139 ASSERT_NO_FATAL_FAILURE( |
| 1160 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | 1140 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); |
| 1161 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 1141 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1181 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); | 1161 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); |
| 1182 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 1162 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 1183 | 1163 |
| 1184 HideTaskManager(); | 1164 HideTaskManager(); |
| 1185 ShowTaskManager(); | 1165 ShowTaskManager(); |
| 1186 | 1166 |
| 1187 ASSERT_NO_FATAL_FAILURE( | 1167 ASSERT_NO_FATAL_FAILURE( |
| 1188 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); | 1168 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); |
| 1189 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 1169 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 1190 } | 1170 } |
| 1171 |
| 1172 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, OrderingOfDependentRows) { |
| 1173 #if defined(OS_MACOSX) |
| 1174 // The ordering under test here is not implemented in the legacy task manager. |
| 1175 if (!task_management::TaskManagerInterface::IsNewTaskManagerEnabled()) |
| 1176 return; |
| 1177 #endif |
| 1178 |
| 1179 ShowTaskManager(); |
| 1180 |
| 1181 GURL a_with_frames(embedded_test_server()->GetURL( |
| 1182 "a.com", "/cross_site_iframe_factory.html?a(b,b,c(d,a,b,c))")); |
| 1183 browser()->OpenURL(content::OpenURLParams(a_with_frames, content::Referrer(), |
| 1184 CURRENT_TAB, |
| 1185 ui::PAGE_TRANSITION_TYPED, false)); |
| 1186 |
| 1187 if (ShouldExpectSubframes()) { |
| 1188 ASSERT_NO_FATAL_FAILURE( |
| 1189 WaitForTaskManagerRows(1, MatchSubframe("http://b.com/"))); |
| 1190 ASSERT_NO_FATAL_FAILURE( |
| 1191 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); |
| 1192 ASSERT_NO_FATAL_FAILURE( |
| 1193 WaitForTaskManagerRows(1, MatchSubframe("http://d.com/"))); |
| 1194 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnySubframe())); |
| 1195 } |
| 1196 ASSERT_NO_FATAL_FAILURE( |
| 1197 WaitForTaskManagerRows(1, MatchTab("Cross-site iframe factory"))); |
| 1198 |
| 1199 int index = FindResourceIndex(MatchTab("Cross-site iframe factory")); |
| 1200 std::vector<int> subframe_offsets; |
| 1201 if (ShouldExpectSubframes()) { |
| 1202 subframe_offsets = { |
| 1203 FindResourceIndex(MatchSubframe("http://b.com/")) - index, |
| 1204 FindResourceIndex(MatchSubframe("http://c.com/")) - index, |
| 1205 FindResourceIndex(MatchSubframe("http://d.com/")) - index}; |
| 1206 EXPECT_THAT(subframe_offsets, testing::UnorderedElementsAre(1, 2, 3)); |
| 1207 } |
| 1208 |
| 1209 // Opening a new tab should appear below the existing tab. |
| 1210 GURL other_tab_url(embedded_test_server()->GetURL( |
| 1211 "d.com", "/cross_site_iframe_factory.html?d(a(c(b)))")); |
| 1212 browser()->OpenURL(content::OpenURLParams(other_tab_url, content::Referrer(), |
| 1213 NEW_FOREGROUND_TAB, |
| 1214 ui::PAGE_TRANSITION_TYPED, false)); |
| 1215 |
| 1216 ASSERT_NO_FATAL_FAILURE( |
| 1217 WaitForTaskManagerRows(2, MatchTab("Cross-site iframe factory"))); |
| 1218 if (ShouldExpectSubframes()) { |
| 1219 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(6, MatchAnySubframe())); |
| 1220 ASSERT_NO_FATAL_FAILURE( |
| 1221 WaitForTaskManagerRows(2, MatchSubframe("http://b.com/"))); |
| 1222 ASSERT_NO_FATAL_FAILURE( |
| 1223 WaitForTaskManagerRows(2, MatchSubframe("http://c.com/"))); |
| 1224 ASSERT_NO_FATAL_FAILURE( |
| 1225 WaitForTaskManagerRows(1, MatchSubframe("http://d.com/"))); |
| 1226 ASSERT_NO_FATAL_FAILURE( |
| 1227 WaitForTaskManagerRows(1, MatchSubframe("http://a.com/"))); |
| 1228 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(6, MatchAnySubframe())); |
| 1229 } else { |
| 1230 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 1231 } |
| 1232 |
| 1233 // The first tab may have moved in absolute position in the list (due to |
| 1234 // random e.g. zygote or gpu activity). |
| 1235 index = FindResourceIndex(MatchTab("Cross-site iframe factory")); |
| 1236 |
| 1237 // Tab 2's rows should immediately follow tab 1. |
| 1238 int tab2_start = index + static_cast<int>(subframe_offsets.size()) + 1; |
| 1239 int tab2_count = ShouldExpectSubframes() ? 4 : 1; |
| 1240 ASSERT_LE(tab2_start + tab2_count, model()->GetRowCount()); |
| 1241 |
| 1242 EXPECT_EQ("Tab: Cross-site iframe factory", |
| 1243 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start))); |
| 1244 if (ShouldExpectSubframes()) { |
| 1245 // The relative ordering of tab1's subframe rows shall be the same as what |
| 1246 // was observed previously. |
| 1247 ASSERT_EQ(subframe_offsets[0], |
| 1248 FindResourceIndex(MatchSubframe("http://b.com/")) - index); |
| 1249 ASSERT_EQ(subframe_offsets[1], |
| 1250 FindResourceIndex(MatchSubframe("http://c.com/")) - index); |
| 1251 ASSERT_EQ(subframe_offsets[2], |
| 1252 FindResourceIndex(MatchSubframe("http://d.com/")) - index); |
| 1253 |
| 1254 // Because the subframes for tab 2 are nested, their order is deterministic. |
| 1255 EXPECT_EQ("Subframe: http://a.com/", |
| 1256 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 1))); |
| 1257 EXPECT_EQ("Subframe: http://c.com/", |
| 1258 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 2))); |
| 1259 EXPECT_EQ("Subframe: http://b.com/", |
| 1260 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 3))); |
| 1261 } |
| 1262 } |
| OLD | NEW |