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 "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/frame_host/navigation_request.h" | 10 #include "content/browser/frame_host/navigation_request.h" |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 GetSpeculativeRenderFrameHost(node)->rfh_state()); | 934 GetSpeculativeRenderFrameHost(node)->rfh_state()); |
935 EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); | 935 EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); |
936 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); | 936 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
937 | 937 |
938 rfh1->SendNavigate(1, kUrl1); | 938 rfh1->SendNavigate(1, kUrl1); |
939 EXPECT_EQ(rfh1, main_test_rfh()); | 939 EXPECT_EQ(rfh1, main_test_rfh()); |
940 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 940 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
941 EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); | 941 EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); |
942 } | 942 } |
943 | 943 |
| 944 // PlzNavigate: Verify that data urls are properly handled. |
| 945 TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) { |
| 946 const GURL kUrl1("http://wikipedia.org/"); |
| 947 const GURL kUrl2("data:text/html,test"); |
| 948 |
| 949 // Navigate to an initial site. |
| 950 contents()->NavigateAndCommit(kUrl1); |
| 951 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| 952 |
| 953 // Navigate to a data url. |
| 954 RequestNavigation(node, kUrl2); |
| 955 NavigationRequest* navigation_request = |
| 956 GetNavigationRequestForFrameTreeNode(node); |
| 957 ASSERT_TRUE(navigation_request); |
| 958 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, |
| 959 navigation_request->state()); |
| 960 main_test_rfh()->SendBeforeUnloadACK(true); |
| 961 |
| 962 // The request should not have been sent to the IO thread but committed |
| 963 // immediately. |
| 964 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, |
| 965 navigation_request->state()); |
| 966 EXPECT_FALSE(navigation_request->loader_for_testing()); |
| 967 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| 968 ASSERT_TRUE(speculative_rfh); |
| 969 speculative_rfh->SendNavigate(0, kUrl2); |
| 970 EXPECT_EQ(main_test_rfh(), speculative_rfh); |
| 971 |
| 972 // Go back to the initial site. |
| 973 contents()->NavigateAndCommit(kUrl1); |
| 974 |
| 975 // Do a renderer-initiated navigation to a data url. The request should not be |
| 976 // sent to the IO thread, nor committed. |
| 977 TestRenderFrameHost* main_rfh = main_test_rfh(); |
| 978 main_rfh->SendBeginNavigationWithURL(kUrl2, true); |
| 979 navigation_request = GetNavigationRequestForFrameTreeNode(node); |
| 980 ASSERT_TRUE(navigation_request); |
| 981 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, |
| 982 navigation_request->state()); |
| 983 EXPECT_FALSE(navigation_request->loader_for_testing()); |
| 984 speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| 985 ASSERT_TRUE(speculative_rfh); |
| 986 speculative_rfh->SendNavigate(0, kUrl2); |
| 987 EXPECT_EQ(main_test_rfh(), speculative_rfh); |
| 988 } |
| 989 |
944 } // namespace content | 990 } // namespace content |
OLD | NEW |