Chromium Code Reviews| 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 b9d31d61d21faf12ffdb4b7deacb3f37f547fab1..ca95bfd2eab08decde54858783d074d0ffacd110 100644 |
| --- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc |
| +++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc |
| @@ -53,6 +53,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" |
| @@ -1861,3 +1862,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()); |
| + |
| + // Dont use https server for the non instant URL so that the browser uses |
|
Charlie Reis
2013/05/01 01:17:54
nit: Don't
Shishir
2013/05/01 07:56:14
Done.
|
| + // differnt RenderViews. |
|
Charlie Reis
2013/05/01 01:17:54
nit: different
Shishir
2013/05/01 07:56:14
Done.
|
| + 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; |
|
Charlie Reis
2013/05/01 01:17:54
nit: Move = to previous line (should fit, and more
Shishir
2013/05/01 07:56:14
Done.
|
| + 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 a |
| +// Instant page end up in an Instant process. |
|
Charlie Reis
2013/05/01 01:17:54
nit: // Instant process
Shishir
2013/05/01 07:56:14
Done.
|
| +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()); |
| +} |