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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigator_impl_unittest.cc
diff --git a/content/browser/frame_host/navigator_impl_unittest.cc b/content/browser/frame_host/navigator_impl_unittest.cc
index 82a49874ec9561ca5d6d17ec8a0aeb1c70cb8cce..2740ee8f8bf221cbfaa9b4198884234c44b2bb4f 100644
--- a/content/browser/frame_host/navigator_impl_unittest.cc
+++ b/content/browser/frame_host/navigator_impl_unittest.cc
@@ -941,4 +941,49 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1));
}
+// 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?
+TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) {
+ const GURL kUrl1("http://wikipedia.org/");
+ const GURL kUrl2("data:test");
+
+ // Navigate to an initial site.
+ contents()->NavigateAndCommit(kUrl1);
+ FrameTreeNode* node = main_test_rfh()->frame_tree_node();
+
+ // Navigate to a data url.
+ RequestNavigation(node, kUrl2);
+ NavigationRequest* navigation_request =
+ GetNavigationRequestForFrameTreeNode(node);
+ ASSERT_TRUE(navigation_request);
+ EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE,
+ navigation_request->state());
+ main_test_rfh()->SendBeforeUnloadACK(true);
+
+ // The request should not have been sent to the IO thread but committed
+ // immediately.
+ EXPECT_EQ(NavigationRequest::RESPONSE_STARTED,
+ navigation_request->state());
+ EXPECT_FALSE(navigation_request->loader_for_testing());
+ TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node);
+ 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
+ speculative_rfh->SendNavigate(0, kUrl2);
+ EXPECT_EQ(main_test_rfh(), speculative_rfh);
+
+ // Go back to the initial site.
+ contents()->NavigateAndCommit(kUrl1);
+
+ // 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.
+ // sent to the IO thread, nor committed.
+ TestRenderFrameHost* main_rfh = main_test_rfh();
+ main_rfh->SendBeginNavigationWithURL(kUrl2);
+ navigation_request = GetNavigationRequestForFrameTreeNode(node);
+ ASSERT_TRUE(navigation_request);
+ EXPECT_EQ(NavigationRequest::RESPONSE_STARTED,
+ navigation_request->state());
+ EXPECT_FALSE(navigation_request->loader_for_testing());
+ EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
+ main_rfh->SendNavigate(1, kUrl2);
+ EXPECT_EQ(main_test_rfh(), main_rfh);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698