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

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

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Adding a DCHECK to probably make a lot of tests fail. Created 3 years, 11 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 "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 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 " Site A ------------ proxies for B\n" 2324 " Site A ------------ proxies for B\n"
2325 " |--Site A ------- proxies for B\n" 2325 " |--Site A ------- proxies for B\n"
2326 " +--Site B ------- proxies for A\n" 2326 " +--Site B ------- proxies for A\n"
2327 "Where A = http://127.0.0.1/\n" 2327 "Where A = http://127.0.0.1/\n"
2328 " B = http://baz.com/", 2328 " B = http://baz.com/",
2329 visualizer.DepictFrameTree(root)); 2329 visualizer.DepictFrameTree(root));
2330 } 2330 }
2331 } 2331 }
2332 2332
2333 // Ensure that we don't crash when navigating subframes after in-page 2333 // Ensure that we don't crash when navigating subframes after in-page
2334 // navigations. See https://crbug.com/522193. 2334 // navigations. See https://crbug.com/522193.
nasko 2017/01/13 19:36:56 nit: No need for just empty space change.
arthursonzogni 2017/01/17 15:24:47 Done.
2335 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 2335 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
2336 FrameNavigationEntry_SubframeAfterInPage) { 2336 FrameNavigationEntry_SubframeAfterInPage) {
2337 // 1. Start on a page with a subframe. 2337 // 1. Start on a page with a subframe.
2338 GURL main_url(embedded_test_server()->GetURL( 2338 GURL main_url(embedded_test_server()->GetURL(
2339 "/navigation_controller/page_with_iframe.html")); 2339 "/navigation_controller/page_with_iframe.html"));
2340 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2340 EXPECT_TRUE(NavigateToURL(shell(), main_url));
2341 const NavigationControllerImpl& controller = 2341 const NavigationControllerImpl& controller =
2342 static_cast<const NavigationControllerImpl&>( 2342 static_cast<const NavigationControllerImpl&>(
2343 shell()->web_contents()->GetController()); 2343 shell()->web_contents()->GetController());
2344 FrameTreeNode* root = 2344 FrameTreeNode* root =
(...skipping 3814 matching lines...) Expand 10 before | Expand all | Expand 10 after
6159 web_contents->GetMainFrame()->GetProcess()->AddFilter(filter.get()); 6159 web_contents->GetMainFrame()->GetProcess()->AddFilter(filter.get());
6160 6160
6161 // Navigate cross-origin, waiting for the commit to occur. 6161 // Navigate cross-origin, waiting for the commit to occur.
6162 UrlCommitObserver cross_origin_commit_observer(root, cross_origin_url); 6162 UrlCommitObserver cross_origin_commit_observer(root, cross_origin_url);
6163 UrlCommitObserver history_commit_observer(root, start_url); 6163 UrlCommitObserver history_commit_observer(root, start_url);
6164 shell()->LoadURL(cross_origin_url); 6164 shell()->LoadURL(cross_origin_url);
6165 cross_origin_commit_observer.Wait(); 6165 cross_origin_commit_observer.Wait();
6166 EXPECT_EQ(cross_origin_url, web_contents->GetLastCommittedURL()); 6166 EXPECT_EQ(cross_origin_url, web_contents->GetLastCommittedURL());
6167 EXPECT_EQ(2, web_contents->GetController().GetLastCommittedEntryIndex()); 6167 EXPECT_EQ(2, web_contents->GetController().GetLastCommittedEntryIndex());
6168 6168
6169 // Wait for the back navigation to commit as well. 6169 if (IsBrowserSideNavigationEnabled()) {
6170 history_commit_observer.Wait(); 6170 // With browser-side-navigation, the history navigation is dropped.
6171 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); 6171 // Navigate to another URL to give the back navigation the opportunity to
6172 EXPECT_EQ(0, web_contents->GetController().GetLastCommittedEntryIndex()); 6172 // commit if it was not dropped.
6173 GURL start_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
6174 EXPECT_TRUE(NavigateToURL(shell(), start_url));
6175 EXPECT_EQ(3, web_contents->GetController().GetLastCommittedEntryIndex());
6176 EXPECT_EQ(4, web_contents->GetController().GetEntryCount());
6173 6177
6174 // Verify the expected origin through JavaScript. It also has the additional 6178 // Check that the renderer is still alive.
6175 // verification of the process also being still alive. 6179 std::string is_alive;
6176 std::string origin; 6180 EXPECT_TRUE(ExecuteScriptAndExtractString(
6177 EXPECT_TRUE(ExecuteScriptAndExtractString( 6181 web_contents, "domAutomationController.send('alive')", &is_alive));
nasko 2017/01/13 19:36:56 Why not use the origin? It gives you extra informa
arthursonzogni 2017/01/17 15:24:47 Done.
6178 web_contents, "domAutomationController.send(document.origin)", &origin)); 6182 EXPECT_EQ("alive", is_alive);
6179 EXPECT_EQ(start_url.GetOrigin().spec(), origin + "/"); 6183 } else {
6184 // Wait for the back navigation to commit as well.
6185 history_commit_observer.Wait();
6186 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL());
6187 EXPECT_EQ(0, web_contents->GetController().GetLastCommittedEntryIndex());
6188 EXPECT_EQ(3, web_contents->GetController().GetEntryCount());
6189
6190 // Verify the expected origin through JavaScript. It also has the additional
6191 // verification of the process also being still alive.
6192 std::string origin;
6193 EXPECT_TRUE(ExecuteScriptAndExtractString(
6194 web_contents, "domAutomationController.send(document.origin)",
6195 &origin));
6196 EXPECT_EQ(start_url.GetOrigin().spec(), origin + "/");
6197 }
6180 } 6198 }
6181 6199
6182 // Test that verifies that Referer and Origin http headers are correctly sent 6200 // Test that verifies that Referer and Origin http headers are correctly sent
6183 // to the final destination of a cross-site POST with a few redirects thrown in. 6201 // to the final destination of a cross-site POST with a few redirects thrown in.
6184 // This test is somewhat related to https://crbug.com/635400. 6202 // This test is somewhat related to https://crbug.com/635400.
6185 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 6203 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
6186 RefererAndOriginHeadersAfterRedirects) { 6204 RefererAndOriginHeadersAfterRedirects) {
6187 // Navigate to the page with form that posts via 307 redirection to 6205 // Navigate to the page with form that posts via 307 redirection to
6188 // |redirect_target_url| (cross-site from |form_url|). Using 307 (rather than 6206 // |redirect_target_url| (cross-site from |form_url|). Using 307 (rather than
6189 // 302) redirection is important to preserve the HTTP method and POST body. 6207 // 302) redirection is important to preserve the HTTP method and POST body.
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
6711 NavigationHandleCommitObserver handle_observer(shell()->web_contents(), 6729 NavigationHandleCommitObserver handle_observer(shell()->web_contents(),
6712 kFragmentURL); 6730 kFragmentURL);
6713 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL)); 6731 EXPECT_TRUE(NavigateToURL(shell(), kFragmentURL));
6714 6732
6715 EXPECT_TRUE(handle_observer.has_committed()); 6733 EXPECT_TRUE(handle_observer.has_committed());
6716 EXPECT_TRUE(handle_observer.was_same_page()); 6734 EXPECT_TRUE(handle_observer.was_same_page());
6717 EXPECT_FALSE(handle_observer.was_renderer_initiated()); 6735 EXPECT_FALSE(handle_observer.was_renderer_initiated());
6718 } 6736 }
6719 6737
6720 } // namespace content 6738 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698