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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 GetSpeculativeRenderFrameHost(node)->rfh_state()); | 711 GetSpeculativeRenderFrameHost(node)->rfh_state()); |
712 EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); | 712 EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1)); |
713 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); | 713 EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh())); |
714 | 714 |
715 rfh1->SendNavigate(1, kUrl1); | 715 rfh1->SendNavigate(1, kUrl1); |
716 EXPECT_EQ(rfh1, main_test_rfh()); | 716 EXPECT_EQ(rfh1, main_test_rfh()); |
717 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); | 717 EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state()); |
718 EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); | 718 EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1)); |
719 } | 719 } |
720 | 720 |
| 721 // PlzNavigate: Verify that data urls are properly handled. |
| 722 TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) { |
| 723 const GURL kUrl1("http://wikipedia.org/"); |
| 724 const GURL kUrl2("data:test"); |
| 725 |
| 726 // Navigate to an initial site. |
| 727 contents()->NavigateAndCommit(kUrl1); |
| 728 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); |
| 729 |
| 730 // Navigate to a data url. |
| 731 RequestNavigation(node, kUrl2); |
| 732 NavigationRequest* navigation_request = |
| 733 GetNavigationRequestForFrameTreeNode(node); |
| 734 ASSERT_TRUE(navigation_request); |
| 735 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, |
| 736 navigation_request->state()); |
| 737 main_test_rfh()->SendBeforeUnloadACK(true); |
| 738 |
| 739 // The request should not have been sent to the IO thread but committed |
| 740 // immediately. |
| 741 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, |
| 742 navigation_request->state()); |
| 743 EXPECT_FALSE(navigation_request->loader_for_testing()); |
| 744 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); |
| 745 ASSERT_TRUE(speculative_rfh); |
| 746 speculative_rfh->SendNavigate(0, kUrl2); |
| 747 EXPECT_EQ(main_test_rfh(), speculative_rfh); |
| 748 |
| 749 // Go back to the initial site. |
| 750 contents()->NavigateAndCommit(kUrl1); |
| 751 |
| 752 // Do a renderer-initiated navigation to a data url. The request should be |
| 753 // sent to the IO thread, nor committed. |
| 754 TestRenderFrameHost* main_rfh = main_test_rfh(); |
| 755 main_rfh->SendBeginNavigationWithURL(kUrl2); |
| 756 navigation_request = GetNavigationRequestForFrameTreeNode(node); |
| 757 ASSERT_TRUE(navigation_request); |
| 758 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, |
| 759 navigation_request->state()); |
| 760 EXPECT_FALSE(navigation_request->loader_for_testing()); |
| 761 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node)); |
| 762 main_rfh->SendNavigate(1, kUrl2); |
| 763 EXPECT_EQ(main_test_rfh(), main_rfh); |
| 764 } |
| 765 |
721 } // namespace content | 766 } // namespace content |
OLD | NEW |