| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 299 |
| 300 // Add a subframe. | 300 // Add a subframe. |
| 301 FrameTreeNode* root_node = contents()->GetFrameTree()->root(); | 301 FrameTreeNode* root_node = contents()->GetFrameTree()->root(); |
| 302 TestRenderFrameHost* subframe_rfh = main_test_rfh()->AppendChild("Child"); | 302 TestRenderFrameHost* subframe_rfh = main_test_rfh()->AppendChild("Child"); |
| 303 ASSERT_TRUE(subframe_rfh); | 303 ASSERT_TRUE(subframe_rfh); |
| 304 | 304 |
| 305 // Start a navigation at the subframe. | 305 // Start a navigation at the subframe. |
| 306 FrameTreeNode* subframe_node = subframe_rfh->frame_tree_node(); | 306 FrameTreeNode* subframe_node = subframe_rfh->frame_tree_node(); |
| 307 RequestNavigation(subframe_node, kUrl2); | 307 RequestNavigation(subframe_node, kUrl2); |
| 308 NavigationRequest* subframe_request = subframe_node->navigation_request(); | 308 NavigationRequest* subframe_request = subframe_node->navigation_request(); |
| 309 |
| 310 // We should be waiting for the BeforeUnload event to execute in the subframe. |
| 311 ASSERT_TRUE(subframe_request); |
| 312 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, |
| 313 subframe_request->state()); |
| 314 EXPECT_TRUE(subframe_rfh->is_waiting_for_beforeunload_ack()); |
| 315 |
| 316 // Simulate the BeforeUnload ACK. The navigation should start. |
| 317 subframe_rfh->SendBeforeUnloadACK(true); |
| 309 TestNavigationURLLoader* subframe_loader = | 318 TestNavigationURLLoader* subframe_loader = |
| 310 GetLoaderForNavigationRequest(subframe_request); | 319 GetLoaderForNavigationRequest(subframe_request); |
| 311 | |
| 312 // Subframe navigations should start right away as they don't have to request | |
| 313 // beforeUnload to run at the renderer. | |
| 314 ASSERT_TRUE(subframe_request); | |
| 315 ASSERT_TRUE(subframe_loader); | 320 ASSERT_TRUE(subframe_loader); |
| 316 EXPECT_EQ(NavigationRequest::STARTED, subframe_request->state()); | 321 EXPECT_EQ(NavigationRequest::STARTED, subframe_request->state()); |
| 317 EXPECT_EQ(kUrl2, subframe_request->common_params().url); | 322 EXPECT_EQ(kUrl2, subframe_request->common_params().url); |
| 318 EXPECT_EQ(kUrl2, subframe_loader->request_info()->common_params.url); | 323 EXPECT_EQ(kUrl2, subframe_loader->request_info()->common_params.url); |
| 319 // First party for cookies url should be that of the main frame. | 324 // First party for cookies url should be that of the main frame. |
| 320 EXPECT_EQ(kUrl1, subframe_loader->request_info()->first_party_for_cookies); | 325 EXPECT_EQ(kUrl1, subframe_loader->request_info()->first_party_for_cookies); |
| 321 EXPECT_FALSE(subframe_loader->request_info()->is_main_frame); | 326 EXPECT_FALSE(subframe_loader->request_info()->is_main_frame); |
| 322 EXPECT_TRUE(subframe_loader->request_info()->parent_is_main_frame); | 327 EXPECT_TRUE(subframe_loader->request_info()->parent_is_main_frame); |
| 323 EXPECT_TRUE(subframe_request->browser_initiated()); | 328 EXPECT_TRUE(subframe_request->browser_initiated()); |
| 324 EXPECT_FALSE(GetSpeculativeRenderFrameHost(root_node)); | 329 EXPECT_FALSE(GetSpeculativeRenderFrameHost(root_node)); |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 | 1234 |
| 1230 // The first navigation commits. This should clear up the speculative RFH and | 1235 // The first navigation commits. This should clear up the speculative RFH and |
| 1231 // the ongoing NavigationRequest. | 1236 // the ongoing NavigationRequest. |
| 1232 speculative_rfh->SendNavigate(entry_id, true, kUrl2); | 1237 speculative_rfh->SendNavigate(entry_id, true, kUrl2); |
| 1233 EXPECT_FALSE(node->navigation_request()); | 1238 EXPECT_FALSE(node->navigation_request()); |
| 1234 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); | 1239 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| 1235 EXPECT_EQ(speculative_rfh, main_test_rfh()); | 1240 EXPECT_EQ(speculative_rfh, main_test_rfh()); |
| 1236 } | 1241 } |
| 1237 | 1242 |
| 1238 } // namespace content | 1243 } // namespace content |
| OLD | NEW |