Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/frame_host/frame_tree.h" | 6 #include "content/browser/frame_host/frame_tree.h" |
| 7 #include "content/browser/frame_host/frame_tree_node.h" | 7 #include "content/browser/frame_host/frame_tree_node.h" |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 | 192 |
| 193 // Load a same-site page into iframe and it should still be live. | 193 // Load a same-site page into iframe and it should still be live. |
| 194 GURL http_url(test_server()->GetURL("files/title1.html")); | 194 GURL http_url(test_server()->GetURL("files/title1.html")); |
| 195 NavigateFrameToURL(root->child_at(0), http_url); | 195 NavigateFrameToURL(root->child_at(0), http_url); |
| 196 EXPECT_TRUE( | 196 EXPECT_TRUE( |
| 197 root->current_frame_host()->render_view_host()->IsRenderViewLive()); | 197 root->current_frame_host()->render_view_host()->IsRenderViewLive()); |
| 198 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); | 198 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); |
| 199 EXPECT_TRUE(root->child_at(0)->current_frame_host()->IsRenderFrameLive()); | 199 EXPECT_TRUE(root->child_at(0)->current_frame_host()->IsRenderFrameLive()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Ensure that origins are correctly set on navigations. | |
| 203 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, OriginSetOnNavigation) { | |
|
Charlie Reis
2014/11/13 18:00:57
Perhaps we can also add a --site-per-process test
alexmos
2014/11/18 18:25:31
Done -- please see RenderViewImplTest.OriginReplic
Charlie Reis
2014/11/19 00:46:17
Thanks!
| |
| 204 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 205 ASSERT_TRUE(test_server()->Start()); | |
| 206 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | |
|
Charlie Reis
2014/11/13 18:00:57
nit: This isn't a site per process test, so it's a
alexmos
2014/11/18 18:25:31
Done. It doesn't matter to the test as long as th
| |
| 207 NavigateToURL(shell(), main_url); | |
| 208 | |
| 209 // It is safe to obtain the root frame tree node here, as it doesn't change. | |
| 210 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
| 211 ->GetFrameTree()->root(); | |
| 212 | |
| 213 EXPECT_EQ(root->current_replication_state().origin.string(), | |
| 214 main_url.GetOrigin().spec()); | |
| 215 EXPECT_FALSE(root->current_replication_state().is_unique_origin); | |
| 216 | |
| 217 GURL frame_url(test_server()->GetURL("files/title1.html")); | |
| 218 NavigateFrameToURL(root->child_at(0), frame_url); | |
| 219 | |
| 220 EXPECT_EQ(root->child_at(0)->current_replication_state().origin.string(), | |
| 221 frame_url.GetOrigin().spec()); | |
| 222 EXPECT_FALSE(root->child_at(0)->current_replication_state().is_unique_origin); | |
| 223 | |
| 224 // Navigating to a data URL should set a unique origin. | |
| 225 GURL data_url("data:text/html,foo"); | |
| 226 NavigateToURL(shell(), data_url); | |
| 227 | |
| 228 EXPECT_TRUE(root->current_replication_state().is_unique_origin); | |
| 229 | |
| 230 // Navigating to a normal URL should update origin and clear unique origin | |
| 231 // flag. | |
| 232 NavigateToURL(shell(), main_url); | |
| 233 EXPECT_EQ(root->current_replication_state().origin.string(), | |
| 234 main_url.GetOrigin().spec()); | |
| 235 EXPECT_FALSE(root->current_replication_state().is_unique_origin); | |
| 236 } | |
| 237 | |
| 202 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest { | 238 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest { |
| 203 public: | 239 public: |
| 204 CrossProcessFrameTreeBrowserTest() {} | 240 CrossProcessFrameTreeBrowserTest() {} |
| 205 | 241 |
| 206 void SetUpCommandLine(base::CommandLine* command_line) override { | 242 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 207 command_line->AppendSwitch(switches::kSitePerProcess); | 243 command_line->AppendSwitch(switches::kSitePerProcess); |
| 208 } | 244 } |
| 209 | 245 |
| 210 private: | 246 private: |
| 211 DISALLOW_COPY_AND_ASSIGN(CrossProcessFrameTreeBrowserTest); | 247 DISALLOW_COPY_AND_ASSIGN(CrossProcessFrameTreeBrowserTest); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 // Ensure that the RenderViews and RenderFrames are all live. | 307 // Ensure that the RenderViews and RenderFrames are all live. |
| 272 EXPECT_TRUE( | 308 EXPECT_TRUE( |
| 273 root->current_frame_host()->render_view_host()->IsRenderViewLive()); | 309 root->current_frame_host()->render_view_host()->IsRenderViewLive()); |
| 274 EXPECT_TRUE( | 310 EXPECT_TRUE( |
| 275 child->current_frame_host()->render_view_host()->IsRenderViewLive()); | 311 child->current_frame_host()->render_view_host()->IsRenderViewLive()); |
| 276 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); | 312 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); |
| 277 EXPECT_TRUE(root->child_at(0)->current_frame_host()->IsRenderFrameLive()); | 313 EXPECT_TRUE(root->child_at(0)->current_frame_host()->IsRenderFrameLive()); |
| 278 } | 314 } |
| 279 | 315 |
| 280 } // namespace content | 316 } // namespace content |
| OLD | NEW |