Commit 4c67d747 authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Update print dialog navigation test to handle same-site BrowsingInstance swap

With crrev.com/c/2121522, some main-frame same-site navigations will
result in a new BrowsingInstance, SiteInstance, RenderFrameHost,
RenderView, etc. This CL updates the print dialog navigation test that
previously didn't expect a change of RenderFrameHosts etc. on same-site
navigations - we're now changing the test to do a same document
navigation (which is what GMail is doing).

For more details, see doc: https://docs.google.com/document/d/1lHdkKLUe8H6ZP6ALwj-dsus7oYcuc93HkSCHCcerItg/edit?usp=sharing

Bug: 977562
Change-Id: Ifeb972f92f86d45385545f84d27d53784d7abe89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212287
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772045}
parent f0d02501
...@@ -199,7 +199,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, CloseDialogOnNavigation) { ...@@ -199,7 +199,7 @@ TEST_F(PrintPreviewDialogControllerUnitTest, CloseDialogOnNavigation) {
// Two similar URLs (same webpage, different URL fragment/query) // Two similar URLs (same webpage, different URL fragment/query)
// Gmail navigates from fragment to query when opening an email to print. // Gmail navigates from fragment to query when opening an email to print.
GURL tiger("https://www.google.com/#q=tiger"); GURL tiger("https://www.google.com/#q=tiger");
GURL tiger_barb("https://www.google.com/?q=tiger+barb"); GURL tiger_barb("https://www.google.com/#?q=tiger+barb");
// Set up by opening a new tab and getting web contents // Set up by opening a new tab and getting web contents
EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
...@@ -275,12 +275,13 @@ TEST_F(PrintPreviewDialogControllerUnitTest, CloseDialogOnNavigation) { ...@@ -275,12 +275,13 @@ TEST_F(PrintPreviewDialogControllerUnitTest, CloseDialogOnNavigation) {
// Try to simulate Gmail navigation: Navigate to an existing page (via // Try to simulate Gmail navigation: Navigate to an existing page (via
// Forward) but modify the navigation type while pending to look like an // Forward) but modify the navigation type while pending to look like an
// address bar + typed transition (like Gmail auto navigation) // address bar + typed transition (like Gmail auto navigation)
content::NavigationController& nav_controller = web_contents->GetController(); std::unique_ptr<content::NavigationSimulator> forward_nav =
nav_controller.GoForward(); content::NavigationSimulator::CreateHistoryNavigation(1, web_contents);
nav_controller.GetPendingEntry()->SetTransitionType(ui::PageTransitionFromInt( forward_nav->Start();
ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)); web_contents->GetController().GetPendingEntry()->SetTransitionType(
CommitPendingLoad(&nav_controller); ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED |
ui::PAGE_TRANSITION_FROM_ADDRESS_BAR));
forward_nav->Commit();
// Navigation successful // Navigation successful
EXPECT_EQ(tiger_barb, web_contents->GetLastCommittedURL()); EXPECT_EQ(tiger_barb, web_contents->GetLastCommittedURL());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment