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" | |
6 #include "base/macros.h" | 5 #include "base/macros.h" |
7 #include "base/time/time.h" | 6 #include "base/time/time.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 7 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 8 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/frame_host/navigation_request.h" | 9 #include "content/browser/frame_host/navigation_request.h" |
11 #include "content/browser/frame_host/navigation_request_info.h" | 10 #include "content/browser/frame_host/navigation_request_info.h" |
12 #include "content/browser/frame_host/navigator.h" | 11 #include "content/browser/frame_host/navigator.h" |
13 #include "content/browser/frame_host/navigator_impl.h" | 12 #include "content/browser/frame_host/navigator_impl.h" |
14 #include "content/browser/frame_host/render_frame_host_manager.h" | 13 #include "content/browser/frame_host/render_frame_host_manager.h" |
15 #include "content/browser/site_instance_impl.h" | 14 #include "content/browser/site_instance_impl.h" |
16 #include "content/browser/streams/stream.h" | 15 #include "content/browser/streams/stream.h" |
17 #include "content/common/frame_messages.h" | 16 #include "content/common/frame_messages.h" |
18 #include "content/common/navigation_params.h" | 17 #include "content/common/navigation_params.h" |
19 #include "content/public/browser/stream_handle.h" | 18 #include "content/public/browser/stream_handle.h" |
20 #include "content/public/common/content_switches.h" | |
21 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
22 #include "content/public/common/url_utils.h" | 20 #include "content/public/common/url_utils.h" |
| 21 #include "content/public/test/browser_test_utils.h" |
23 #include "content/public/test/mock_render_process_host.h" | 22 #include "content/public/test/mock_render_process_host.h" |
24 #include "content/test/browser_side_navigation_test_utils.h" | 23 #include "content/test/browser_side_navigation_test_utils.h" |
25 #include "content/test/test_navigation_url_loader.h" | 24 #include "content/test/test_navigation_url_loader.h" |
26 #include "content/test/test_render_frame_host.h" | 25 #include "content/test/test_render_frame_host.h" |
27 #include "content/test/test_web_contents.h" | 26 #include "content/test/test_web_contents.h" |
28 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
29 #include "net/http/http_response_headers.h" | 28 #include "net/http/http_response_headers.h" |
30 #include "net/url_request/redirect_info.h" | 29 #include "net/url_request/redirect_info.h" |
31 #include "ui/base/page_transition_types.h" | 30 #include "ui/base/page_transition_types.h" |
32 #include "url/url_constants.h" | 31 #include "url/url_constants.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // First party for cookies url should be that of the main frame. | 310 // First party for cookies url should be that of the main frame. |
312 EXPECT_EQ(kUrl1, subframe_loader->request_info()->first_party_for_cookies); | 311 EXPECT_EQ(kUrl1, subframe_loader->request_info()->first_party_for_cookies); |
313 EXPECT_FALSE(subframe_loader->request_info()->is_main_frame); | 312 EXPECT_FALSE(subframe_loader->request_info()->is_main_frame); |
314 EXPECT_TRUE(subframe_loader->request_info()->parent_is_main_frame); | 313 EXPECT_TRUE(subframe_loader->request_info()->parent_is_main_frame); |
315 EXPECT_TRUE(subframe_request->browser_initiated()); | 314 EXPECT_TRUE(subframe_request->browser_initiated()); |
316 EXPECT_FALSE(GetSpeculativeRenderFrameHost(root_node)); | 315 EXPECT_FALSE(GetSpeculativeRenderFrameHost(root_node)); |
317 | 316 |
318 // Subframe navigations should never create a speculative RenderFrameHost, | 317 // Subframe navigations should never create a speculative RenderFrameHost, |
319 // unless site-per-process is enabled. In that case, as the subframe | 318 // unless site-per-process is enabled. In that case, as the subframe |
320 // navigation is to a different site and is still ongoing, it should have one. | 319 // navigation is to a different site and is still ongoing, it should have one. |
321 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 320 if (AreAllSitesIsolatedForTesting()) { |
322 switches::kSitePerProcess)) { | |
323 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); | 321 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); |
324 } else { | 322 } else { |
325 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); | 323 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); |
326 } | 324 } |
327 | 325 |
328 // Now start a navigation at the root node. | 326 // Now start a navigation at the root node. |
329 RequestNavigation(root_node, kUrl3); | 327 RequestNavigation(root_node, kUrl3); |
330 NavigationRequest* main_request = root_node->navigation_request(); | 328 NavigationRequest* main_request = root_node->navigation_request(); |
331 ASSERT_TRUE(main_request); | 329 ASSERT_TRUE(main_request); |
332 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, | 330 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, |
(...skipping 13 matching lines...) Expand all Loading... |
346 EXPECT_TRUE(main_loader->request_info()->is_main_frame); | 344 EXPECT_TRUE(main_loader->request_info()->is_main_frame); |
347 EXPECT_FALSE(main_loader->request_info()->parent_is_main_frame); | 345 EXPECT_FALSE(main_loader->request_info()->parent_is_main_frame); |
348 EXPECT_TRUE(main_request->browser_initiated()); | 346 EXPECT_TRUE(main_request->browser_initiated()); |
349 // BeforeUnloadACK was received from the renderer so the navigation should | 347 // BeforeUnloadACK was received from the renderer so the navigation should |
350 // have started. | 348 // have started. |
351 EXPECT_EQ(NavigationRequest::STARTED, main_request->state()); | 349 EXPECT_EQ(NavigationRequest::STARTED, main_request->state()); |
352 EXPECT_TRUE(GetSpeculativeRenderFrameHost(root_node)); | 350 EXPECT_TRUE(GetSpeculativeRenderFrameHost(root_node)); |
353 | 351 |
354 // As the main frame hasn't yet committed the subframe still exists. Thus, the | 352 // As the main frame hasn't yet committed the subframe still exists. Thus, the |
355 // above situation regarding subframe navigations is valid here. | 353 // above situation regarding subframe navigations is valid here. |
356 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 354 if (AreAllSitesIsolatedForTesting()) { |
357 switches::kSitePerProcess)) { | |
358 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); | 355 EXPECT_TRUE(GetSpeculativeRenderFrameHost(subframe_node)); |
359 } else { | 356 } else { |
360 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); | 357 EXPECT_FALSE(GetSpeculativeRenderFrameHost(subframe_node)); |
361 } | 358 } |
362 } | 359 } |
363 | 360 |
364 // PlzNavigate: Test that committing an HTTP 204 or HTTP 205 response cancels | 361 // PlzNavigate: Test that committing an HTTP 204 or HTTP 205 response cancels |
365 // the navigation. | 362 // the navigation. |
366 TEST_F(NavigatorTestWithBrowserSideNavigation, NoContent) { | 363 TEST_F(NavigatorTestWithBrowserSideNavigation, NoContent) { |
367 const GURL kUrl1("http://www.chromium.org/"); | 364 const GURL kUrl1("http://www.chromium.org/"); |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 | 1131 |
1135 SiteInstance* converted_instance_2 = | 1132 SiteInstance* converted_instance_2 = |
1136 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); | 1133 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); |
1137 // Should return |unrelated_instance| because its site matches and it is | 1134 // Should return |unrelated_instance| because its site matches and it is |
1138 // unrelated to the current SiteInstance. | 1135 // unrelated to the current SiteInstance. |
1139 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); | 1136 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); |
1140 } | 1137 } |
1141 } | 1138 } |
1142 | 1139 |
1143 } // namespace content | 1140 } // namespace content |
OLD | NEW |