Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: content/browser/frame_host/navigator_impl_unittest.cc

Issue 906283003: PlzNavigate: Support data urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
Charlie Reis 2015/02/20 22:11:50 Can you add a second test for base_url_for_data_ur
clamy 2015/02/26 15:28:36 What exactly would you want to test in that test?
945 TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) {
946 const GURL kUrl1("http://wikipedia.org/");
947 const GURL kUrl2("data: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);
Charlie Reis 2015/02/20 22:11:50 Why is there a speculative RFH? NavigatorImpl::Be
carlosk 2015/02/23 10:50:28 Line 960 causes it to be called.
clamy 2015/02/26 15:28:36 No, in that case NavigationRequest::BeginNavigatio
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 be
Charlie Reis 2015/02/20 22:11:50 should not?
clamy 2015/02/26 15:28:36 Done.
976 // sent to the IO thread, nor committed.
977 TestRenderFrameHost* main_rfh = main_test_rfh();
978 main_rfh->SendBeginNavigationWithURL(kUrl2);
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 EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
985 main_rfh->SendNavigate(1, kUrl2);
986 EXPECT_EQ(main_test_rfh(), main_rfh);
987 }
988
944 } // namespace content 989 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698