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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/frame_host/cross_site_transferring_request.h" | 10 #include "content/browser/frame_host/cross_site_transferring_request.h" |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 EXPECT_TRUE(manager2->speculative_web_ui()); | 1069 EXPECT_TRUE(manager2->speculative_web_ui()); |
1070 } else { | 1070 } else { |
1071 EXPECT_TRUE(manager2->pending_web_ui()); | 1071 EXPECT_TRUE(manager2->pending_web_ui()); |
1072 } | 1072 } |
1073 EXPECT_TRUE( | 1073 EXPECT_TRUE( |
1074 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1074 host2->render_view_host()->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1075 | 1075 |
1076 manager2->DidNavigateFrame(host2, true); | 1076 manager2->DidNavigateFrame(host2, true); |
1077 } | 1077 } |
1078 | 1078 |
| 1079 // Tests that a WebUI is correctly reused between chrome:// pages. |
| 1080 TEST_F(RenderFrameHostManagerTest, WebUIWasReused) { |
| 1081 set_should_create_webui(true); |
| 1082 |
| 1083 // Navigate to a WebUI page. |
| 1084 const GURL kUrl1("chrome://foo"); |
| 1085 contents()->NavigateAndCommit(kUrl1); |
| 1086 RenderFrameHostManager* manager = |
| 1087 main_test_rfh()->frame_tree_node()->render_manager(); |
| 1088 WebUIImpl* web_ui = manager->web_ui(); |
| 1089 EXPECT_TRUE(web_ui); |
| 1090 |
| 1091 // Navigate to another WebUI page which should be same-site and keep the |
| 1092 // current WebUI. |
| 1093 const GURL kUrl2("chrome://foo/bar"); |
| 1094 contents()->NavigateAndCommit(kUrl2); |
| 1095 EXPECT_EQ(web_ui, manager->web_ui()); |
| 1096 } |
| 1097 |
| 1098 // Tests that a WebUI is correctly cleaned up when navigating from a chrome:// |
| 1099 // page to a non-chrome:// page. |
| 1100 TEST_F(RenderFrameHostManagerTest, WebUIWasCleared) { |
| 1101 set_should_create_webui(true); |
| 1102 |
| 1103 // Navigate to a WebUI page. |
| 1104 const GURL kUrl1("chrome://foo"); |
| 1105 contents()->NavigateAndCommit(kUrl1); |
| 1106 EXPECT_TRUE(main_test_rfh()->frame_tree_node()->render_manager()->web_ui()); |
| 1107 |
| 1108 // Navigate to a non-WebUI page. |
| 1109 const GURL kUrl2("http://www.google.com"); |
| 1110 contents()->NavigateAndCommit(kUrl2); |
| 1111 EXPECT_FALSE(main_test_rfh()->frame_tree_node()->render_manager()->web_ui()); |
| 1112 } |
| 1113 |
1079 // Tests that we don't end up in an inconsistent state if a page does a back and | 1114 // Tests that we don't end up in an inconsistent state if a page does a back and |
1080 // then reload. http://crbug.com/51680 | 1115 // then reload. http://crbug.com/51680 |
1081 // Also tests that only user-gesture navigations can interrupt cross-process | 1116 // Also tests that only user-gesture navigations can interrupt cross-process |
1082 // navigations. http://crbug.com/75195 | 1117 // navigations. http://crbug.com/75195 |
1083 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { | 1118 TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) { |
1084 const GURL kUrl1("http://www.google.com/"); | 1119 const GURL kUrl1("http://www.google.com/"); |
1085 const GURL kUrl2("http://www.evil-site.com/"); | 1120 const GURL kUrl2("http://www.evil-site.com/"); |
1086 | 1121 |
1087 // Navigate to a safe site, then an evil site. | 1122 // Navigate to a safe site, then an evil site. |
1088 // This will switch RenderFrameHosts. We cannot assert that the first and | 1123 // This will switch RenderFrameHosts. We cannot assert that the first and |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2053 EXPECT_FALSE(contents2->GetMainFrame()->IsRenderFrameLive()); |
2019 contents2->NavigateAndCommit(kUrl3); | 2054 contents2->NavigateAndCommit(kUrl3); |
2020 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); | 2055 EXPECT_TRUE(contents2->GetMainFrame()->IsRenderFrameLive()); |
2021 EXPECT_NE(nullptr, | 2056 EXPECT_NE(nullptr, |
2022 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); | 2057 iframe->GetRenderFrameProxyHost(contents1->GetSiteInstance())); |
2023 EXPECT_EQ(nullptr, | 2058 EXPECT_EQ(nullptr, |
2024 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); | 2059 iframe->GetRenderFrameProxyHost(contents2->GetSiteInstance())); |
2025 } | 2060 } |
2026 | 2061 |
2027 } // namespace content | 2062 } // namespace content |
OLD | NEW |