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

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

Issue 2433743004: PlzNavigate: Transmit referrer into FrameNavigationEntry. (Closed)
Patch Set: Add tests. Created 4 years, 1 month 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 | « no previous file | content/renderer/render_frame_impl.cc » ('j') | 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 "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 6741 matching lines...) Expand 10 before | Expand all | Expand 10 after
6752 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 6752 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
6753 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); 6753 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4);
6754 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); 6754 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3);
6755 6755
6756 controller.ReloadToRefreshContent(false); 6756 controller.ReloadToRefreshContent(false);
6757 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 6757 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
6758 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4); 6758 histogram.ExpectTotalCount(kReloadToReloadMetricName, 4);
6759 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3); 6759 histogram.ExpectTotalCount(kReloadMainResourceToReloadMetricName, 3);
6760 } 6760 }
6761 6761
6762 // Check that the referrer is stored inside FrameNavigationEntry for subframes.
6763 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
6764 RefererStoredForSubFrame) {
6765 if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
6766 return;
6767
6768 const NavigationControllerImpl& controller =
6769 static_cast<const NavigationControllerImpl&>(
6770 shell()->web_contents()->GetController());
6771
6772 // Navigate to a page with an iframe.
6773 GURL url(embedded_test_server()->GetURL(
6774 "/navigation_controller/page_with_iframe_simple.html"));
6775 EXPECT_TRUE(NavigateToURL(shell(), url));
6776
6777 EXPECT_EQ(1, controller.GetEntryCount());
6778 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
6779
6780 // Check that the FrameNavigationEntry's referrer.
Charlie Reis 2016/10/24 17:26:44 nit: Drop "that"
6781 ASSERT_EQ(1U, entry->root_node()->children.size());
6782 FrameNavigationEntry* frame_entry =
6783 entry->root_node()->children[0]->frame_entry.get();
6784 EXPECT_EQ(frame_entry->referrer().url, url);
6785 }
6786
6787 // Check that the referrer is stored inside FrameNavigationEntry for subframes
6788 // despite a redirection.
6789 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
6790 RefererStoredForSubFrameWithRedirect) {
Charlie Reis 2016/10/24 17:26:44 There's a fair amount of overhead to each browser
6791 if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
6792 return;
6793
6794 const NavigationControllerImpl& controller =
6795 static_cast<const NavigationControllerImpl&>(
6796 shell()->web_contents()->GetController());
6797
6798 // Navigate to a page with an iframe.
6799 GURL url(embedded_test_server()->GetURL(
6800 "/navigation_controller/page_with_iframe_redirect.html"));
6801 EXPECT_TRUE(NavigateToURL(shell(), url));
6802
6803 EXPECT_EQ(1, controller.GetEntryCount());
6804 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
6805
6806 // Check that the FrameNavigationEntry's referrer.
Charlie Reis 2016/10/24 17:26:44 nit: Drop "that"
6807 ASSERT_EQ(1U, entry->root_node()->children.size());
6808 FrameNavigationEntry* frame_entry =
6809 entry->root_node()->children[0]->frame_entry.get();
6810 EXPECT_EQ(frame_entry->referrer().url, url);
6811 }
6812
6762 namespace { 6813 namespace {
6763 6814
6764 class RequestMonitoringNavigationBrowserTest : public ContentBrowserTest { 6815 class RequestMonitoringNavigationBrowserTest : public ContentBrowserTest {
6765 public: 6816 public:
6766 RequestMonitoringNavigationBrowserTest() : weak_factory_(this) {} 6817 RequestMonitoringNavigationBrowserTest() : weak_factory_(this) {}
6767 6818
6768 const net::test_server::HttpRequest* FindAccumulatedRequest( 6819 const net::test_server::HttpRequest* FindAccumulatedRequest(
6769 const GURL& url_to_find) { 6820 const GURL& url_to_find) {
6770 // net::test_server::HttpRequest::GetURL hardcodes "http://localhost/" part. 6821 // net::test_server::HttpRequest::GetURL hardcodes "http://localhost/" part.
6771 GURL::Replacements replacements; 6822 GURL::Replacements replacements;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
6874 // Verify that the extra header was NOT present for the subresource. 6925 // Verify that the extra header was NOT present for the subresource.
6875 const net::test_server::HttpRequest* image_request = 6926 const net::test_server::HttpRequest* image_request =
6876 FindAccumulatedRequest(image_url); 6927 FindAccumulatedRequest(image_url);
6877 ASSERT_TRUE(image_request); 6928 ASSERT_TRUE(image_request);
6878 EXPECT_THAT(image_request->headers, 6929 EXPECT_THAT(image_request->headers,
6879 testing::Not(testing::Contains( 6930 testing::Not(testing::Contains(
6880 testing::Key("X-ExtraHeadersVsSubresources")))); 6931 testing::Key("X-ExtraHeadersVsSubresources"))));
6881 } 6932 }
6882 6933
6883 } // namespace content 6934 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698