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

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

Issue 1153193011: PlzNavigate: send Javascript urls synchronously to the renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unit test now that data urls are sent committed synchronously Created 5 years, 6 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
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 963
964 // PlzNavigate: Verify that data urls are properly handled. 964 // PlzNavigate: Verify that data urls are properly handled.
965 TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) { 965 TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) {
966 const GURL kUrl1("http://wikipedia.org/"); 966 const GURL kUrl1("http://wikipedia.org/");
967 const GURL kUrl2("data:text/html,test"); 967 const GURL kUrl2("data:text/html,test");
968 968
969 // Navigate to an initial site. 969 // Navigate to an initial site.
970 contents()->NavigateAndCommit(kUrl1); 970 contents()->NavigateAndCommit(kUrl1);
971 FrameTreeNode* node = main_test_rfh()->frame_tree_node(); 971 FrameTreeNode* node = main_test_rfh()->frame_tree_node();
972 972
973 // Navigate to a data url. 973 // Navigate to a data url. The request should not have been sent to the IO
974 // thread but committed immediately.
974 int entry_id = RequestNavigation(node, kUrl2); 975 int entry_id = RequestNavigation(node, kUrl2);
975 NavigationRequest* navigation_request = node->navigation_request(); 976 NavigationRequest* navigation_request = node->navigation_request();
976 ASSERT_TRUE(navigation_request); 977 ASSERT_TRUE(navigation_request);
977 EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE,
978 navigation_request->state());
979 main_test_rfh()->SendBeforeUnloadACK(true);
980
981 // The request should not have been sent to the IO thread but committed
982 // immediately.
983 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, 978 EXPECT_EQ(NavigationRequest::RESPONSE_STARTED,
984 navigation_request->state()); 979 navigation_request->state());
985 EXPECT_FALSE(navigation_request->loader_for_testing()); 980 EXPECT_FALSE(navigation_request->loader_for_testing());
986 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node); 981 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node);
987 ASSERT_TRUE(speculative_rfh); 982 ASSERT_TRUE(speculative_rfh);
988 speculative_rfh->SendNavigate(0, entry_id, true, kUrl2); 983 speculative_rfh->SendNavigate(0, entry_id, true, kUrl2);
989 EXPECT_EQ(main_test_rfh(), speculative_rfh); 984 EXPECT_EQ(main_test_rfh(), speculative_rfh);
990 985
991 // Go back to the initial site. 986 // Go back to the initial site.
992 contents()->NavigateAndCommit(kUrl1); 987 contents()->NavigateAndCommit(kUrl1);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 1121
1127 SiteInstance* converted_instance_2 = 1122 SiteInstance* converted_instance_2 =
1128 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); 1123 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get());
1129 // Should return |unrelated_instance| because its site matches and it is 1124 // Should return |unrelated_instance| because its site matches and it is
1130 // unrelated to the current SiteInstance. 1125 // unrelated to the current SiteInstance.
1131 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); 1126 EXPECT_EQ(unrelated_instance.get(), converted_instance_2);
1132 } 1127 }
1133 } 1128 }
1134 1129
1135 } // namespace content 1130 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698