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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2396493002: Improve the TestNavigationManager (Closed)
Patch Set: Addressed Nasko's nit Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 7931 matching lines...) Expand 10 before | Expand all | Expand 10 after
7942 // The RenderViewHost for b.com in the main tab should not be active. 7942 // The RenderViewHost for b.com in the main tab should not be active.
7943 SiteInstance* b_instance = popup_shell->web_contents()->GetSiteInstance(); 7943 SiteInstance* b_instance = popup_shell->web_contents()->GetSiteInstance();
7944 RenderViewHostImpl* rvh = 7944 RenderViewHostImpl* rvh =
7945 web_contents()->GetFrameTree()->GetRenderViewHost(b_instance); 7945 web_contents()->GetFrameTree()->GetRenderViewHost(b_instance);
7946 EXPECT_FALSE(rvh->is_active()); 7946 EXPECT_FALSE(rvh->is_active());
7947 7947
7948 // Navigate main tab to a b.com URL that will not commit. 7948 // Navigate main tab to a b.com URL that will not commit.
7949 GURL stall_url(embedded_test_server()->GetURL("b.com", "/title2.html")); 7949 GURL stall_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
7950 TestNavigationManager delayer(shell()->web_contents(), stall_url); 7950 TestNavigationManager delayer(shell()->web_contents(), stall_url);
7951 shell()->LoadURL(stall_url); 7951 shell()->LoadURL(stall_url);
7952 EXPECT_TRUE(delayer.WaitForWillStartRequest()); 7952 EXPECT_TRUE(delayer.WaitForRequestStart());
7953 7953
7954 // The pending RFH should be in the same process as the popup. 7954 // The pending RFH should be in the same process as the popup.
7955 RenderFrameHostImpl* pending_rfh = 7955 RenderFrameHostImpl* pending_rfh =
7956 IsBrowserSideNavigationEnabled() 7956 IsBrowserSideNavigationEnabled()
7957 ? root->render_manager()->speculative_frame_host() 7957 ? root->render_manager()->speculative_frame_host()
7958 : root->render_manager()->pending_frame_host(); 7958 : root->render_manager()->pending_frame_host();
7959 RenderProcessHost* pending_process = pending_rfh->GetProcess(); 7959 RenderProcessHost* pending_process = pending_rfh->GetProcess();
7960 EXPECT_EQ(pending_process, 7960 EXPECT_EQ(pending_process,
7961 popup_shell->web_contents()->GetMainFrame()->GetProcess()); 7961 popup_shell->web_contents()->GetMainFrame()->GetProcess());
7962 7962
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
8004 // The RenderViewHost for b.com in the main tab should not be active. 8004 // The RenderViewHost for b.com in the main tab should not be active.
8005 SiteInstance* b_instance = popup_shell->web_contents()->GetSiteInstance(); 8005 SiteInstance* b_instance = popup_shell->web_contents()->GetSiteInstance();
8006 RenderViewHostImpl* rvh = 8006 RenderViewHostImpl* rvh =
8007 web_contents()->GetFrameTree()->GetRenderViewHost(b_instance); 8007 web_contents()->GetFrameTree()->GetRenderViewHost(b_instance);
8008 EXPECT_FALSE(rvh->is_active()); 8008 EXPECT_FALSE(rvh->is_active());
8009 8009
8010 // Navigate main tab to a b.com URL that will not commit. 8010 // Navigate main tab to a b.com URL that will not commit.
8011 GURL stall_url(embedded_test_server()->GetURL("b.com", "/title2.html")); 8011 GURL stall_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
8012 TestNavigationManager delayer(shell()->web_contents(), stall_url); 8012 TestNavigationManager delayer(shell()->web_contents(), stall_url);
8013 shell()->LoadURL(stall_url); 8013 shell()->LoadURL(stall_url);
8014 EXPECT_TRUE(delayer.WaitForWillStartRequest()); 8014 EXPECT_TRUE(delayer.WaitForRequestStart());
8015 8015
8016 // Kill the b.com process, currently in use by the pending RenderFrameHost 8016 // Kill the b.com process, currently in use by the pending RenderFrameHost
8017 // and the popup. 8017 // and the popup.
8018 RenderProcessHost* pending_process = 8018 RenderProcessHost* pending_process =
8019 popup_shell->web_contents()->GetMainFrame()->GetProcess(); 8019 popup_shell->web_contents()->GetMainFrame()->GetProcess();
8020 RenderProcessHostWatcher crash_observer( 8020 RenderProcessHostWatcher crash_observer(
8021 pending_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 8021 pending_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
8022 EXPECT_TRUE(pending_process->Shutdown(0, false)); 8022 EXPECT_TRUE(pending_process->Shutdown(0, false));
8023 crash_observer.Wait(); 8023 crash_observer.Wait();
8024 8024
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
8311 ->GetFrameTree() 8311 ->GetFrameTree()
8312 ->root(); 8312 ->root();
8313 8313
8314 // Start a cross-process navigation and wait until the response is received. 8314 // Start a cross-process navigation and wait until the response is received.
8315 GURL cross_site_url_1 = 8315 GURL cross_site_url_1 =
8316 embedded_test_server()->GetURL("b.com", "/title1.html"); 8316 embedded_test_server()->GetURL("b.com", "/title1.html");
8317 TestNavigationManager cross_site_manager(shell()->web_contents(), 8317 TestNavigationManager cross_site_manager(shell()->web_contents(),
8318 cross_site_url_1); 8318 cross_site_url_1);
8319 shell()->web_contents()->GetController().LoadURL( 8319 shell()->web_contents()->GetController().LoadURL(
8320 cross_site_url_1, Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); 8320 cross_site_url_1, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
8321 EXPECT_TRUE(cross_site_manager.WaitForWillProcessResponse()); 8321 EXPECT_TRUE(cross_site_manager.WaitForResponse());
8322 8322
8323 // Start a renderer-initiated navigation to a cross-process url and make sure 8323 // Start a renderer-initiated navigation to a cross-process url and make sure
8324 // the navigation will be blocked before being transferred. 8324 // the navigation will be blocked before being transferred.
8325 GURL cross_site_url_2 = 8325 GURL cross_site_url_2 =
8326 embedded_test_server()->GetURL("c.com", "/title1.html"); 8326 embedded_test_server()->GetURL("c.com", "/title1.html");
8327 TestNavigationManager transfer_manager(shell()->web_contents(), 8327 TestNavigationManager transfer_manager(shell()->web_contents(),
8328 cross_site_url_2); 8328 cross_site_url_2);
8329 EXPECT_TRUE(ExecuteScript( 8329 EXPECT_TRUE(ExecuteScript(
8330 root, "location.href = '" + cross_site_url_2.spec() + "';")); 8330 root, "location.href = '" + cross_site_url_2.spec() + "';"));
8331 EXPECT_TRUE(transfer_manager.WaitForWillProcessResponse()); 8331 EXPECT_TRUE(transfer_manager.WaitForResponse());
8332 8332
8333 // Now have the cross-process navigation commit and mark the current RFH as 8333 // Now have the cross-process navigation commit and mark the current RFH as
8334 // pending deletion. 8334 // pending deletion.
8335 cross_site_manager.WaitForNavigationFinished(); 8335 cross_site_manager.WaitForNavigationFinished();
8336 8336
8337 // Resume the navigation in the previous RFH that has just been marked as 8337 // Resume the navigation in the previous RFH that has just been marked as
8338 // pending deletion. We should not crash. 8338 // pending deletion. We should not crash.
8339 transfer_manager.WaitForNavigationFinished(); 8339 transfer_manager.WaitForNavigationFinished();
8340 } 8340 }
8341 8341
8342 } // namespace content 8342 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698