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

Unified Diff: chrome/browser/ui/search/instant_extended_interactive_uitest.cc

Issue 13877028: Renderer initiated navigations from non instant process should not fall into instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing another recently added test. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/browser/ui/search/instant_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/instant_extended_interactive_uitest.cc
diff --git a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
index 5eee78fa9db8db3ec23ac03030c76569c0028b5e..664204df42d767c351f33bfbde6d7507a6f8cd52 100644
--- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
+++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
@@ -56,6 +56,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/bindings_policy.h"
+#include "content/public/common/renderer_preferences.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -2049,3 +2050,117 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputChangedFromSearchToURL) {
// Confirm that the Instant overlay was NOT committed.
EXPECT_NE(overlay, browser()->tab_strip_model()->GetActiveWebContents());
}
+
+// Test that renderer initiated navigations to an instant URL from a non
+// Instant page do not end up in an Instant process if they are bounced to the
+// browser.
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
+ RendererInitiatedNavigationNotInInstantProcess) {
+ InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(browser()->profile());
+ ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
+
+ // Setup Instant.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+ FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
+
+ EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+
+ // Don't use https server for the non instant URL so that the browser uses
+ // different RenderViews.
+ GURL non_instant_url = test_server()->GetURL("files/simple.html");
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ non_instant_url,
+ CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ content::WebContents* contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_FALSE(instant_service->IsInstantProcess(
+ contents->GetRenderProcessHost()->GetID()));
+ EXPECT_EQ(non_instant_url, contents->GetURL());
+
+ int old_render_view_id = contents->GetRenderViewHost()->GetRoutingID();
+ int old_render_process_id = contents->GetRenderProcessHost()->GetID();
+
+ std::string instant_url_with_query = instant_url().spec() + "q=3";
+ std::string add_link_script = base::StringPrintf(
+ "var a = document.createElement('a');"
+ "a.id = 'toClick';"
+ "a.href = '%s';"
+ "document.body.appendChild(a);",
+ instant_url_with_query.c_str());
+ EXPECT_TRUE(content::ExecuteScript(contents, add_link_script));
+
+ // Ensure that navigations are bounced to the browser.
+ contents->GetMutableRendererPrefs()->browser_handles_all_top_level_requests =
+ true;
+ contents->GetRenderViewHost()->SyncRendererPrefs();
+
+ content::WindowedNotificationObserver observer(
+ content::NOTIFICATION_NAV_ENTRY_COMMITTED,
+ content::NotificationService::AllSources());
+ EXPECT_TRUE(content::ExecuteScript(
+ contents, "document.getElementById('toClick').click();"));
+ observer.Wait();
+
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+ contents = browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_FALSE(instant_service->IsInstantProcess(
+ contents->GetRenderProcessHost()->GetID()));
+ EXPECT_EQ(GURL(instant_url_with_query), contents->GetURL());
+ int new_render_view_id = contents->GetRenderViewHost()->GetRoutingID();
+ int new_render_process_id = contents->GetRenderProcessHost()->GetID();
+
+ EXPECT_TRUE(old_render_process_id != new_render_process_id ||
+ old_render_view_id != new_render_view_id);
+}
+
+// Test that renderer initiated navigations to an Instant URL from an
+// Instant process end up in an Instant process.
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
+ RendererInitiatedNavigationInInstantProcess) {
+ InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(browser()->profile());
+ ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
+
+ // Setup Instant.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+ FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
+
+ EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ instant_url(),
+ CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ content::WebContents* contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_TRUE(instant_service->IsInstantProcess(
+ contents->GetRenderProcessHost()->GetID()));
+
+ std::string instant_url_with_query = instant_url().spec() + "q=3";
+ std::string add_link_script = base::StringPrintf(
+ "var a = document.createElement('a');"
+ "a.id = 'toClick';"
+ "a.href = '%s';"
+ "document.body.appendChild(a);",
+ instant_url_with_query.c_str());
+ EXPECT_TRUE(content::ExecuteScript(contents, add_link_script));
+
+ content::WindowedNotificationObserver observer(
+ content::NOTIFICATION_NAV_ENTRY_COMMITTED,
+ content::NotificationService::AllSources());
+ EXPECT_TRUE(content::ExecuteScript(
+ contents, "document.getElementById('toClick').click();"));
+ observer.Wait();
+
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+ contents = browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_TRUE(instant_service->IsInstantProcess(
+ contents->GetRenderProcessHost()->GetID()));
+ EXPECT_EQ(GURL(instant_url_with_query), contents->GetURL());
+}
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/browser/ui/search/instant_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698