Index: chrome/browser/instant/instant_extended_browsertest.cc |
diff --git a/chrome/browser/instant/instant_extended_browsertest.cc b/chrome/browser/instant/instant_extended_browsertest.cc |
index 803122a7f61512109e2f7d42ec0eb978108d13f0..da30e255a57420e221c3a05403e59bc1dcbcc774 100644 |
--- a/chrome/browser/instant/instant_extended_browsertest.cc |
+++ b/chrome/browser/instant/instant_extended_browsertest.cc |
@@ -126,6 +126,46 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { |
EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
} |
+// Test that middle clicking on a suggestion opens the result in a new tab. |
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
+ MiddleClickOnSuggestionOpensInNewTab) { |
+ ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
+ FocusOmniboxAndWaitForInstantSupport(); |
+ EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
+ |
+ EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
+ |
+ // Typing in the omnibox should show the overlay. |
+ SetOmniboxTextAndWaitForInstantToShow("santa"); |
+ EXPECT_TRUE(instant()->IsPreviewingSearchResults()); |
+ |
+ // Create an event listener that opens the top suggestion in a new tab. |
+ EXPECT_TRUE(ExecuteScript( |
+ "var rid = getApiHandle().nativeSuggestions[0].rid;" |
+ "document.body.addEventListener('click', function() {" |
+ "chrome.embeddedSearch.navigateContentWindow(rid, 2);" |
+ "});" |
+ )); |
+ |
+ content::WindowedNotificationObserver observer( |
+ chrome::NOTIFICATION_TAB_ADDED, |
+ content::NotificationService::AllSources()); |
+ |
+ // Click to trigger the event listener. |
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
+ |
+ // Wait for the new tab to be added. |
+ observer.Wait(); |
+ |
+ // Check that the new tab URL is as expected. |
+ content::WebContents* new_tab_contents = |
+ browser()->tab_strip_model()->GetWebContentsAt(1); |
+ EXPECT_EQ(new_tab_contents->GetURL().spec(), instant_url_.spec()+"q=santa"); |
sreeram
2013/02/21 20:36:51
Nit: Spaces around "+".
|
+ |
+ // Check that there are now two tabs. |
+ EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
sreeram
2013/02/21 20:36:51
You should do this before line 160. I.e., check th
|
+} |
+ |
// TODO(sreeram): Enable this test once @mathp's CL lands: |
// https://codereview.chromium.org/12179025/ |
// |