| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 12 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 14 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_result.h" | 15 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_utils.h" | 17 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 18 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/favicon/favicon_tab_helper.h" | 20 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 20 #include "chrome/browser/history/history_types.h" | 21 #include "chrome/browser/history/history_types.h" |
| 21 #include "chrome/browser/history/top_sites.h" | 22 #include "chrome/browser/history/top_sites.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/search/instant_service.h" | 24 #include "chrome/browser/search/instant_service.h" |
| 24 #include "chrome/browser/search/instant_service_factory.h" | 25 #include "chrome/browser/search/instant_service_factory.h" |
| 25 #include "chrome/browser/search/search.h" | 26 #include "chrome/browser/search/search.h" |
| 26 #include "chrome/browser/themes/theme_service.h" | 27 #include "chrome/browser/themes/theme_service.h" |
| 27 #include "chrome/browser/themes/theme_service_factory.h" | 28 #include "chrome/browser/themes/theme_service_factory.h" |
| 28 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 29 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 29 #include "chrome/browser/ui/search/instant_commit_type.h" | 30 #include "chrome/browser/ui/search/instant_commit_type.h" |
| 30 #include "chrome/browser/ui/search/instant_ntp.h" | 31 #include "chrome/browser/ui/search/instant_ntp.h" |
| 31 #include "chrome/browser/ui/search/instant_overlay.h" | 32 #include "chrome/browser/ui/search/instant_overlay.h" |
| 32 #include "chrome/browser/ui/search/instant_tab.h" | 33 #include "chrome/browser/ui/search/instant_tab.h" |
| 33 #include "chrome/browser/ui/search/instant_test_utils.h" | 34 #include "chrome/browser/ui/search/instant_test_utils.h" |
| 34 #include "chrome/browser/ui/search/search_tab_helper.h" | 35 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 36 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 36 #include "chrome/browser/ui/webui/theme_source.h" | 37 #include "chrome/browser/ui/webui/theme_source.h" |
| 37 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
| 39 #include "chrome/common/chrome_switches.h" |
| 38 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/common/thumbnail_score.h" | 41 #include "chrome/common/thumbnail_score.h" |
| 40 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
| 41 #include "chrome/test/base/in_process_browser_test.h" | 43 #include "chrome/test/base/in_process_browser_test.h" |
| 42 #include "chrome/test/base/interactive_test_utils.h" | 44 #include "chrome/test/base/interactive_test_utils.h" |
| 43 #include "chrome/test/base/ui_test_utils.h" | 45 #include "chrome/test/base/ui_test_utils.h" |
| 44 #include "content/public/browser/navigation_controller.h" | 46 #include "content/public/browser/navigation_controller.h" |
| 45 #include "content/public/browser/navigation_entry.h" | 47 #include "content/public/browser/navigation_entry.h" |
| 46 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
| 47 #include "content/public/browser/render_process_host.h" | 49 #include "content/public/browser/render_process_host.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 188 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 187 | 189 |
| 188 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 190 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 189 EXPECT_FALSE(omnibox()->model()->has_focus()); | 191 EXPECT_FALSE(omnibox()->model()->has_focus()); |
| 190 | 192 |
| 191 // Delete any existing overlay. | 193 // Delete any existing overlay. |
| 192 instant()->overlay_.reset(); | 194 instant()->overlay_.reset(); |
| 193 EXPECT_FALSE(instant()->GetOverlayContents()); | 195 EXPECT_FALSE(instant()->GetOverlayContents()); |
| 194 | 196 |
| 195 // Refocus the omnibox. The InstantController should've preloaded Instant. | 197 // Refocus the omnibox. The InstantController should've preloaded Instant. |
| 196 FocusOmniboxAndWaitForInstantExtendedSupport(); | 198 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 197 | 199 |
| 198 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 200 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 199 EXPECT_TRUE(omnibox()->model()->has_focus()); | 201 EXPECT_TRUE(omnibox()->model()->has_focus()); |
| 200 | 202 |
| 201 content::WebContents* overlay = instant()->GetOverlayContents(); | 203 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 202 EXPECT_TRUE(overlay); | 204 EXPECT_TRUE(overlay); |
| 203 | 205 |
| 204 // Check that the page supports Instant, but it isn't showing. | 206 // Check that the page supports Instant, but it isn't showing. |
| 205 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 207 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 206 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 208 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 217 | 219 |
| 218 FocusOmnibox(); | 220 FocusOmnibox(); |
| 219 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 221 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 220 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 222 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 221 } | 223 } |
| 222 | 224 |
| 223 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { | 225 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { |
| 224 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 226 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 225 | 227 |
| 226 // Focus omnibox and confirm overlay isn't shown. | 228 // Focus omnibox and confirm overlay isn't shown. |
| 227 FocusOmniboxAndWaitForInstantExtendedSupport(); | 229 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 228 content::WebContents* overlay = instant()->GetOverlayContents(); | 230 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 229 EXPECT_TRUE(overlay); | 231 EXPECT_TRUE(overlay); |
| 230 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 232 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 231 EXPECT_TRUE(instant()->model()->mode().is_default()); | 233 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 232 | 234 |
| 233 // Typing in the omnibox should show the overlay. | 235 // Typing in the omnibox should show the overlay. |
| 234 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 236 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 235 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 237 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 236 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 238 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 237 } | 239 } |
| 238 | 240 |
| 239 // Test that middle clicking on a suggestion opens the result in a new tab. | 241 // Test that middle clicking on a suggestion opens the result in a new tab. |
| 240 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 242 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 241 MiddleClickOnSuggestionOpensInNewTab) { | 243 MiddleClickOnSuggestionOpensInNewTab) { |
| 242 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 244 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 243 FocusOmniboxAndWaitForInstantExtendedSupport(); | 245 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 244 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 246 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 245 | 247 |
| 246 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 248 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 247 | 249 |
| 248 // Typing in the omnibox should show the overlay. | 250 // Typing in the omnibox should show the overlay. |
| 249 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/")); | 251 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://www.example.com/")); |
| 250 | 252 |
| 251 // Create an event listener that opens the top suggestion in a new tab. | 253 // Create an event listener that opens the top suggestion in a new tab. |
| 252 EXPECT_TRUE(ExecuteScript( | 254 EXPECT_TRUE(ExecuteScript( |
| 253 "var rid = getApiHandle().nativeSuggestions[0].rid;" | 255 "var rid = getApiHandle().nativeSuggestions[0].rid;" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 271 browser()->tab_strip_model()->GetWebContentsAt(1); | 273 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 272 EXPECT_EQ("http://www.example.com/", new_tab_contents->GetURL().spec()); | 274 EXPECT_EQ("http://www.example.com/", new_tab_contents->GetURL().spec()); |
| 273 | 275 |
| 274 // Check that there are now two tabs. | 276 // Check that there are now two tabs. |
| 275 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 277 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 276 } | 278 } |
| 277 | 279 |
| 278 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 280 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 279 UnfocusingOmniboxDoesNotChangeSuggestions) { | 281 UnfocusingOmniboxDoesNotChangeSuggestions) { |
| 280 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 282 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 281 FocusOmniboxAndWaitForInstantExtendedSupport(); | 283 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 282 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 284 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 283 | 285 |
| 284 // Get a committed tab to work with. | 286 // Get a committed tab to work with. |
| 285 content::WebContents* instant_tab = instant()->GetOverlayContents(); | 287 content::WebContents* instant_tab = instant()->GetOverlayContents(); |
| 286 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("committed")); | 288 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("committed")); |
| 287 browser()->window()->GetLocationBar()->AcceptInput(); | 289 browser()->window()->GetLocationBar()->AcceptInput(); |
| 288 | 290 |
| 289 // Put focus back into the omnibox, type, and wait for some gray text. | 291 // Put focus back into the omnibox, type, and wait for some gray text. |
| 290 EXPECT_TRUE(content::ExecuteScript(instant_tab, | 292 EXPECT_TRUE(content::ExecuteScript(instant_tab, |
| 291 "suggestion = 'santa claus';")); | 293 "suggestion = 'santa claus';")); |
| 292 SetOmniboxTextAndWaitForSuggestion("santa "); | 294 SetOmniboxTextAndWaitForSuggestion("santa "); |
| 293 EXPECT_EQ(ASCIIToUTF16("claus"), GetGrayText()); | 295 EXPECT_EQ(ASCIIToUTF16("claus"), GetGrayText()); |
| 294 EXPECT_TRUE(content::ExecuteScript(instant_tab, | 296 EXPECT_TRUE(content::ExecuteScript(instant_tab, |
| 295 "onChangeCalls = onNativeSuggestionsCalls = 0;")); | 297 "onChangeCalls = onNativeSuggestionsCalls = 0;")); |
| 296 | 298 |
| 297 // Now unfocus the omnibox. | 299 // Now unfocus the omnibox. |
| 298 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 300 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 299 EXPECT_TRUE(UpdateSearchState(instant_tab)); | 301 EXPECT_TRUE(UpdateSearchState(instant_tab)); |
| 300 EXPECT_EQ(0, on_change_calls_); | 302 EXPECT_EQ(0, on_change_calls_); |
| 301 EXPECT_EQ(0, on_native_suggestions_calls_); | 303 EXPECT_EQ(0, on_native_suggestions_calls_); |
| 302 } | 304 } |
| 303 | 305 |
| 304 // Test that omnibox text is correctly set when overlay is committed with Enter. | 306 // Test that omnibox text is correctly set when overlay is committed with Enter. |
| 305 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) { | 307 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) { |
| 306 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 308 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 307 FocusOmniboxAndWaitForInstantExtendedSupport(); | 309 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 308 | 310 |
| 309 // The page will autocomplete once we set the omnibox value. | 311 // The page will autocomplete once we set the omnibox value. |
| 310 EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';")); | 312 EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';")); |
| 311 | 313 |
| 312 // Set the text, and wait for suggestions to show up. | 314 // Set the text, and wait for suggestions to show up. |
| 313 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("santa")); | 315 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("santa")); |
| 314 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); | 316 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); |
| 315 | 317 |
| 316 // Test that the current suggestion is correctly set. | 318 // Test that the current suggestion is correctly set. |
| 317 EXPECT_EQ(ASCIIToUTF16(" claus"), GetGrayText()); | 319 EXPECT_EQ(ASCIIToUTF16(" claus"), GetGrayText()); |
| 318 | 320 |
| 319 // Commit the search by pressing Enter. | 321 // Commit the search by pressing Enter. |
| 320 browser()->window()->GetLocationBar()->AcceptInput(); | 322 browser()->window()->GetLocationBar()->AcceptInput(); |
| 321 | 323 |
| 322 // 'Enter' commits the query as it was typed. | 324 // 'Enter' commits the query as it was typed. |
| 323 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); | 325 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); |
| 324 | 326 |
| 325 // Suggestion should be cleared at this point. | 327 // Suggestion should be cleared at this point. |
| 326 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 328 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 327 } | 329 } |
| 328 | 330 |
| 329 // Test that omnibox text is correctly set when committed with focus lost. | 331 // Test that omnibox text is correctly set when committed with focus lost. |
| 330 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) { | 332 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) { |
| 331 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 333 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 332 FocusOmniboxAndWaitForInstantExtendedSupport(); | 334 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 333 | 335 |
| 334 // Set autocomplete text (grey text). | 336 // Set autocomplete text (grey text). |
| 335 EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';")); | 337 EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';")); |
| 336 | 338 |
| 337 // Set the text, and wait for suggestions to show up. | 339 // Set the text, and wait for suggestions to show up. |
| 338 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("johnny")); | 340 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("johnny")); |
| 339 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); | 341 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); |
| 340 | 342 |
| 341 // Test that the current suggestion is correctly set. | 343 // Test that the current suggestion is correctly set. |
| 342 EXPECT_EQ(ASCIIToUTF16(" depp"), GetGrayText()); | 344 EXPECT_EQ(ASCIIToUTF16(" depp"), GetGrayText()); |
| 343 | 345 |
| 344 // Commit the overlay by lost focus (e.g. clicking on the page). | 346 // Commit the overlay by lost focus (e.g. clicking on the page). |
| 345 instant()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); | 347 instant()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); |
| 346 | 348 |
| 347 // Omnibox text and suggestion should not be changed. | 349 // Omnibox text and suggestion should not be changed. |
| 348 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); | 350 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); |
| 349 EXPECT_EQ(ASCIIToUTF16(" depp"), GetGrayText()); | 351 EXPECT_EQ(ASCIIToUTF16(" depp"), GetGrayText()); |
| 350 } | 352 } |
| 351 | 353 |
| 352 // Test that omnibox text is correctly set when clicking on committed SERP. | 354 // Test that omnibox text is correctly set when clicking on committed SERP. |
| 353 // Disabled on Mac because omnibox focus loss is not working correctly. | 355 // Disabled on Mac because omnibox focus loss is not working correctly. |
| 354 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 356 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 355 OmniboxTextUponFocusedCommittedSERP) { | 357 OmniboxTextUponFocusedCommittedSERP) { |
| 356 // Setup Instant. | 358 // Setup Instant. |
| 357 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 359 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 358 FocusOmniboxAndWaitForInstantExtendedSupport(); | 360 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 359 | 361 |
| 360 // Create an observer to wait for the instant tab to support Instant. | 362 // Create an observer to wait for the instant tab to support Instant. |
| 361 content::WindowedNotificationObserver observer( | 363 content::WindowedNotificationObserver observer( |
| 362 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 364 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 363 content::NotificationService::AllSources()); | 365 content::NotificationService::AllSources()); |
| 364 | 366 |
| 365 // Do a search and commit it. | 367 // Do a search and commit it. |
| 366 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello k")); | 368 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello k")); |
| 367 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); | 369 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); |
| 368 browser()->window()->GetLocationBar()->AcceptInput(); | 370 browser()->window()->GetLocationBar()->AcceptInput(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 382 EXPECT_EQ(ASCIIToUTF16("hello"), omnibox()->GetText()); | 384 EXPECT_EQ(ASCIIToUTF16("hello"), omnibox()->GetText()); |
| 383 EXPECT_EQ(ASCIIToUTF16(" kitty"), GetGrayText()); | 385 EXPECT_EQ(ASCIIToUTF16(" kitty"), GetGrayText()); |
| 384 } | 386 } |
| 385 | 387 |
| 386 // Checks that a previous Navigation suggestion is not re-used when a search | 388 // Checks that a previous Navigation suggestion is not re-used when a search |
| 387 // suggestion comes in. | 389 // suggestion comes in. |
| 388 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 390 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 389 NavigationSuggestionIsDiscardedUponSearchSuggestion) { | 391 NavigationSuggestionIsDiscardedUponSearchSuggestion) { |
| 390 // Setup Instant. | 392 // Setup Instant. |
| 391 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 393 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 392 FocusOmniboxAndWaitForInstantExtendedSupport(); | 394 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 393 | 395 |
| 394 // Tell the page to send a URL suggestion. | 396 // Tell the page to send a URL suggestion. |
| 395 EXPECT_TRUE(ExecuteScript("suggestion = 'http://www.example.com';" | 397 EXPECT_TRUE(ExecuteScript("suggestion = 'http://www.example.com';" |
| 396 "behavior = 1;")); | 398 "behavior = 1;")); |
| 397 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("exa")); | 399 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("exa")); |
| 398 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); | 400 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); |
| 399 | 401 |
| 400 // Now send a search suggestion and see that Navigation suggestion is no | 402 // Now send a search suggestion and see that Navigation suggestion is no |
| 401 // longer kept. | 403 // longer kept. |
| 402 EXPECT_TRUE(ExecuteScript("suggestion = 'exams are great';" | 404 EXPECT_TRUE(ExecuteScript("suggestion = 'exams are great';" |
| 403 "behavior = 2;")); | 405 "behavior = 2;")); |
| 404 SetOmniboxText("exam"); | 406 SetOmniboxText("exam"); |
| 405 // Wait for JavaScript to run handleOnChange by executing a blank script. | 407 // Wait for JavaScript to run handleOnChange by executing a blank script. |
| 406 EXPECT_TRUE(ExecuteScript(std::string())); | 408 EXPECT_TRUE(ExecuteScript(std::string())); |
| 407 | 409 |
| 408 instant()->overlay()->contents()->GetView()->Focus(); | 410 instant()->overlay()->contents()->GetView()->Focus(); |
| 409 EXPECT_EQ(ASCIIToUTF16("exam"), omnibox()->GetText()); | 411 EXPECT_EQ(ASCIIToUTF16("exam"), omnibox()->GetText()); |
| 410 EXPECT_EQ(ASCIIToUTF16("s are great"), GetGrayText()); | 412 EXPECT_EQ(ASCIIToUTF16("s are great"), GetGrayText()); |
| 411 | 413 |
| 412 // TODO(jered): Remove this after fixing OnBlur(). | 414 // TODO(jered): Remove this after fixing OnBlur(). |
| 413 omnibox()->RevertAll(); | 415 omnibox()->RevertAll(); |
| 414 } | 416 } |
| 415 | 417 |
| 416 // This test simulates a search provider using the InstantExtended API to | 418 // This test simulates a search provider using the InstantExtended API to |
| 417 // navigate through the suggested results and back to the original user query. | 419 // navigate through the suggested results and back to the original user query. |
| 418 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { | 420 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { |
| 419 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 421 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 420 FocusOmniboxAndWaitForInstantExtendedSupport(); | 422 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 421 | 423 |
| 422 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello")); | 424 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello")); |
| 423 EXPECT_EQ("hello", GetOmniboxText()); | 425 EXPECT_EQ("hello", GetOmniboxText()); |
| 424 | 426 |
| 425 SendDownArrow(); | 427 SendDownArrow(); |
| 426 EXPECT_EQ("result 1", GetOmniboxText()); | 428 EXPECT_EQ("result 1", GetOmniboxText()); |
| 427 SendDownArrow(); | 429 SendDownArrow(); |
| 428 EXPECT_EQ("result 2", GetOmniboxText()); | 430 EXPECT_EQ("result 2", GetOmniboxText()); |
| 429 SendUpArrow(); | 431 SendUpArrow(); |
| 430 EXPECT_EQ("result 1", GetOmniboxText()); | 432 EXPECT_EQ("result 1", GetOmniboxText()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 456 | 458 |
| 457 // This test simulates a search provider using the InstantExtended API to | 459 // This test simulates a search provider using the InstantExtended API to |
| 458 // navigate through the suggested results and back to the original user query. | 460 // navigate through the suggested results and back to the original user query. |
| 459 // If this test starts to flake, it may be that the second call to AcceptInput | 461 // If this test starts to flake, it may be that the second call to AcceptInput |
| 460 // below causes instant()->instant_tab() to no longer be valid due to e.g. a | 462 // below causes instant()->instant_tab() to no longer be valid due to e.g. a |
| 461 // navigation. In that case, see https://codereview.chromium.org/12895007/#msg28 | 463 // navigation. In that case, see https://codereview.chromium.org/12895007/#msg28 |
| 462 // and onwards for possible alternatives. | 464 // and onwards for possible alternatives. |
| 463 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 465 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 464 MAYBE_NavigateToURLSuggestionHitEnterAndLookForSubmit) { | 466 MAYBE_NavigateToURLSuggestionHitEnterAndLookForSubmit) { |
| 465 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 467 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 466 FocusOmniboxAndWaitForInstantExtendedSupport(); | 468 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 467 | 469 |
| 468 // Create an observer to wait for the instant tab to support Instant. | 470 // Create an observer to wait for the instant tab to support Instant. |
| 469 content::WindowedNotificationObserver observer( | 471 content::WindowedNotificationObserver observer( |
| 470 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 472 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 471 content::NotificationService::AllSources()); | 473 content::NotificationService::AllSources()); |
| 472 | 474 |
| 473 // Do a search and commit it. | 475 // Do a search and commit it. |
| 474 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello k")); | 476 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello k")); |
| 475 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); | 477 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); |
| 476 browser()->window()->GetLocationBar()->AcceptInput(); | 478 browser()->window()->GetLocationBar()->AcceptInput(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 501 EXPECT_TRUE(UpdateSearchState(instant()->instant_tab()->contents())); | 503 EXPECT_TRUE(UpdateSearchState(instant()->instant_tab()->contents())); |
| 502 EXPECT_EQ(2, submit_count_); | 504 EXPECT_EQ(2, submit_count_); |
| 503 EXPECT_EQ(old_query_value, query_value_); | 505 EXPECT_EQ(old_query_value, query_value_); |
| 504 } | 506 } |
| 505 | 507 |
| 506 // This test simulates a search provider using the InstantExtended API to | 508 // This test simulates a search provider using the InstantExtended API to |
| 507 // navigate through the suggested results and hitting escape to get back to the | 509 // navigate through the suggested results and hitting escape to get back to the |
| 508 // original user query. | 510 // original user query. |
| 509 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { | 511 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { |
| 510 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 512 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 511 FocusOmniboxAndWaitForInstantExtendedSupport(); | 513 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 512 | 514 |
| 513 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello")); | 515 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("hello")); |
| 514 EXPECT_EQ("hello", GetOmniboxText()); | 516 EXPECT_EQ("hello", GetOmniboxText()); |
| 515 | 517 |
| 516 SendDownArrow(); | 518 SendDownArrow(); |
| 517 EXPECT_EQ("result 1", GetOmniboxText()); | 519 EXPECT_EQ("result 1", GetOmniboxText()); |
| 518 SendDownArrow(); | 520 SendDownArrow(); |
| 519 EXPECT_EQ("result 2", GetOmniboxText()); | 521 EXPECT_EQ("result 2", GetOmniboxText()); |
| 520 SendEscape(); | 522 SendEscape(); |
| 521 EXPECT_EQ("hello", GetOmniboxText()); | 523 EXPECT_EQ("hello", GetOmniboxText()); |
| 522 | 524 |
| 523 // Ensure that the API's value is set correctly. | 525 // Ensure that the API's value is set correctly. |
| 524 std::string result; | 526 std::string result; |
| 525 EXPECT_TRUE(GetStringFromJS(instant()->GetOverlayContents(), | 527 EXPECT_TRUE(GetStringFromJS(instant()->GetOverlayContents(), |
| 526 "window.chrome.searchBox.value", | 528 "window.chrome.searchBox.value", |
| 527 &result)); | 529 &result)); |
| 528 EXPECT_EQ("hello", result); | 530 EXPECT_EQ("hello", result); |
| 529 | 531 |
| 530 EXPECT_TRUE(HasUserInputInProgress()); | 532 EXPECT_TRUE(HasUserInputInProgress()); |
| 531 EXPECT_FALSE(HasTemporaryText()); | 533 EXPECT_FALSE(HasTemporaryText()); |
| 532 | 534 |
| 533 // Commit the search by pressing Enter. | 535 // Commit the search by pressing Enter. |
| 534 browser()->window()->GetLocationBar()->AcceptInput(); | 536 browser()->window()->GetLocationBar()->AcceptInput(); |
| 535 EXPECT_EQ("hello", GetOmniboxText()); | 537 EXPECT_EQ("hello", GetOmniboxText()); |
| 536 } | 538 } |
| 537 | 539 |
| 538 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PressEscapeWithBlueText) { | 540 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PressEscapeWithBlueText) { |
| 539 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 541 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 540 FocusOmniboxAndWaitForInstantExtendedSupport(); | 542 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 541 | 543 |
| 542 // Set blue text completion. | 544 // Set blue text completion. |
| 543 EXPECT_TRUE(ExecuteScript("suggestion = 'chimichanga.com';" | 545 EXPECT_TRUE(ExecuteScript("suggestion = 'chimichanga.com';" |
| 544 "behavior = 1;")); | 546 "behavior = 1;")); |
| 545 | 547 |
| 546 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("chimi")); | 548 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("chimi")); |
| 547 | 549 |
| 548 EXPECT_EQ(ASCIIToUTF16("chimichanga.com"), omnibox()->GetText()); | 550 EXPECT_EQ(ASCIIToUTF16("chimichanga.com"), omnibox()->GetText()); |
| 549 EXPECT_EQ(ASCIIToUTF16("changa.com"), GetBlueText()); | 551 EXPECT_EQ(ASCIIToUTF16("changa.com"), GetBlueText()); |
| 550 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 552 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 567 EXPECT_EQ(ASCIIToUTF16("changa.com"), GetBlueText()); | 569 EXPECT_EQ(ASCIIToUTF16("changa.com"), GetBlueText()); |
| 568 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 570 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 569 | 571 |
| 570 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 572 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
| 571 EXPECT_EQ(0, on_native_suggestions_calls_); | 573 EXPECT_EQ(0, on_native_suggestions_calls_); |
| 572 EXPECT_EQ(0, on_change_calls_); | 574 EXPECT_EQ(0, on_change_calls_); |
| 573 } | 575 } |
| 574 | 576 |
| 575 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PressEscapeWithGrayText) { | 577 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PressEscapeWithGrayText) { |
| 576 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 578 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 577 FocusOmniboxAndWaitForInstantExtendedSupport(); | 579 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 578 | 580 |
| 579 // Set gray text completion. | 581 // Set gray text completion. |
| 580 EXPECT_TRUE(ExecuteScript("suggestion = 'cowabunga';" | 582 EXPECT_TRUE(ExecuteScript("suggestion = 'cowabunga';" |
| 581 "behavior = 2;")); | 583 "behavior = 2;")); |
| 582 | 584 |
| 583 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("cowa")); | 585 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("cowa")); |
| 584 | 586 |
| 585 EXPECT_EQ(ASCIIToUTF16("cowa"), omnibox()->GetText()); | 587 EXPECT_EQ(ASCIIToUTF16("cowa"), omnibox()->GetText()); |
| 586 EXPECT_EQ(ASCIIToUTF16(""), GetBlueText()); | 588 EXPECT_EQ(ASCIIToUTF16(""), GetBlueText()); |
| 587 EXPECT_EQ(ASCIIToUTF16("bunga"), GetGrayText()); | 589 EXPECT_EQ(ASCIIToUTF16("bunga"), GetGrayText()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 605 EXPECT_EQ(ASCIIToUTF16("bunga"), GetGrayText()); | 607 EXPECT_EQ(ASCIIToUTF16("bunga"), GetGrayText()); |
| 606 | 608 |
| 607 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 609 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
| 608 EXPECT_EQ(0, on_native_suggestions_calls_); | 610 EXPECT_EQ(0, on_native_suggestions_calls_); |
| 609 EXPECT_EQ(0, on_change_calls_); | 611 EXPECT_EQ(0, on_change_calls_); |
| 610 } | 612 } |
| 611 | 613 |
| 612 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) { | 614 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) { |
| 613 // Setup Instant. | 615 // Setup Instant. |
| 614 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 616 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 615 FocusOmniboxAndWaitForInstantExtendedSupport(); | 617 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 616 | 618 |
| 617 // NTP contents should be preloaded. | 619 // NTP contents should be preloaded. |
| 618 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 620 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 619 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 621 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 620 EXPECT_TRUE(ntp_contents); | 622 EXPECT_TRUE(ntp_contents); |
| 621 } | 623 } |
| 622 | 624 |
| 623 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) { | 625 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) { |
| 624 // Setup Instant. | 626 // Setup Instant. |
| 625 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 627 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 626 FocusOmniboxAndWaitForInstantExtendedSupport(); | 628 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 627 | 629 |
| 628 // NTP contents should be preloaded. | 630 // NTP contents should be preloaded. |
| 629 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 631 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 630 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 632 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 631 EXPECT_TRUE(ntp_contents); | 633 EXPECT_TRUE(ntp_contents); |
| 632 | 634 |
| 633 // Open new tab. Preloaded NTP contents should have been used. | 635 // Open new tab. Preloaded NTP contents should have been used. |
| 634 ui_test_utils::NavigateToURLWithDisposition( | 636 ui_test_utils::NavigateToURLWithDisposition( |
| 635 browser(), | 637 browser(), |
| 636 GURL(chrome::kChromeUINewTabURL), | 638 GURL(chrome::kChromeUINewTabURL), |
| 637 NEW_FOREGROUND_TAB, | 639 NEW_FOREGROUND_TAB, |
| 638 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 640 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 639 content::WebContents* active_tab = | 641 content::WebContents* active_tab = |
| 640 browser()->tab_strip_model()->GetActiveWebContents(); | 642 browser()->tab_strip_model()->GetActiveWebContents(); |
| 641 EXPECT_EQ(ntp_contents, active_tab); | 643 EXPECT_EQ(ntp_contents, active_tab); |
| 642 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); | 644 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); |
| 643 } | 645 } |
| 644 | 646 |
| 645 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) { | 647 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) { |
| 646 // Setup Instant. | 648 // Setup Instant. |
| 647 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 649 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 648 FocusOmniboxAndWaitForInstantExtendedSupport(); | 650 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 649 | 651 |
| 650 // NTP contents should be preloaded. | 652 // NTP contents should be preloaded. |
| 651 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 653 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 652 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 654 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 653 EXPECT_TRUE(ntp_contents); | 655 EXPECT_TRUE(ntp_contents); |
| 654 | 656 |
| 655 // Open new tab. Preloaded NTP contents should have been used. | 657 // Open new tab. Preloaded NTP contents should have been used. |
| 656 ui_test_utils::NavigateToURLWithDisposition( | 658 ui_test_utils::NavigateToURLWithDisposition( |
| 657 browser(), | 659 browser(), |
| 658 GURL(chrome::kChromeUINewTabURL), | 660 GURL(chrome::kChromeUINewTabURL), |
| 659 CURRENT_TAB, | 661 CURRENT_TAB, |
| 660 ui_test_utils::BROWSER_TEST_NONE); | 662 ui_test_utils::BROWSER_TEST_NONE); |
| 661 content::WebContents* active_tab = | 663 content::WebContents* active_tab = |
| 662 browser()->tab_strip_model()->GetActiveWebContents(); | 664 browser()->tab_strip_model()->GetActiveWebContents(); |
| 663 EXPECT_EQ(ntp_contents, active_tab); | 665 EXPECT_EQ(ntp_contents, active_tab); |
| 664 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); | 666 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); |
| 665 } | 667 } |
| 666 | 668 |
| 667 // TODO(samarth): re-enable when fixing the infinite reload on shutdown. | 669 // TODO(samarth): re-enable when fixing the infinite reload on shutdown. |
| 668 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 670 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 669 DISABLED_PreloadedNTPForWrongProvider) { | 671 DISABLED_PreloadedNTPForWrongProvider) { |
| 670 // Setup Instant. | 672 // Setup Instant. |
| 671 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 673 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 672 FocusOmniboxAndWaitForInstantExtendedSupport(); | 674 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 673 | 675 |
| 674 // NTP contents should be preloaded. | 676 // NTP contents should be preloaded. |
| 675 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 677 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 676 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 678 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 677 EXPECT_TRUE(ntp_contents); | 679 EXPECT_TRUE(ntp_contents); |
| 678 GURL ntp_url = ntp_contents->GetURL(); | 680 GURL ntp_url = ntp_contents->GetURL(); |
| 679 | 681 |
| 680 // Change providers. | 682 // Change providers. |
| 681 SetInstantURL("chrome://blank"); | 683 SetInstantURL("chrome://blank"); |
| 682 | 684 |
| 683 // Open new tab. Preloaded NTP contents should have not been used. | 685 // Open new tab. Preloaded NTP contents should have not been used. |
| 684 ui_test_utils::NavigateToURLWithDisposition( | 686 ui_test_utils::NavigateToURLWithDisposition( |
| 685 browser(), | 687 browser(), |
| 686 GURL(chrome::kChromeUINewTabURL), | 688 GURL(chrome::kChromeUINewTabURL), |
| 687 NEW_FOREGROUND_TAB, | 689 NEW_FOREGROUND_TAB, |
| 688 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 690 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 689 content::WebContents* active_tab = | 691 content::WebContents* active_tab = |
| 690 browser()->tab_strip_model()->GetActiveWebContents(); | 692 browser()->tab_strip_model()->GetActiveWebContents(); |
| 691 EXPECT_NE(ntp_url, active_tab->GetURL()); | 693 EXPECT_NE(ntp_url, active_tab->GetURL()); |
| 692 } | 694 } |
| 693 | 695 |
| 694 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) { | 696 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) { |
| 695 // Setup Instant. | 697 // Setup Instant. |
| 696 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 698 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 697 FocusOmniboxAndWaitForInstantExtendedSupport(); | 699 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 698 | 700 |
| 699 // Explicitly unfocus the omnibox. | 701 // Explicitly unfocus the omnibox. |
| 700 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 702 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 701 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 703 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 702 EXPECT_FALSE(omnibox()->model()->has_focus()); | 704 EXPECT_FALSE(omnibox()->model()->has_focus()); |
| 703 | 705 |
| 704 // Open new tab. Preloaded NTP contents should have been used. | 706 // Open new tab. Preloaded NTP contents should have been used. |
| 705 ui_test_utils::NavigateToURLWithDisposition( | 707 ui_test_utils::NavigateToURLWithDisposition( |
| 706 browser(), | 708 browser(), |
| 707 GURL(chrome::kChromeUINewTabURL), | 709 GURL(chrome::kChromeUINewTabURL), |
| 708 NEW_FOREGROUND_TAB, | 710 NEW_FOREGROUND_TAB, |
| 709 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 711 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 710 | 712 |
| 711 // Omnibox should have focus. | 713 // Omnibox should have focus. |
| 712 EXPECT_TRUE(omnibox()->model()->has_focus()); | 714 EXPECT_TRUE(omnibox()->model()->has_focus()); |
| 713 } | 715 } |
| 714 | 716 |
| 715 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) { | 717 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) { |
| 716 // Setup Instant. | 718 // Setup Instant. |
| 717 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 719 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 718 FocusOmniboxAndWaitForInstantExtendedSupport(); | 720 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 719 | 721 |
| 720 // Open new tab. Preloaded NTP contents should have been used. | 722 // Open new tab. Preloaded NTP contents should have been used. |
| 721 ui_test_utils::NavigateToURLWithDisposition( | 723 ui_test_utils::NavigateToURLWithDisposition( |
| 722 browser(), | 724 browser(), |
| 723 GURL(chrome::kChromeUINewTabURL), | 725 GURL(chrome::kChromeUINewTabURL), |
| 724 CURRENT_TAB, | 726 CURRENT_TAB, |
| 725 ui_test_utils::BROWSER_TEST_NONE); | 727 ui_test_utils::BROWSER_TEST_NONE); |
| 726 | 728 |
| 727 // Omnibox should be empty. | 729 // Omnibox should be empty. |
| 728 EXPECT_TRUE(omnibox()->GetText().empty()); | 730 EXPECT_TRUE(omnibox()->GetText().empty()); |
| 729 } | 731 } |
| 730 | 732 |
| 731 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. | 733 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. |
| 732 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NoFaviconOnNewTabPage) { | 734 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NoFaviconOnNewTabPage) { |
| 733 // Setup Instant. | 735 // Setup Instant. |
| 734 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 736 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 735 FocusOmniboxAndWaitForInstantExtendedSupport(); | 737 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 736 | 738 |
| 737 // Open new tab. Preloaded NTP contents should have been used. | 739 // Open new tab. Preloaded NTP contents should have been used. |
| 738 ui_test_utils::NavigateToURLWithDisposition( | 740 ui_test_utils::NavigateToURLWithDisposition( |
| 739 browser(), | 741 browser(), |
| 740 GURL(chrome::kChromeUINewTabURL), | 742 GURL(chrome::kChromeUINewTabURL), |
| 741 CURRENT_TAB, | 743 CURRENT_TAB, |
| 742 ui_test_utils::BROWSER_TEST_NONE); | 744 ui_test_utils::BROWSER_TEST_NONE); |
| 743 | 745 |
| 744 // No favicon should be shown. | 746 // No favicon should be shown. |
| 745 content::WebContents* active_tab = | 747 content::WebContents* active_tab = |
| 746 browser()->tab_strip_model()->GetActiveWebContents(); | 748 browser()->tab_strip_model()->GetActiveWebContents(); |
| 747 FaviconTabHelper* favicon_tab_helper = | 749 FaviconTabHelper* favicon_tab_helper = |
| 748 FaviconTabHelper::FromWebContents(active_tab); | 750 FaviconTabHelper::FromWebContents(active_tab); |
| 749 EXPECT_FALSE(favicon_tab_helper->ShouldDisplayFavicon()); | 751 EXPECT_FALSE(favicon_tab_helper->ShouldDisplayFavicon()); |
| 750 | 752 |
| 751 // Favicon should be shown off the NTP. | 753 // Favicon should be shown off the NTP. |
| 752 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 754 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 753 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 755 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 754 favicon_tab_helper = FaviconTabHelper::FromWebContents(active_tab); | 756 favicon_tab_helper = FaviconTabHelper::FromWebContents(active_tab); |
| 755 EXPECT_TRUE(favicon_tab_helper->ShouldDisplayFavicon()); | 757 EXPECT_TRUE(favicon_tab_helper->ShouldDisplayFavicon()); |
| 756 } | 758 } |
| 757 | 759 |
| 758 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputOnNTPDoesntShowOverlay) { | 760 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputOnNTPDoesntShowOverlay) { |
| 759 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 761 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 760 | 762 |
| 761 // Focus omnibox and confirm overlay isn't shown. | 763 // Focus omnibox and confirm overlay isn't shown. |
| 762 FocusOmniboxAndWaitForInstantExtendedSupport(); | 764 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 763 content::WebContents* overlay = instant()->GetOverlayContents(); | 765 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 764 EXPECT_TRUE(overlay); | 766 EXPECT_TRUE(overlay); |
| 765 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 767 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 766 EXPECT_TRUE(instant()->model()->mode().is_default()); | 768 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 767 | 769 |
| 768 // Navigate to the NTP. | 770 // Navigate to the NTP. |
| 769 ui_test_utils::NavigateToURLWithDisposition( | 771 ui_test_utils::NavigateToURLWithDisposition( |
| 770 browser(), | 772 browser(), |
| 771 GURL(chrome::kChromeUINewTabURL), | 773 GURL(chrome::kChromeUINewTabURL), |
| 772 CURRENT_TAB, | 774 CURRENT_TAB, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 783 // it, which is rendered in the dedicated Instant renderer process. | 785 // it, which is rendered in the dedicated Instant renderer process. |
| 784 // | 786 // |
| 785 // TODO(sreeram): Fix this up when we stop doing crazy things on init. | 787 // TODO(sreeram): Fix this up when we stop doing crazy things on init. |
| 786 InstantService* instant_service = | 788 InstantService* instant_service = |
| 787 InstantServiceFactory::GetForProfile(browser()->profile()); | 789 InstantServiceFactory::GetForProfile(browser()->profile()); |
| 788 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 790 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 789 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); | 791 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); |
| 790 | 792 |
| 791 // Setup Instant. | 793 // Setup Instant. |
| 792 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 794 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 793 FocusOmniboxAndWaitForInstantExtendedSupport(); | 795 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 794 | 796 |
| 795 // The registered Instant render process should still exist. | 797 // The registered Instant render process should still exist. |
| 796 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); | 798 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); |
| 797 | 799 |
| 798 // And the Instant overlay and ntp should live inside it. | 800 // And the Instant overlay and ntp should live inside it. |
| 799 content::WebContents* overlay = instant()->GetOverlayContents(); | 801 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 800 EXPECT_TRUE(instant_service->IsInstantProcess( | 802 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 801 overlay->GetRenderProcessHost()->GetID())); | 803 overlay->GetRenderProcessHost()->GetID())); |
| 802 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 804 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 803 EXPECT_TRUE(instant_service->IsInstantProcess( | 805 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 804 ntp_contents->GetRenderProcessHost()->GetID())); | 806 ntp_contents->GetRenderProcessHost()->GetID())); |
| 805 | 807 |
| 806 // Navigating to the NTP should use the Instant render process. | 808 // Navigating to the NTP should use the Instant render process. |
| 807 ui_test_utils::NavigateToURLWithDisposition( | 809 ui_test_utils::NavigateToURLWithDisposition( |
| 808 browser(), | 810 browser(), |
| 809 GURL(chrome::kChromeUINewTabURL), | 811 GURL(chrome::kChromeUINewTabURL), |
| 810 CURRENT_TAB, | 812 CURRENT_TAB, |
| 811 ui_test_utils::BROWSER_TEST_NONE); | 813 ui_test_utils::BROWSER_TEST_NONE); |
| 812 content::WebContents* active_tab = | 814 content::WebContents* active_tab = |
| 813 browser()->tab_strip_model()->GetActiveWebContents(); | 815 browser()->tab_strip_model()->GetActiveWebContents(); |
| 814 EXPECT_TRUE(instant_service->IsInstantProcess( | 816 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 815 active_tab->GetRenderProcessHost()->GetID())); | 817 active_tab->GetRenderProcessHost()->GetID())); |
| 816 | 818 |
| 817 // Navigating elsewhere should not use the Instant render process. | 819 // Navigating elsewhere should not use the Instant render process. |
| 818 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 820 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
| 819 EXPECT_FALSE(instant_service->IsInstantProcess( | 821 EXPECT_FALSE(instant_service->IsInstantProcess( |
| 820 active_tab->GetRenderProcessHost()->GetID())); | 822 active_tab->GetRenderProcessHost()->GetID())); |
| 821 } | 823 } |
| 822 | 824 |
| 825 // Test that a search query will not be displayed for navsuggest queries. |
| 826 IN_PROC_BROWSER_TEST_F( |
| 827 InstantExtendedTest, SearchQueryNotDisplayedForNavsuggest) { |
| 828 // Use only the local overlay. |
| 829 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 830 switches::kEnableLocalOnlyInstantExtendedAPI); |
| 831 ASSERT_TRUE(chrome::IsLocalOnlyInstantExtendedAPIEnabled()); |
| 832 |
| 833 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 834 |
| 835 // The second argument indicates to use only the local overlay and NTP. |
| 836 instant()->SetInstantEnabled(true, true); |
| 837 |
| 838 // Focus omnibox and confirm overlay isn't shown. |
| 839 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 840 |
| 841 // Typing in the omnibox should show the overlay. |
| 842 SetOmniboxText("face"); |
| 843 |
| 844 // Create an event listener that opens the top suggestion in a new tab. |
| 845 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 846 |
| 847 // Add a navsuggest suggestion. |
| 848 instant()->SetSuggestions( |
| 849 instant()->overlay()->contents(), |
| 850 std::vector<InstantSuggestion>( |
| 851 1, |
| 852 InstantSuggestion(ASCIIToUTF16("http://facemash.com/"), |
| 853 INSTANT_COMPLETE_NOW, |
| 854 INSTANT_SUGGESTION_URL, |
| 855 ASCIIToUTF16("face")))); |
| 856 |
| 857 while (!omnibox()->model()->autocomplete_controller()->done()) { |
| 858 content::WindowedNotificationObserver autocomplete_observer( |
| 859 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, |
| 860 content::NotificationService::AllSources()); |
| 861 autocomplete_observer.Wait(); |
| 862 } |
| 863 |
| 864 std::string nativeSuggestionString = |
| 865 "chrome.embeddedSearch.searchBox.nativeSuggestions"; |
| 866 |
| 867 int nativeSuggestionsLength; |
| 868 EXPECT_TRUE( |
| 869 GetIntFromJS(overlay, nativeSuggestionString + ".length", |
| 870 &nativeSuggestionsLength)); |
| 871 for (int i = 0; i < nativeSuggestionsLength; ++i) { |
| 872 std::string nativeSuggestionsAtIndex = |
| 873 nativeSuggestionString + "[" + base::IntToString(i) + "]"; |
| 874 |
| 875 bool isSearchPropertyExists; |
| 876 EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionsAtIndex + |
| 877 ".hasOwnProperty('is_search')", &isSearchPropertyExists)); |
| 878 |
| 879 // Verify that if this is a search suggestion the type is not navsuggest. |
| 880 if (isSearchPropertyExists) { |
| 881 bool is_search; |
| 882 EXPECT_TRUE(GetBoolFromJS( |
| 883 overlay, nativeSuggestionsAtIndex + ".is_search", &is_search)); |
| 884 |
| 885 std::string type; |
| 886 EXPECT_TRUE( |
| 887 GetStringFromJS(overlay, nativeSuggestionsAtIndex + ".type", &type)); |
| 888 EXPECT_FALSE(is_search && type == "navsuggest"); |
| 889 } |
| 890 } |
| 891 } |
| 892 |
| 823 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in | 893 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in |
| 824 // a tab uses a new BrowsingInstance, to avoid conflicts in the | 894 // a tab uses a new BrowsingInstance, to avoid conflicts in the |
| 825 // NavigationController. | 895 // NavigationController. |
| 826 // Flaky: http://crbug.com/177516 | 896 // Flaky: http://crbug.com/177516 |
| 827 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { | 897 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { |
| 828 // Setup Instant. | 898 // Setup Instant. |
| 829 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 899 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 830 FocusOmniboxAndWaitForInstantExtendedSupport(); | 900 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 831 | 901 |
| 832 // Check that the uncommited ntp page and uncommited overlay have unrelated | 902 // Check that the uncommited ntp page and uncommited overlay have unrelated |
| 833 // site instances. | 903 // site instances. |
| 834 // TODO(sreeram): |ntp_| is going away, so this check can be removed in the | 904 // TODO(sreeram): |ntp_| is going away, so this check can be removed in the |
| 835 // future. | 905 // future. |
| 836 content::WebContents* overlay = instant()->GetOverlayContents(); | 906 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 837 content::WebContents* ntp_contents = instant()->ntp_->contents(); | 907 content::WebContents* ntp_contents = instant()->ntp_->contents(); |
| 838 EXPECT_FALSE(overlay->GetSiteInstance()->IsRelatedSiteInstance( | 908 EXPECT_FALSE(overlay->GetSiteInstance()->IsRelatedSiteInstance( |
| 839 ntp_contents->GetSiteInstance())); | 909 ntp_contents->GetSiteInstance())); |
| 840 | 910 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 865 scoped_refptr<content::SiteInstance> second_site_instance = | 935 scoped_refptr<content::SiteInstance> second_site_instance = |
| 866 second_active_tab->GetSiteInstance(); | 936 second_active_tab->GetSiteInstance(); |
| 867 EXPECT_NE(first_site_instance, second_site_instance); | 937 EXPECT_NE(first_site_instance, second_site_instance); |
| 868 EXPECT_FALSE(first_site_instance->IsRelatedSiteInstance( | 938 EXPECT_FALSE(first_site_instance->IsRelatedSiteInstance( |
| 869 second_site_instance)); | 939 second_site_instance)); |
| 870 } | 940 } |
| 871 | 941 |
| 872 // Tests that suggestions are sanity checked. | 942 // Tests that suggestions are sanity checked. |
| 873 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) { | 943 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) { |
| 874 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 944 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 875 FocusOmniboxAndWaitForInstantExtendedSupport(); | 945 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 876 | 946 |
| 877 // Do not set gray text that is not a suffix of the query. | 947 // Do not set gray text that is not a suffix of the query. |
| 878 EXPECT_TRUE(ExecuteScript("suggestion = 'potato';" | 948 EXPECT_TRUE(ExecuteScript("suggestion = 'potato';" |
| 879 "behavior = 2;")); | 949 "behavior = 2;")); |
| 880 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 950 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 881 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); | 951 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); |
| 882 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 952 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 883 | 953 |
| 884 omnibox()->RevertAll(); | 954 omnibox()->RevertAll(); |
| 885 | 955 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 SetOmniboxText("www.example.com/"); | 1023 SetOmniboxText("www.example.com/"); |
| 954 omnibox()->OnAfterPossibleChange(); | 1024 omnibox()->OnAfterPossibleChange(); |
| 955 EXPECT_EQ(ASCIIToUTF16("www.example.com/"), omnibox()->GetText()); | 1025 EXPECT_EQ(ASCIIToUTF16("www.example.com/"), omnibox()->GetText()); |
| 956 } | 1026 } |
| 957 | 1027 |
| 958 // Tests that a previous navigation suggestion is not discarded if it's not | 1028 // Tests that a previous navigation suggestion is not discarded if it's not |
| 959 // stale. | 1029 // stale. |
| 960 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 1030 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 961 NavigationSuggestionIsNotDiscarded) { | 1031 NavigationSuggestionIsNotDiscarded) { |
| 962 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1032 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 963 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1033 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 964 | 1034 |
| 965 // Tell the page to send a URL suggestion. | 1035 // Tell the page to send a URL suggestion. |
| 966 EXPECT_TRUE(ExecuteScript("suggestion = 'http://www.example.com';" | 1036 EXPECT_TRUE(ExecuteScript("suggestion = 'http://www.example.com';" |
| 967 "behavior = 1;")); | 1037 "behavior = 1;")); |
| 968 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("exa")); | 1038 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("exa")); |
| 969 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); | 1039 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); |
| 970 SetOmniboxText("exam"); | 1040 SetOmniboxText("exam"); |
| 971 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); | 1041 EXPECT_EQ(ASCIIToUTF16("example.com"), omnibox()->GetText()); |
| 972 | 1042 |
| 973 // TODO(jered): Remove this after fixing OnBlur(). | 1043 // TODO(jered): Remove this after fixing OnBlur(). |
| 974 omnibox()->RevertAll(); | 1044 omnibox()->RevertAll(); |
| 975 } | 1045 } |
| 976 | 1046 |
| 977 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. | 1047 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. |
| 978 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_MostVisited) { | 1048 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_MostVisited) { |
| 979 content::WindowedNotificationObserver observer( | 1049 content::WindowedNotificationObserver observer( |
| 980 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, | 1050 chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS, |
| 981 content::NotificationService::AllSources()); | 1051 content::NotificationService::AllSources()); |
| 982 // Initialize Instant. | 1052 // Initialize Instant. |
| 983 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1053 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 984 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1054 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 985 | 1055 |
| 986 // Get a handle to the NTP and the current state of the JS. | 1056 // Get a handle to the NTP and the current state of the JS. |
| 987 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 1057 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 988 content::WebContents* overlay = instant()->ntp_->contents(); | 1058 content::WebContents* overlay = instant()->ntp_->contents(); |
| 989 EXPECT_TRUE(overlay); | 1059 EXPECT_TRUE(overlay); |
| 990 EXPECT_TRUE(UpdateSearchState(overlay)); | 1060 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 991 | 1061 |
| 992 // Wait for most visited data to be ready, if necessary. | 1062 // Wait for most visited data to be ready, if necessary. |
| 993 if (on_most_visited_change_calls_ == 0) { | 1063 if (on_most_visited_change_calls_ == 0) { |
| 994 observer.Wait(); | 1064 observer.Wait(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 EXPECT_TRUE(UpdateSearchState(overlay)); | 1132 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 1063 | 1133 |
| 1064 // Make sure we have the same number of items as before. | 1134 // Make sure we have the same number of items as before. |
| 1065 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); | 1135 EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count); |
| 1066 } | 1136 } |
| 1067 | 1137 |
| 1068 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { | 1138 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { |
| 1069 InstallThemeSource(); | 1139 InstallThemeSource(); |
| 1070 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); | 1140 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); |
| 1071 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1141 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1072 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1142 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1073 | 1143 |
| 1074 // The "Instant" New Tab should have access to chrome-search: scheme but not | 1144 // The "Instant" New Tab should have access to chrome-search: scheme but not |
| 1075 // chrome: scheme. | 1145 // chrome: scheme. |
| 1076 ui_test_utils::NavigateToURLWithDisposition( | 1146 ui_test_utils::NavigateToURLWithDisposition( |
| 1077 browser(), | 1147 browser(), |
| 1078 GURL(chrome::kChromeUINewTabURL), | 1148 GURL(chrome::kChromeUINewTabURL), |
| 1079 NEW_FOREGROUND_TAB, | 1149 NEW_FOREGROUND_TAB, |
| 1080 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1150 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 1081 | 1151 |
| 1082 content::RenderViewHost* rvh = | 1152 content::RenderViewHost* rvh = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1095 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. | 1165 // TODO(dhollowa): Fix flakes. http://crbug.com/179930. |
| 1096 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_FaviconAccess) { | 1166 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_FaviconAccess) { |
| 1097 // Create a favicon. | 1167 // Create a favicon. |
| 1098 history::TopSites* top_sites = browser()->profile()->GetTopSites(); | 1168 history::TopSites* top_sites = browser()->profile()->GetTopSites(); |
| 1099 GURL url("http://www.google.com/foo.html"); | 1169 GURL url("http://www.google.com/foo.html"); |
| 1100 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); | 1170 gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE)); |
| 1101 ThumbnailScore high_score(0.0, true, true, base::Time::Now()); | 1171 ThumbnailScore high_score(0.0, true, true, base::Time::Now()); |
| 1102 EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score)); | 1172 EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score)); |
| 1103 | 1173 |
| 1104 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1174 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1105 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1175 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1106 | 1176 |
| 1107 // The "Instant" New Tab should have access to chrome-search: scheme but not | 1177 // The "Instant" New Tab should have access to chrome-search: scheme but not |
| 1108 // chrome: scheme. | 1178 // chrome: scheme. |
| 1109 ui_test_utils::NavigateToURLWithDisposition( | 1179 ui_test_utils::NavigateToURLWithDisposition( |
| 1110 browser(), | 1180 browser(), |
| 1111 GURL(chrome::kChromeUINewTabURL), | 1181 GURL(chrome::kChromeUINewTabURL), |
| 1112 NEW_FOREGROUND_TAB, | 1182 NEW_FOREGROUND_TAB, |
| 1113 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1183 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 1114 | 1184 |
| 1115 content::RenderViewHost* rvh = | 1185 content::RenderViewHost* rvh = |
| 1116 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); | 1186 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 1117 | 1187 |
| 1118 // Get the favicons. | 1188 // Get the favicons. |
| 1119 const std::string chrome_favicon_url( | 1189 const std::string chrome_favicon_url( |
| 1120 "chrome://favicon/largest/http://www.google.com/foo.html"); | 1190 "chrome://favicon/largest/http://www.google.com/foo.html"); |
| 1121 const std::string search_favicon_url( | 1191 const std::string search_favicon_url( |
| 1122 "chrome-search://favicon/largest/http://www.google.com/foo.html"); | 1192 "chrome-search://favicon/largest/http://www.google.com/foo.html"); |
| 1123 bool loaded = false; | 1193 bool loaded = false; |
| 1124 ASSERT_TRUE(LoadImage(rvh, chrome_favicon_url, &loaded)); | 1194 ASSERT_TRUE(LoadImage(rvh, chrome_favicon_url, &loaded)); |
| 1125 EXPECT_FALSE(loaded) << chrome_favicon_url; | 1195 EXPECT_FALSE(loaded) << chrome_favicon_url; |
| 1126 ASSERT_TRUE(LoadImage(rvh, search_favicon_url, &loaded)); | 1196 ASSERT_TRUE(LoadImage(rvh, search_favicon_url, &loaded)); |
| 1127 EXPECT_TRUE(loaded) << search_favicon_url; | 1197 EXPECT_TRUE(loaded) << search_favicon_url; |
| 1128 } | 1198 } |
| 1129 | 1199 |
| 1130 // WebUIBindings should never be enabled on ANY Instant web contents. | 1200 // WebUIBindings should never be enabled on ANY Instant web contents. |
| 1131 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnNTP) { | 1201 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnNTP) { |
| 1132 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1202 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1133 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1203 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1134 | 1204 |
| 1135 ui_test_utils::NavigateToURLWithDisposition( | 1205 ui_test_utils::NavigateToURLWithDisposition( |
| 1136 browser(), | 1206 browser(), |
| 1137 GURL(chrome::kChromeUINewTabURL), | 1207 GURL(chrome::kChromeUINewTabURL), |
| 1138 NEW_FOREGROUND_TAB, | 1208 NEW_FOREGROUND_TAB, |
| 1139 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1209 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 1140 const content::WebContents* tab = | 1210 const content::WebContents* tab = |
| 1141 browser()->tab_strip_model()->GetActiveWebContents(); | 1211 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1142 | 1212 |
| 1143 // Instant-provided NTP should not have any bindings enabled. | 1213 // Instant-provided NTP should not have any bindings enabled. |
| 1144 EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings()); | 1214 EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings()); |
| 1145 } | 1215 } |
| 1146 | 1216 |
| 1147 // WebUIBindings should never be enabled on ANY Instant web contents. | 1217 // WebUIBindings should never be enabled on ANY Instant web contents. |
| 1148 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnPreview) { | 1218 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnPreview) { |
| 1149 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1219 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1150 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1220 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1151 | 1221 |
| 1152 // Typing in the omnibox shows the overlay. | 1222 // Typing in the omnibox shows the overlay. |
| 1153 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 1223 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 1154 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 1224 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 1155 content::WebContents* preview = instant()->GetOverlayContents(); | 1225 content::WebContents* preview = instant()->GetOverlayContents(); |
| 1156 ASSERT_NE(static_cast<content::WebContents*>(NULL), preview); | 1226 ASSERT_NE(static_cast<content::WebContents*>(NULL), preview); |
| 1157 | 1227 |
| 1158 // Instant preview should not have any bindings enabled. | 1228 // Instant preview should not have any bindings enabled. |
| 1159 EXPECT_EQ(0, preview->GetRenderViewHost()->GetEnabledBindings()); | 1229 EXPECT_EQ(0, preview->GetRenderViewHost()->GetEnabledBindings()); |
| 1160 } | 1230 } |
| 1161 | 1231 |
| 1162 // WebUIBindings should never be enabled on ANY Instant web contents. | 1232 // WebUIBindings should never be enabled on ANY Instant web contents. |
| 1163 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnResults) { | 1233 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnResults) { |
| 1164 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1234 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1165 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1235 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1166 | 1236 |
| 1167 // Typing in the omnibox shows the overlay. | 1237 // Typing in the omnibox shows the overlay. |
| 1168 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 1238 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 1169 content::WebContents* preview = instant()->GetOverlayContents(); | 1239 content::WebContents* preview = instant()->GetOverlayContents(); |
| 1170 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 1240 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 1171 // Commit the search by pressing Enter. | 1241 // Commit the search by pressing Enter. |
| 1172 browser()->window()->GetLocationBar()->AcceptInput(); | 1242 browser()->window()->GetLocationBar()->AcceptInput(); |
| 1173 EXPECT_TRUE(instant()->model()->mode().is_default()); | 1243 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 1174 const content::WebContents* tab = | 1244 const content::WebContents* tab = |
| 1175 browser()->tab_strip_model()->GetActiveWebContents(); | 1245 browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 #else | 1291 #else |
| 1222 #define MAYBE_CommitWhenFocusLostInFullHeight CommitWhenFocusLostInFullHeight | 1292 #define MAYBE_CommitWhenFocusLostInFullHeight CommitWhenFocusLostInFullHeight |
| 1223 #endif | 1293 #endif |
| 1224 // Test that the overlay is committed when the omnibox loses focus when it is | 1294 // Test that the overlay is committed when the omnibox loses focus when it is |
| 1225 // shown at 100% height. | 1295 // shown at 100% height. |
| 1226 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 1296 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 1227 MAYBE_CommitWhenFocusLostInFullHeight) { | 1297 MAYBE_CommitWhenFocusLostInFullHeight) { |
| 1228 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1298 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1229 | 1299 |
| 1230 // Focus omnibox and confirm overlay isn't shown. | 1300 // Focus omnibox and confirm overlay isn't shown. |
| 1231 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1301 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1232 content::WebContents* overlay = instant()->GetOverlayContents(); | 1302 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1233 EXPECT_TRUE(overlay); | 1303 EXPECT_TRUE(overlay); |
| 1234 EXPECT_TRUE(instant()->model()->mode().is_default()); | 1304 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 1235 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 1305 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 1236 | 1306 |
| 1237 // Typing in the omnibox should show the overlay. | 1307 // Typing in the omnibox should show the overlay. |
| 1238 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 1308 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 1239 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); | 1309 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); |
| 1240 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 1310 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 1241 | 1311 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1260 CommitWhenShownInFullHeightWithoutFocus | 1330 CommitWhenShownInFullHeightWithoutFocus |
| 1261 #endif | 1331 #endif |
| 1262 | 1332 |
| 1263 // Test that the overlay is committed when shown at 100% height without focus | 1333 // Test that the overlay is committed when shown at 100% height without focus |
| 1264 // in the omnibox. | 1334 // in the omnibox. |
| 1265 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 1335 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 1266 MAYBE_CommitWhenShownInFullHeightWithoutFocus) { | 1336 MAYBE_CommitWhenShownInFullHeightWithoutFocus) { |
| 1267 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1337 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1268 | 1338 |
| 1269 // Focus omnibox and confirm overlay isn't shown. | 1339 // Focus omnibox and confirm overlay isn't shown. |
| 1270 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1340 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1271 content::WebContents* overlay = instant()->GetOverlayContents(); | 1341 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1272 EXPECT_TRUE(overlay); | 1342 EXPECT_TRUE(overlay); |
| 1273 EXPECT_TRUE(instant()->model()->mode().is_default()); | 1343 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 1274 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 1344 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 1275 | 1345 |
| 1276 // Create an observer to wait for the commit. | 1346 // Create an observer to wait for the commit. |
| 1277 content::WindowedNotificationObserver commit_observer( | 1347 content::WindowedNotificationObserver commit_observer( |
| 1278 chrome::NOTIFICATION_INSTANT_COMMITTED, | 1348 chrome::NOTIFICATION_INSTANT_COMMITTED, |
| 1279 content::NotificationService::AllSources()); | 1349 content::NotificationService::AllSources()); |
| 1280 | 1350 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 browser()->tab_strip_model()->GetActiveWebContents(); | 1383 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1314 EXPECT_EQ(overlay, active_tab); | 1384 EXPECT_EQ(overlay, active_tab); |
| 1315 } | 1385 } |
| 1316 | 1386 |
| 1317 // Test that a transient entry is set properly when the overlay is committed | 1387 // Test that a transient entry is set properly when the overlay is committed |
| 1318 // without a navigation. | 1388 // without a navigation. |
| 1319 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, TransientEntrySet) { | 1389 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, TransientEntrySet) { |
| 1320 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1390 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1321 | 1391 |
| 1322 // Focus omnibox and confirm overlay isn't shown. | 1392 // Focus omnibox and confirm overlay isn't shown. |
| 1323 FocusOmniboxAndWaitForInstantSupport(); | 1393 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 1324 content::WebContents* overlay = instant()->GetOverlayContents(); | 1394 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1325 EXPECT_TRUE(overlay); | 1395 EXPECT_TRUE(overlay); |
| 1326 EXPECT_TRUE(instant()->model()->mode().is_default()); | 1396 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 1327 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 1397 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 1328 | 1398 |
| 1329 // Commit the overlay without triggering a navigation. | 1399 // Commit the overlay without triggering a navigation. |
| 1330 content::WindowedNotificationObserver observer( | 1400 content::WindowedNotificationObserver observer( |
| 1331 chrome::NOTIFICATION_INSTANT_COMMITTED, | 1401 chrome::NOTIFICATION_INSTANT_COMMITTED, |
| 1332 content::NotificationService::AllSources()); | 1402 content::NotificationService::AllSources()); |
| 1333 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 1403 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1349 EXPECT_NE(transient_entry->GetPageID(), committed_entry->GetPageID()); | 1419 EXPECT_NE(transient_entry->GetPageID(), committed_entry->GetPageID()); |
| 1350 } | 1420 } |
| 1351 | 1421 |
| 1352 // Test that the a transient entry is cleared when the overlay is committed | 1422 // Test that the a transient entry is cleared when the overlay is committed |
| 1353 // with a navigation. | 1423 // with a navigation. |
| 1354 // TODO(samarth) : this test fails, http://crbug.com/181070. | 1424 // TODO(samarth) : this test fails, http://crbug.com/181070. |
| 1355 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_TransientEntryRemoved) { | 1425 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_TransientEntryRemoved) { |
| 1356 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1426 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1357 | 1427 |
| 1358 // Focus omnibox and confirm overlay isn't shown. | 1428 // Focus omnibox and confirm overlay isn't shown. |
| 1359 FocusOmniboxAndWaitForInstantSupport(); | 1429 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 1360 content::WebContents* overlay = instant()->GetOverlayContents(); | 1430 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1361 EXPECT_TRUE(overlay); | 1431 EXPECT_TRUE(overlay); |
| 1362 EXPECT_TRUE(instant()->model()->mode().is_default()); | 1432 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 1363 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 1433 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 1364 | 1434 |
| 1365 // Create an observer to wait for the commit. | 1435 // Create an observer to wait for the commit. |
| 1366 content::WindowedNotificationObserver observer( | 1436 content::WindowedNotificationObserver observer( |
| 1367 chrome::NOTIFICATION_INSTANT_COMMITTED, | 1437 chrome::NOTIFICATION_INSTANT_COMMITTED, |
| 1368 content::NotificationService::AllSources()); | 1438 content::NotificationService::AllSources()); |
| 1369 | 1439 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1391 | 1461 |
| 1392 // The last committed entry should be the URL the page navigated to. | 1462 // The last committed entry should be the URL the page navigated to. |
| 1393 const content::NavigationEntry* committed_entry = | 1463 const content::NavigationEntry* committed_entry = |
| 1394 active_tab->GetController().GetLastCommittedEntry(); | 1464 active_tab->GetController().GetLastCommittedEntry(); |
| 1395 EXPECT_TRUE(EndsWith(committed_entry->GetURL().spec(), "#q=query", true)); | 1465 EXPECT_TRUE(EndsWith(committed_entry->GetURL().spec(), "#q=query", true)); |
| 1396 } | 1466 } |
| 1397 | 1467 |
| 1398 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, RestrictedItemReadback) { | 1468 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, RestrictedItemReadback) { |
| 1399 // Initialize Instant. | 1469 // Initialize Instant. |
| 1400 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1470 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1401 FocusOmniboxAndWaitForInstantSupport(); | 1471 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 1402 | 1472 |
| 1403 // Get a handle to the NTP and the current state of the JS. | 1473 // Get a handle to the NTP and the current state of the JS. |
| 1404 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); | 1474 ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp()); |
| 1405 content::WebContents* preview_tab = instant()->ntp()->contents(); | 1475 content::WebContents* preview_tab = instant()->ntp()->contents(); |
| 1406 EXPECT_TRUE(preview_tab); | 1476 EXPECT_TRUE(preview_tab); |
| 1407 | 1477 |
| 1408 // Manufacture a few autocomplete results and get them down to the page. | 1478 // Manufacture a few autocomplete results and get them down to the page. |
| 1409 std::vector<InstantAutocompleteResult> autocomplete_results; | 1479 std::vector<InstantAutocompleteResult> autocomplete_results; |
| 1410 for (int i = 0; i < 3; ++i) { | 1480 for (int i = 0; i < 3; ++i) { |
| 1411 std::string description(base::StringPrintf("Test Description %d", i)); | 1481 std::string description(base::StringPrintf("Test Description %d", i)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 EXPECT_TRUE(GetStringFromJS(instant()->GetOverlayContents(), | 1534 EXPECT_TRUE(GetStringFromJS(instant()->GetOverlayContents(), |
| 1465 "apiHandle.value", | 1535 "apiHandle.value", |
| 1466 &result)); | 1536 &result)); |
| 1467 EXPECT_EQ(kQueryString, result); | 1537 EXPECT_EQ(kQueryString, result); |
| 1468 } | 1538 } |
| 1469 | 1539 |
| 1470 // Test that autocomplete results are sent to the page only when all the | 1540 // Test that autocomplete results are sent to the page only when all the |
| 1471 // providers are done. | 1541 // providers are done. |
| 1472 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, AutocompleteProvidersDone) { | 1542 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, AutocompleteProvidersDone) { |
| 1473 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1543 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1474 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1544 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1475 | 1545 |
| 1476 content::WebContents* overlay = instant()->GetOverlayContents(); | 1546 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1477 EXPECT_TRUE(UpdateSearchState(overlay)); | 1547 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 1478 EXPECT_EQ(0, on_native_suggestions_calls_); | 1548 EXPECT_EQ(0, on_native_suggestions_calls_); |
| 1479 | 1549 |
| 1480 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("railroad")); | 1550 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("railroad")); |
| 1481 | 1551 |
| 1482 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 1552 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 1483 EXPECT_TRUE(UpdateSearchState(overlay)); | 1553 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 1484 EXPECT_EQ(1, on_native_suggestions_calls_); | 1554 EXPECT_EQ(1, on_native_suggestions_calls_); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1501 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) | 1571 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) |
| 1502 #define MAYBE_TopBarsVisibilityWhenSwitchingTabs \ | 1572 #define MAYBE_TopBarsVisibilityWhenSwitchingTabs \ |
| 1503 TopBarsVisibilityWhenSwitchingTabs | 1573 TopBarsVisibilityWhenSwitchingTabs |
| 1504 #else | 1574 #else |
| 1505 #define MAYBE_TopBarsVisibilityWhenSwitchingTabs \ | 1575 #define MAYBE_TopBarsVisibilityWhenSwitchingTabs \ |
| 1506 DISABLED_TopBarsVisibilityWhenSwitchingTabs | 1576 DISABLED_TopBarsVisibilityWhenSwitchingTabs |
| 1507 #endif | 1577 #endif |
| 1508 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 1578 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 1509 MAYBE_TopBarsVisibilityWhenSwitchingTabs) { | 1579 MAYBE_TopBarsVisibilityWhenSwitchingTabs) { |
| 1510 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1580 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1511 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1581 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1512 | 1582 |
| 1513 // Open 2 tabs of |DFEAULT| mode. | 1583 // Open 2 tabs of |DFEAULT| mode. |
| 1514 ui_test_utils::NavigateToURLWithDisposition( | 1584 ui_test_utils::NavigateToURLWithDisposition( |
| 1515 browser(), | 1585 browser(), |
| 1516 GURL("http://www.example.com"), | 1586 GURL("http://www.example.com"), |
| 1517 CURRENT_TAB, | 1587 CURRENT_TAB, |
| 1518 ui_test_utils::BROWSER_TEST_NONE); | 1588 ui_test_utils::BROWSER_TEST_NONE); |
| 1519 ui_test_utils::NavigateToURLWithDisposition( | 1589 ui_test_utils::NavigateToURLWithDisposition( |
| 1520 browser(), | 1590 browser(), |
| 1521 GURL("http://www.example.com"), | 1591 GURL("http://www.example.com"), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 !found_bookmark_match && iter != result.end(); ++iter) { | 1661 !found_bookmark_match && iter != result.end(); ++iter) { |
| 1592 found_bookmark_match = iter->type == AutocompleteMatch::BOOKMARK_TITLE; | 1662 found_bookmark_match = iter->type == AutocompleteMatch::BOOKMARK_TITLE; |
| 1593 } | 1663 } |
| 1594 | 1664 |
| 1595 EXPECT_TRUE(found_bookmark_match); | 1665 EXPECT_TRUE(found_bookmark_match); |
| 1596 } | 1666 } |
| 1597 | 1667 |
| 1598 // Test that the omnibox's temporary text is reset when the popup is closed. | 1668 // Test that the omnibox's temporary text is reset when the popup is closed. |
| 1599 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, TemporaryTextResetWhenPopupClosed) { | 1669 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, TemporaryTextResetWhenPopupClosed) { |
| 1600 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1670 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1601 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1671 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1602 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 1672 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 1603 | 1673 |
| 1604 // Show the overlay and arrow-down to a suggestion (this sets temporary text). | 1674 // Show the overlay and arrow-down to a suggestion (this sets temporary text). |
| 1605 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("juju")); | 1675 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("juju")); |
| 1606 SendDownArrow(); | 1676 SendDownArrow(); |
| 1607 | 1677 |
| 1608 EXPECT_TRUE(HasTemporaryText()); | 1678 EXPECT_TRUE(HasTemporaryText()); |
| 1609 EXPECT_EQ("result 1", GetOmniboxText()); | 1679 EXPECT_EQ("result 1", GetOmniboxText()); |
| 1610 | 1680 |
| 1611 // Click outside the omnibox (but not on the overlay), to make the omnibox | 1681 // Click outside the omnibox (but not on the overlay), to make the omnibox |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1623 | 1693 |
| 1624 // The omnibox should've reverted to the underlying permanent URL. | 1694 // The omnibox should've reverted to the underlying permanent URL. |
| 1625 EXPECT_FALSE(HasTemporaryText()); | 1695 EXPECT_FALSE(HasTemporaryText()); |
| 1626 EXPECT_EQ(std::string(chrome::kAboutBlankURL), GetOmniboxText()); | 1696 EXPECT_EQ(std::string(chrome::kAboutBlankURL), GetOmniboxText()); |
| 1627 } | 1697 } |
| 1628 | 1698 |
| 1629 // Test that autocomplete results aren't sent when the popup is closed. | 1699 // Test that autocomplete results aren't sent when the popup is closed. |
| 1630 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 1700 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 1631 NoAutocompleteResultsWhenPopupClosed) { | 1701 NoAutocompleteResultsWhenPopupClosed) { |
| 1632 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1702 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1633 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1703 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1634 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 1704 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 1635 | 1705 |
| 1636 // Show the overlay and arrow-down to a suggestion (this sets temporary text). | 1706 // Show the overlay and arrow-down to a suggestion (this sets temporary text). |
| 1637 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("thangam")); | 1707 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("thangam")); |
| 1638 SendDownArrow(); | 1708 SendDownArrow(); |
| 1639 EXPECT_TRUE(HasTemporaryText()); | 1709 EXPECT_TRUE(HasTemporaryText()); |
| 1640 | 1710 |
| 1641 EXPECT_TRUE(ExecuteScript("onChangeCalls = onNativeSuggestionsCalls = 0;")); | 1711 EXPECT_TRUE(ExecuteScript("onChangeCalls = onNativeSuggestionsCalls = 0;")); |
| 1642 | 1712 |
| 1643 content::WebContents* overlay = instant()->GetOverlayContents(); | 1713 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1644 EXPECT_TRUE(UpdateSearchState(overlay)); | 1714 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 1645 EXPECT_EQ(0, on_change_calls_); | 1715 EXPECT_EQ(0, on_change_calls_); |
| 1646 EXPECT_EQ(0, on_native_suggestions_calls_); | 1716 EXPECT_EQ(0, on_native_suggestions_calls_); |
| 1647 | 1717 |
| 1648 // Click outside the omnibox (but not on the overlay), to make the omnibox | 1718 // Click outside the omnibox (but not on the overlay), to make the omnibox |
| 1649 // lose focus. Close the popup explicitly, to workaround test/toolkit issues. | 1719 // lose focus. Close the popup explicitly, to workaround test/toolkit issues. |
| 1650 ui_test_utils::ClickOnView(browser(), VIEW_ID_TOOLBAR); | 1720 ui_test_utils::ClickOnView(browser(), VIEW_ID_TOOLBAR); |
| 1651 omnibox()->CloseOmniboxPopup(); | 1721 omnibox()->CloseOmniboxPopup(); |
| 1652 EXPECT_FALSE(HasTemporaryText()); | 1722 EXPECT_FALSE(HasTemporaryText()); |
| 1653 | 1723 |
| 1654 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 1724 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 1655 EXPECT_TRUE(UpdateSearchState(overlay)); | 1725 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 1656 EXPECT_EQ(0, on_change_calls_); | 1726 EXPECT_EQ(0, on_change_calls_); |
| 1657 EXPECT_EQ(0, on_native_suggestions_calls_); | 1727 EXPECT_EQ(0, on_native_suggestions_calls_); |
| 1658 } | 1728 } |
| 1659 | 1729 |
| 1660 // Test that suggestions are not accepted when unexpected. | 1730 // Test that suggestions are not accepted when unexpected. |
| 1661 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DeniesUnexpectedSuggestions) { | 1731 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DeniesUnexpectedSuggestions) { |
| 1662 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1732 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1663 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1733 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1664 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("chip")); | 1734 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("chip")); |
| 1665 SendDownArrow(); | 1735 SendDownArrow(); |
| 1666 | 1736 |
| 1667 EXPECT_EQ("result 1", GetOmniboxText()); | 1737 EXPECT_EQ("result 1", GetOmniboxText()); |
| 1668 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 1738 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 1669 | 1739 |
| 1670 // Make the page send an unexpected suggestion. | 1740 // Make the page send an unexpected suggestion. |
| 1671 EXPECT_TRUE(ExecuteScript("suggestion = 'chippies';" | 1741 EXPECT_TRUE(ExecuteScript("suggestion = 'chippies';" |
| 1672 "handleOnChange();")); | 1742 "handleOnChange();")); |
| 1673 | 1743 |
| 1674 // Verify that the suggestion is ignored. | 1744 // Verify that the suggestion is ignored. |
| 1675 EXPECT_EQ("result 1", GetOmniboxText()); | 1745 EXPECT_EQ("result 1", GetOmniboxText()); |
| 1676 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 1746 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 1677 } | 1747 } |
| 1678 | 1748 |
| 1679 // Test that autocomplete results are cleared when the query is cleared. | 1749 // Test that autocomplete results are cleared when the query is cleared. |
| 1680 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EmptyAutocompleteResults) { | 1750 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EmptyAutocompleteResults) { |
| 1681 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1751 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1682 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1752 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1683 | 1753 |
| 1684 // Type a URL, so that there's at least one autocomplete result (a "URL what | 1754 // Type a URL, so that there's at least one autocomplete result (a "URL what |
| 1685 // you typed" match). | 1755 // you typed" match). |
| 1686 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://upsamina/")); | 1756 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://upsamina/")); |
| 1687 | 1757 |
| 1688 content::WebContents* overlay = instant()->GetOverlayContents(); | 1758 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1689 | 1759 |
| 1690 int num_autocomplete_results = 0; | 1760 int num_autocomplete_results = 0; |
| 1691 EXPECT_TRUE(GetIntFromJS( | 1761 EXPECT_TRUE(GetIntFromJS( |
| 1692 overlay, | 1762 overlay, |
| 1693 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", | 1763 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", |
| 1694 &num_autocomplete_results)); | 1764 &num_autocomplete_results)); |
| 1695 EXPECT_LT(0, num_autocomplete_results); | 1765 EXPECT_LT(0, num_autocomplete_results); |
| 1696 | 1766 |
| 1697 // Erase the query in the omnibox. | 1767 // Erase the query in the omnibox. |
| 1698 SetOmniboxText(""); | 1768 SetOmniboxText(""); |
| 1699 | 1769 |
| 1700 EXPECT_TRUE(GetIntFromJS( | 1770 EXPECT_TRUE(GetIntFromJS( |
| 1701 overlay, | 1771 overlay, |
| 1702 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", | 1772 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", |
| 1703 &num_autocomplete_results)); | 1773 &num_autocomplete_results)); |
| 1704 EXPECT_EQ(0, num_autocomplete_results); | 1774 EXPECT_EQ(0, num_autocomplete_results); |
| 1705 } | 1775 } |
| 1706 | 1776 |
| 1707 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744. | 1777 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744. |
| 1708 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EscapeClearsOmnibox) { | 1778 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EscapeClearsOmnibox) { |
| 1709 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1779 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1710 FocusOmniboxAndWaitForInstantExtendedSupport(); | 1780 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 1711 | 1781 |
| 1712 // Navigate to the Instant NTP, and wait for it to be recognized. | 1782 // Navigate to the Instant NTP, and wait for it to be recognized. |
| 1713 content::WindowedNotificationObserver instant_tab_observer( | 1783 content::WindowedNotificationObserver instant_tab_observer( |
| 1714 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 1784 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 1715 content::NotificationService::AllSources()); | 1785 content::NotificationService::AllSources()); |
| 1716 ui_test_utils::NavigateToURLWithDisposition(browser(), | 1786 ui_test_utils::NavigateToURLWithDisposition(browser(), |
| 1717 GURL(chrome::kChromeUINewTabURL), | 1787 GURL(chrome::kChromeUINewTabURL), |
| 1718 CURRENT_TAB, | 1788 CURRENT_TAB, |
| 1719 ui_test_utils::BROWSER_TEST_NONE); | 1789 ui_test_utils::BROWSER_TEST_NONE); |
| 1720 instant_tab_observer.Wait(); | 1790 instant_tab_observer.Wait(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1736 SendEscape(); | 1806 SendEscape(); |
| 1737 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", | 1807 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", |
| 1738 &query)); | 1808 &query)); |
| 1739 EXPECT_EQ("", query); | 1809 EXPECT_EQ("", query); |
| 1740 EXPECT_EQ("", GetOmniboxText()); | 1810 EXPECT_EQ("", GetOmniboxText()); |
| 1741 | 1811 |
| 1742 EXPECT_TRUE(UpdateSearchState(contents)); | 1812 EXPECT_TRUE(UpdateSearchState(contents)); |
| 1743 EXPECT_LT(0, on_change_calls_); | 1813 EXPECT_LT(0, on_change_calls_); |
| 1744 EXPECT_EQ(0, submit_count_); | 1814 EXPECT_EQ(0, submit_count_); |
| 1745 } | 1815 } |
| OLD | NEW |