Chromium Code Reviews| 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 #include <vector> |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 #include "chrome/test/base/ui_test_utils.h" | 36 #include "chrome/test/base/ui_test_utils.h" |
| 37 #include "components/infobars/core/confirm_infobar_delegate.h" | 37 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 38 #include "components/infobars/core/infobar.h" | 38 #include "components/infobars/core/infobar.h" |
| 39 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
| 40 #include "content/public/browser/page_navigator.h" | 40 #include "content/public/browser/page_navigator.h" |
| 41 #include "content/public/browser/render_frame_host.h" | 41 #include "content/public/browser/render_frame_host.h" |
| 42 #include "content/public/common/content_features.h" | 42 #include "content/public/common/content_features.h" |
| 43 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 44 #include "content/public/test/browser_test_utils.h" | 44 #include "content/public/test/browser_test_utils.h" |
| 45 #include "content/public/test/content_browser_test_utils.h" | 45 #include "content/public/test/content_browser_test_utils.h" |
| 46 #include "content/public/test/test_navigation_observer.h" | |
| 46 #include "extensions/browser/extension_system.h" | 47 #include "extensions/browser/extension_system.h" |
| 47 #include "extensions/common/extension.h" | 48 #include "extensions/common/extension.h" |
| 48 #include "net/dns/mock_host_resolver.h" | 49 #include "net/dns/mock_host_resolver.h" |
| 49 #include "net/test/embedded_test_server/embedded_test_server.h" | 50 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 50 #include "testing/gmock/include/gmock/gmock.h" | 51 #include "testing/gmock/include/gmock/gmock.h" |
| 51 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
| 52 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
| 53 #include "ui/base/page_transition_types.h" | 54 #include "ui/base/page_transition_types.h" |
| 55 #include "url/gurl.h" | |
| 54 | 56 |
| 55 using content::WebContents; | 57 using content::WebContents; |
| 56 using task_manager::browsertest_util::ColumnSpecifier; | 58 using task_manager::browsertest_util::ColumnSpecifier; |
| 57 using task_manager::browsertest_util::MatchAboutBlankTab; | 59 using task_manager::browsertest_util::MatchAboutBlankTab; |
| 58 using task_manager::browsertest_util::MatchAnyApp; | 60 using task_manager::browsertest_util::MatchAnyApp; |
| 59 using task_manager::browsertest_util::MatchAnyExtension; | 61 using task_manager::browsertest_util::MatchAnyExtension; |
| 60 using task_manager::browsertest_util::MatchAnySubframe; | 62 using task_manager::browsertest_util::MatchAnySubframe; |
| 61 using task_manager::browsertest_util::MatchAnyTab; | 63 using task_manager::browsertest_util::MatchAnyTab; |
| 62 using task_manager::browsertest_util::MatchAnyUtility; | 64 using task_manager::browsertest_util::MatchAnyUtility; |
| 63 using task_manager::browsertest_util::MatchApp; | 65 using task_manager::browsertest_util::MatchApp; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 } | 209 } |
| 208 | 210 |
| 209 bool ShouldExpectSubframes() { | 211 bool ShouldExpectSubframes() { |
| 210 return content::AreAllSitesIsolatedForTesting(); | 212 return content::AreAllSitesIsolatedForTesting(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 private: | 215 private: |
| 214 DISALLOW_COPY_AND_ASSIGN(TaskManagerOOPIFBrowserTest); | 216 DISALLOW_COPY_AND_ASSIGN(TaskManagerOOPIFBrowserTest); |
| 215 }; | 217 }; |
| 216 | 218 |
| 217 INSTANTIATE_TEST_CASE_P(, TaskManagerOOPIFBrowserTest, ::testing::Bool()); | 219 INSTANTIATE_TEST_CASE_P(DefaultIsolation, |
| 220 TaskManagerOOPIFBrowserTest, | |
| 221 ::testing::Values(false)); | |
| 222 INSTANTIATE_TEST_CASE_P(SitePerProcess, | |
| 223 TaskManagerOOPIFBrowserTest, | |
| 224 ::testing::Values(true)); | |
| 218 | 225 |
| 219 #if defined(OS_MACOSX) || defined(OS_LINUX) | 226 #if defined(OS_MACOSX) || defined(OS_LINUX) |
| 220 #define MAYBE_ShutdownWhileOpen DISABLED_ShutdownWhileOpen | 227 #define MAYBE_ShutdownWhileOpen DISABLED_ShutdownWhileOpen |
| 221 #else | 228 #else |
| 222 #define MAYBE_ShutdownWhileOpen ShutdownWhileOpen | 229 #define MAYBE_ShutdownWhileOpen ShutdownWhileOpen |
| 223 #endif | 230 #endif |
| 224 | 231 |
| 225 // Regression test for http://crbug.com/13361 | 232 // Regression test for http://crbug.com/13361 |
| 226 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ShutdownWhileOpen) { | 233 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ShutdownWhileOpen) { |
| 227 ShowTaskManager(); | 234 ShowTaskManager(); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); | 789 DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); |
| 783 ShowTaskManager(); // Task manager shown AFTER dev tools window. | 790 ShowTaskManager(); // Task manager shown AFTER dev tools window. |
| 784 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); | 791 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); |
| 785 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); | 792 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); |
| 786 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); | 793 DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); |
| 787 } | 794 } |
| 788 | 795 |
| 789 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, KillSubframe) { | 796 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, KillSubframe) { |
| 790 ShowTaskManager(); | 797 ShowTaskManager(); |
| 791 | 798 |
| 799 content::TestNavigationObserver navigation_observer( | |
| 800 browser()->tab_strip_model()->GetActiveWebContents()); | |
| 792 GURL main_url(embedded_test_server()->GetURL( | 801 GURL main_url(embedded_test_server()->GetURL( |
| 793 "/cross-site/a.com/iframe_cross_site.html")); | 802 "/cross-site/a.com/iframe_cross_site.html")); |
| 794 browser()->OpenURL(content::OpenURLParams(main_url, content::Referrer(), | 803 browser()->OpenURL(content::OpenURLParams(main_url, content::Referrer(), |
| 795 WindowOpenDisposition::CURRENT_TAB, | 804 WindowOpenDisposition::CURRENT_TAB, |
| 796 ui::PAGE_TRANSITION_TYPED, false)); | 805 ui::PAGE_TRANSITION_TYPED, false)); |
| 797 | 806 |
| 798 ASSERT_NO_FATAL_FAILURE( | 807 ASSERT_NO_FATAL_FAILURE( |
| 799 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | 808 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); |
| 800 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 809 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 801 | 810 |
| 811 GURL b_url; | |
| 802 if (!ShouldExpectSubframes()) { | 812 if (!ShouldExpectSubframes()) { |
| 803 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 813 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 804 } else { | 814 } else { |
| 805 ASSERT_NO_FATAL_FAILURE( | 815 ASSERT_NO_FATAL_FAILURE( |
| 806 WaitForTaskManagerRows(1, MatchSubframe("http://b.com/"))); | 816 WaitForTaskManagerRows(1, MatchSubframe("http://b.com/"))); |
| 807 ASSERT_NO_FATAL_FAILURE( | 817 ASSERT_NO_FATAL_FAILURE( |
| 808 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); | 818 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); |
| 809 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnySubframe())); | 819 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnySubframe())); |
| 810 int subframe_b = FindResourceIndex(MatchSubframe("http://b.com/")); | 820 int subframe_b = FindResourceIndex(MatchSubframe("http://b.com/")); |
| 811 ASSERT_NE(-1, subframe_b); | 821 ASSERT_NE(-1, subframe_b); |
| 812 ASSERT_NE(-1, model()->GetTabId(subframe_b)); | 822 ASSERT_NE(-1, model()->GetTabId(subframe_b)); |
| 813 | 823 |
| 824 // Remember |b_url| to be able to later renavigate to the same URL without | |
| 825 // doing any process swaps (we want to avoid redirects that would happen | |
| 826 // when going through /cross-site/foo.com/..., because | |
| 827 // https://crbug.com/642958 wouldn't repro in presence of process swaps). | |
| 828 navigation_observer.Wait(); | |
| 829 b_url = browser() | |
| 830 ->tab_strip_model() | |
| 831 ->GetActiveWebContents() | |
| 832 ->GetAllFrames()[1] | |
| 833 ->GetLastCommittedURL(); | |
| 834 ASSERT_EQ(b_url.host(), "b.com"); // Sanity check of test code / setup. | |
| 835 | |
| 814 model()->Kill(subframe_b); | 836 model()->Kill(subframe_b); |
| 815 | 837 |
| 816 ASSERT_NO_FATAL_FAILURE( | 838 ASSERT_NO_FATAL_FAILURE( |
| 817 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); | 839 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); |
| 818 ASSERT_NO_FATAL_FAILURE( | 840 ASSERT_NO_FATAL_FAILURE( |
| 819 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); | 841 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); |
| 820 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); | 842 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); |
| 821 ASSERT_NO_FATAL_FAILURE( | 843 ASSERT_NO_FATAL_FAILURE( |
| 822 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | 844 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); |
| 823 } | 845 } |
| 824 | 846 |
| 825 HideTaskManager(); | 847 HideTaskManager(); |
| 826 ShowTaskManager(); | 848 ShowTaskManager(); |
| 827 | 849 |
| 828 if (!ShouldExpectSubframes()) { | 850 if (!ShouldExpectSubframes()) { |
| 829 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); | 851 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); |
| 830 } else { | 852 } else { |
| 831 ASSERT_NO_FATAL_FAILURE( | 853 ASSERT_NO_FATAL_FAILURE( |
| 832 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); | 854 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); |
| 833 ASSERT_NO_FATAL_FAILURE( | 855 ASSERT_NO_FATAL_FAILURE( |
| 834 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); | 856 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); |
| 835 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); | 857 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); |
| 836 ASSERT_NO_FATAL_FAILURE( | 858 ASSERT_NO_FATAL_FAILURE( |
| 837 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | 859 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); |
| 860 | |
| 861 // Reload the subframe and verify it has re-appeared in the task manager. | |
| 862 // This is a regression test for https://crbug.com/642958. | |
| 863 ASSERT_TRUE(content::ExecuteScript( | |
| 864 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame(), | |
| 865 "document.getElementById('frame1').src = '" + b_url.spec() + "';")); | |
|
Łukasz Anforowicz
2017/05/05 22:01:05
Initially I couldn't get the test to repro the pro
| |
| 866 ASSERT_NO_FATAL_FAILURE( | |
| 867 WaitForTaskManagerRows(1, MatchSubframe("http://b.com/"))); | |
| 868 ASSERT_NO_FATAL_FAILURE( | |
| 869 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); | |
| 870 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnySubframe())); | |
| 871 ASSERT_NO_FATAL_FAILURE( | |
| 872 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); | |
| 838 } | 873 } |
| 839 } | 874 } |
| 840 | 875 |
| 841 // Tests what happens when a tab navigates to a site (a.com) that it previously | 876 // Tests what happens when a tab navigates to a site (a.com) that it previously |
| 842 // has a cross-process subframe into (b.com). | 877 // has a cross-process subframe into (b.com). |
| 843 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, NavigateToSubframeProcess) { | 878 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, NavigateToSubframeProcess) { |
| 844 ShowTaskManager(); | 879 ShowTaskManager(); |
| 845 | 880 |
| 846 // Navigate the tab to a page on a.com with cross-process subframes to | 881 // Navigate the tab to a page on a.com with cross-process subframes to |
| 847 // b.com and c.com. | 882 // b.com and c.com. |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1130 | 1165 |
| 1131 // Because the subframes for tab 2 are nested, their order is deterministic. | 1166 // Because the subframes for tab 2 are nested, their order is deterministic. |
| 1132 EXPECT_EQ("Subframe: http://a.com/", | 1167 EXPECT_EQ("Subframe: http://a.com/", |
| 1133 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 1))); | 1168 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 1))); |
| 1134 EXPECT_EQ("Subframe: http://c.com/", | 1169 EXPECT_EQ("Subframe: http://c.com/", |
| 1135 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 2))); | 1170 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 2))); |
| 1136 EXPECT_EQ("Subframe: http://b.com/", | 1171 EXPECT_EQ("Subframe: http://b.com/", |
| 1137 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 3))); | 1172 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 3))); |
| 1138 } | 1173 } |
| 1139 } | 1174 } |
| OLD | NEW |