OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.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 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1848 EXPECT_FALSE(rvh_deleted_observer.deleted()); | 1848 EXPECT_FALSE(rvh_deleted_observer.deleted()); |
1849 } | 1849 } |
1850 } | 1850 } |
1851 | 1851 |
1852 // Browser-side navigation: Test that a proper NavigationRequest is created by | 1852 // Browser-side navigation: Test that a proper NavigationRequest is created by |
1853 // BeginNavigation. | 1853 // BeginNavigation. |
1854 TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationBeginNavigation) { | 1854 TEST_F(RenderFrameHostManagerTest, BrowserSideNavigationBeginNavigation) { |
1855 const GURL kUrl1("http://www.google.com/"); | 1855 const GURL kUrl1("http://www.google.com/"); |
1856 const GURL kUrl2("http://www.chromium.org/"); | 1856 const GURL kUrl2("http://www.chromium.org/"); |
1857 const GURL kUrl3("http://www.gmail.com/"); | 1857 const GURL kUrl3("http://www.gmail.com/"); |
1858 const int64 firstNavRequestID = 1; | |
clamy
2014/08/18 11:51:24
Please rename this variable as kFirstNavRequestId
| |
1858 | 1859 |
1859 // Navigate to the first page. | 1860 // Navigate to the first page. |
1860 contents()->NavigateAndCommit(kUrl1); | 1861 contents()->NavigateAndCommit(kUrl1); |
1861 TestRenderViewHost* rvh1 = test_rvh(); | 1862 TestRenderViewHost* rvh1 = test_rvh(); |
1862 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state()); | 1863 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, rvh1->rvh_state()); |
1863 | 1864 |
1864 // Add a subframe. | 1865 // Add a subframe. |
1865 TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>( | 1866 TestRenderFrameHost* subframe_rfh = static_cast<TestRenderFrameHost*>( |
1866 contents()->GetFrameTree()->AddFrame( | 1867 contents()->GetFrameTree()->AddFrame( |
1867 contents()->GetFrameTree()->root(), 14, "Child")); | 1868 contents()->GetFrameTree()->root(), 14, "Child")); |
1868 | 1869 |
1869 // Simulate a BeginNavigation IPC on the subframe. | 1870 // Simulate a BeginNavigation IPC on the subframe. |
1870 subframe_rfh->SendBeginNavigationWithURL(kUrl2); | 1871 subframe_rfh->SendBeginNavigationWithURL(kUrl2); |
1871 NavigationRequest* subframe_request = | 1872 NavigationRequest* subframe_request = |
1872 NavigationRequestForRenderFrameManager( | 1873 NavigationRequestForRenderFrameManager( |
1873 subframe_rfh->frame_tree_node()->render_manager()); | 1874 subframe_rfh->frame_tree_node()->render_manager()); |
1874 ASSERT_TRUE(subframe_request); | 1875 ASSERT_TRUE(subframe_request); |
1875 EXPECT_EQ(kUrl2, subframe_request->info_for_testing().navigation_params.url); | 1876 EXPECT_EQ(kUrl2, subframe_request->info_for_testing().navigation_params.url); |
1876 // First party for cookies url should be that of the main frame. | 1877 // First party for cookies url should be that of the main frame. |
1877 EXPECT_EQ( | 1878 EXPECT_EQ( |
1878 kUrl1, subframe_request->info_for_testing().first_party_for_cookies); | 1879 kUrl1, subframe_request->info_for_testing().first_party_for_cookies); |
1879 EXPECT_FALSE(subframe_request->info_for_testing().is_main_frame); | 1880 EXPECT_FALSE(subframe_request->info_for_testing().is_main_frame); |
1880 EXPECT_TRUE(subframe_request->info_for_testing().parent_is_main_frame); | 1881 EXPECT_TRUE(subframe_request->info_for_testing().parent_is_main_frame); |
1882 EXPECT_EQ(firstNavRequestID, subframe_request->navigation_request_id()); | |
1881 | 1883 |
1882 // Simulate a BeginNavigation IPC on the main frame. | 1884 // Simulate a BeginNavigation IPC on the main frame. |
1883 main_test_rfh()->SendBeginNavigationWithURL(kUrl3); | 1885 main_test_rfh()->SendBeginNavigationWithURL(kUrl3); |
1884 NavigationRequest* main_request = | 1886 NavigationRequest* main_request = |
1885 NavigationRequestForRenderFrameManager( | 1887 NavigationRequestForRenderFrameManager( |
1886 main_test_rfh()->frame_tree_node()->render_manager()); | 1888 main_test_rfh()->frame_tree_node()->render_manager()); |
1887 ASSERT_TRUE(main_request); | 1889 ASSERT_TRUE(main_request); |
1888 EXPECT_EQ(kUrl3, main_request->info_for_testing().navigation_params.url); | 1890 EXPECT_EQ(kUrl3, main_request->info_for_testing().navigation_params.url); |
1889 EXPECT_EQ(kUrl3, main_request->info_for_testing().first_party_for_cookies); | 1891 EXPECT_EQ(kUrl3, main_request->info_for_testing().first_party_for_cookies); |
1890 EXPECT_TRUE(main_request->info_for_testing().is_main_frame); | 1892 EXPECT_TRUE(main_request->info_for_testing().is_main_frame); |
1891 EXPECT_FALSE(main_request->info_for_testing().parent_is_main_frame); | 1893 EXPECT_FALSE(main_request->info_for_testing().parent_is_main_frame); |
1894 EXPECT_EQ(firstNavRequestID + 1, main_request->navigation_request_id()); | |
1892 } | 1895 } |
1893 | 1896 |
1894 } // namespace content | 1897 } // namespace content |
OLD | NEW |