| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "chrome/browser/content_settings/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 6 #include "chrome/browser/history/history_service_factory.h" | 6 #include "chrome/browser/history/history_service_factory.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/search/instant_service.h" | 8 #include "chrome/browser/search/instant_service.h" |
| 9 #include "chrome/browser/search/instant_service_factory.h" | 9 #include "chrome/browser/search/instant_service_factory.h" |
| 10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 68 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 69 | 69 |
| 70 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 70 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 71 EXPECT_FALSE(omnibox()->model()->has_focus()); | 71 EXPECT_FALSE(omnibox()->model()->has_focus()); |
| 72 | 72 |
| 73 // Delete any existing overlay. | 73 // Delete any existing overlay. |
| 74 instant()->overlay_.reset(); | 74 instant()->overlay_.reset(); |
| 75 EXPECT_FALSE(instant()->GetOverlayContents()); | 75 EXPECT_FALSE(instant()->GetOverlayContents()); |
| 76 | 76 |
| 77 // Refocus the omnibox. The InstantController should've preloaded Instant. | 77 // Refocus the omnibox. The InstantController should've preloaded Instant. |
| 78 FocusOmniboxAndWaitForInstantSupport(); | 78 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 79 | 79 |
| 80 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 80 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| 81 EXPECT_TRUE(omnibox()->model()->has_focus()); | 81 EXPECT_TRUE(omnibox()->model()->has_focus()); |
| 82 | 82 |
| 83 content::WebContents* overlay = instant()->GetOverlayContents(); | 83 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 84 EXPECT_TRUE(overlay); | 84 EXPECT_TRUE(overlay); |
| 85 | 85 |
| 86 // Check that the page supports Instant, but it isn't showing. | 86 // Check that the page supports Instant, but it isn't showing. |
| 87 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 87 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 88 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 88 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 110 | 110 |
| 111 // Flakes on Windows and Mac: http://crbug.com/170677 | 111 // Flakes on Windows and Mac: http://crbug.com/170677 |
| 112 #if defined(OS_WIN) || defined(OS_MACOSX) | 112 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 113 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent | 113 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent |
| 114 #else | 114 #else |
| 115 #define MAYBE_OnChangeEvent OnChangeEvent | 115 #define MAYBE_OnChangeEvent OnChangeEvent |
| 116 #endif | 116 #endif |
| 117 // Test that the onchange event is dispatched upon typing in the omnibox. | 117 // Test that the onchange event is dispatched upon typing in the omnibox. |
| 118 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnChangeEvent) { | 118 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnChangeEvent) { |
| 119 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 119 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 120 FocusOmniboxAndWaitForInstantSupport(); | 120 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 121 | 121 |
| 122 // Use the Instant page as the active tab, so we can exploit its visibility | 122 // Use the Instant page as the active tab, so we can exploit its visibility |
| 123 // handler to check visibility transitions. | 123 // handler to check visibility transitions. |
| 124 ui_test_utils::NavigateToURL(browser(), instant_url()); | 124 ui_test_utils::NavigateToURL(browser(), instant_url()); |
| 125 content::WebContents* active_tab = | 125 content::WebContents* active_tab = |
| 126 browser()->tab_strip_model()->GetActiveWebContents(); | 126 browser()->tab_strip_model()->GetActiveWebContents(); |
| 127 | 127 |
| 128 int active_tab_onvisibilitycalls = -1; | 128 int active_tab_onvisibilitycalls = -1; |
| 129 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", | 129 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", |
| 130 &active_tab_onvisibilitycalls)); | 130 &active_tab_onvisibilitycalls)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 152 EXPECT_EQ(1, onvisibilitycalls_); | 152 EXPECT_EQ(1, onvisibilitycalls_); |
| 153 active_tab_onvisibilitycalls = -1; | 153 active_tab_onvisibilitycalls = -1; |
| 154 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", | 154 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", |
| 155 &active_tab_onvisibilitycalls)); | 155 &active_tab_onvisibilitycalls)); |
| 156 EXPECT_EQ(0, active_tab_onvisibilitycalls); | 156 EXPECT_EQ(0, active_tab_onvisibilitycalls); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Test that the onsubmit event is dispatched upon pressing Enter. | 159 // Test that the onsubmit event is dispatched upon pressing Enter. |
| 160 IN_PROC_BROWSER_TEST_F(InstantTest, OnSubmitEvent) { | 160 IN_PROC_BROWSER_TEST_F(InstantTest, OnSubmitEvent) { |
| 161 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 161 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 162 FocusOmniboxAndWaitForInstantSupport(); | 162 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 163 SetOmniboxTextAndWaitForOverlayToShow("search"); | 163 SetOmniboxTextAndWaitForOverlayToShow("search"); |
| 164 | 164 |
| 165 // Stash a reference to the overlay, so we can refer to it after commit. | 165 // Stash a reference to the overlay, so we can refer to it after commit. |
| 166 content::WebContents* overlay = instant()->GetOverlayContents(); | 166 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 167 EXPECT_TRUE(overlay); | 167 EXPECT_TRUE(overlay); |
| 168 | 168 |
| 169 // The state of the searchbox before the commit. | 169 // The state of the searchbox before the commit. |
| 170 EXPECT_TRUE(UpdateSearchState(overlay)); | 170 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 171 EXPECT_EQ("search", value_); | 171 EXPECT_EQ("search", value_); |
| 172 EXPECT_FALSE(verbatim_); | 172 EXPECT_FALSE(verbatim_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 EXPECT_EQ("search", value_); | 213 EXPECT_EQ("search", value_); |
| 214 EXPECT_TRUE(verbatim_); | 214 EXPECT_TRUE(verbatim_); |
| 215 EXPECT_EQ(1, onsubmitcalls_); | 215 EXPECT_EQ(1, onsubmitcalls_); |
| 216 EXPECT_EQ(1, onvisibilitycalls_); | 216 EXPECT_EQ(1, onvisibilitycalls_); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Test that the oncancel event is dispatched upon clicking on the overlay. | 219 // Test that the oncancel event is dispatched upon clicking on the overlay. |
| 220 IN_PROC_BROWSER_TEST_F(InstantTest, OnCancelEvent) { | 220 IN_PROC_BROWSER_TEST_F(InstantTest, OnCancelEvent) { |
| 221 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 221 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 222 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 222 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 223 FocusOmniboxAndWaitForInstantSupport(); | 223 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 224 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); | 224 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
| 225 | 225 |
| 226 // Stash a reference to the overlay, so we can refer to it after commit. | 226 // Stash a reference to the overlay, so we can refer to it after commit. |
| 227 content::WebContents* overlay = instant()->GetOverlayContents(); | 227 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 228 EXPECT_TRUE(overlay); | 228 EXPECT_TRUE(overlay); |
| 229 | 229 |
| 230 // The state of the searchbox before the commit. | 230 // The state of the searchbox before the commit. |
| 231 EXPECT_TRUE(UpdateSearchState(overlay)); | 231 EXPECT_TRUE(UpdateSearchState(overlay)); |
| 232 EXPECT_EQ("search", value_); | 232 EXPECT_EQ("search", value_); |
| 233 EXPECT_FALSE(verbatim_); | 233 EXPECT_FALSE(verbatim_); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 EXPECT_EQ("search", value_); | 274 EXPECT_EQ("search", value_); |
| 275 EXPECT_TRUE(verbatim_); | 275 EXPECT_TRUE(verbatim_); |
| 276 EXPECT_EQ(1, oncancelcalls_); | 276 EXPECT_EQ(1, oncancelcalls_); |
| 277 EXPECT_EQ(1, onvisibilitycalls_); | 277 EXPECT_EQ(1, onvisibilitycalls_); |
| 278 } | 278 } |
| 279 | 279 |
| 280 // Test that the onreisze event is dispatched upon typing in the omnibox. | 280 // Test that the onreisze event is dispatched upon typing in the omnibox. |
| 281 IN_PROC_BROWSER_TEST_F(InstantTest, OnResizeEvent) { | 281 IN_PROC_BROWSER_TEST_F(InstantTest, OnResizeEvent) { |
| 282 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 282 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 283 | 283 |
| 284 FocusOmniboxAndWaitForInstantSupport(); | 284 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 285 | 285 |
| 286 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 286 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
| 287 EXPECT_EQ(0, onresizecalls_); | 287 EXPECT_EQ(0, onresizecalls_); |
| 288 EXPECT_EQ(0, height_); | 288 EXPECT_EQ(0, height_); |
| 289 | 289 |
| 290 // Type a query into the omnibox. This should cause an onresize() event, with | 290 // Type a query into the omnibox. This should cause an onresize() event, with |
| 291 // a valid (non-zero) height. | 291 // a valid (non-zero) height. |
| 292 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); | 292 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
| 293 | 293 |
| 294 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 294 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
| 295 EXPECT_EQ(1, onresizecalls_); | 295 EXPECT_EQ(1, onresizecalls_); |
| 296 EXPECT_LT(0, height_); | 296 EXPECT_LT(0, height_); |
| 297 } | 297 } |
| 298 | 298 |
| 299 // Test that the INSTANT_COMPLETE_NOW behavior works as expected. | 299 // Test that the INSTANT_COMPLETE_NOW behavior works as expected. |
| 300 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) { | 300 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNow) { |
| 301 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 301 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 302 FocusOmniboxAndWaitForInstantSupport(); | 302 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 303 | 303 |
| 304 // Tell the JS to request the given behavior. | 304 // Tell the JS to request the given behavior. |
| 305 EXPECT_TRUE(ExecuteScript("behavior = 'now'")); | 305 EXPECT_TRUE(ExecuteScript("behavior = 'now'")); |
| 306 | 306 |
| 307 // Type a query, causing the hardcoded "query suggestion" to be returned. | 307 // Type a query, causing the hardcoded "query suggestion" to be returned. |
| 308 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 308 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 309 | 309 |
| 310 // Get what's showing in the omnibox, and what's highlighted. | 310 // Get what's showing in the omnibox, and what's highlighted. |
| 311 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 311 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
| 312 EXPECT_EQ(ASCIIToUTF16(" suggestion"), GetBlueText()); | 312 EXPECT_EQ(ASCIIToUTF16(" suggestion"), GetBlueText()); |
| 313 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 313 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 314 } | 314 } |
| 315 | 315 |
| 316 // Test that the INSTANT_COMPLETE_NEVER behavior works as expected. | 316 // Test that the INSTANT_COMPLETE_NEVER behavior works as expected. |
| 317 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNever) { | 317 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsCompletedNever) { |
| 318 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 318 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 319 FocusOmniboxAndWaitForInstantSupport(); | 319 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 320 | 320 |
| 321 // Tell the JS to request the given behavior. | 321 // Tell the JS to request the given behavior. |
| 322 EXPECT_TRUE(ExecuteScript("behavior = 'never'")); | 322 EXPECT_TRUE(ExecuteScript("behavior = 'never'")); |
| 323 | 323 |
| 324 // Type a query, causing the hardcoded "query suggestion" to be returned. | 324 // Type a query, causing the hardcoded "query suggestion" to be returned. |
| 325 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 325 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 326 | 326 |
| 327 // Get what's showing in the omnibox, and what's highlighted. | 327 // Get what's showing in the omnibox, and what's highlighted. |
| 328 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); | 328 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); |
| 329 EXPECT_EQ(ASCIIToUTF16(""), GetBlueText()); | 329 EXPECT_EQ(ASCIIToUTF16(""), GetBlueText()); |
| 330 EXPECT_EQ(ASCIIToUTF16(" suggestion"), GetGrayText()); | 330 EXPECT_EQ(ASCIIToUTF16(" suggestion"), GetGrayText()); |
| 331 } | 331 } |
| 332 | 332 |
| 333 // Test that a valid suggestion is accepted. | 333 // Test that a valid suggestion is accepted. |
| 334 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsValidObject) { | 334 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsValidObject) { |
| 335 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 335 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 336 FocusOmniboxAndWaitForInstantSupport(); | 336 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 337 | 337 |
| 338 // Tell the JS to use the given suggestion. | 338 // Tell the JS to use the given suggestion. |
| 339 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'query completion' } ]")); | 339 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'query completion' } ]")); |
| 340 | 340 |
| 341 // Type a query, causing "query completion" to be returned as the suggestion. | 341 // Type a query, causing "query completion" to be returned as the suggestion. |
| 342 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 342 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 343 EXPECT_EQ(ASCIIToUTF16("query completion"), omnibox()->GetText()); | 343 EXPECT_EQ(ASCIIToUTF16("query completion"), omnibox()->GetText()); |
| 344 } | 344 } |
| 345 | 345 |
| 346 // Test that an invalid suggestion is rejected. | 346 // Test that an invalid suggestion is rejected. |
| 347 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsInvalidObject) { | 347 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsInvalidObject) { |
| 348 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 348 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 349 FocusOmniboxAndWaitForInstantSupport(); | 349 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 350 | 350 |
| 351 // Tell the JS to use an object in an invalid format. | 351 // Tell the JS to use an object in an invalid format. |
| 352 EXPECT_TRUE(ExecuteScript("suggestion = { value: 'query completion' }")); | 352 EXPECT_TRUE(ExecuteScript("suggestion = { value: 'query completion' }")); |
| 353 | 353 |
| 354 // Type a query, but expect no suggestion. | 354 // Type a query, but expect no suggestion. |
| 355 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 355 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 356 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); | 356 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Test that various forms of empty suggestions are rejected. | 359 // Test that various forms of empty suggestions are rejected. |
| 360 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsEmpty) { | 360 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionIsEmpty) { |
| 361 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 361 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 362 FocusOmniboxAndWaitForInstantSupport(); | 362 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 363 | 363 |
| 364 EXPECT_TRUE(ExecuteScript("suggestion = {}")); | 364 EXPECT_TRUE(ExecuteScript("suggestion = {}")); |
| 365 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 365 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 366 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); | 366 EXPECT_EQ(ASCIIToUTF16("query"), omnibox()->GetText()); |
| 367 | 367 |
| 368 omnibox()->RevertAll(); | 368 omnibox()->RevertAll(); |
| 369 | 369 |
| 370 EXPECT_TRUE(ExecuteScript("suggestion = []")); | 370 EXPECT_TRUE(ExecuteScript("suggestion = []")); |
| 371 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query sugg")); | 371 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query sugg")); |
| 372 EXPECT_EQ(ASCIIToUTF16("query sugg"), omnibox()->GetText()); | 372 EXPECT_EQ(ASCIIToUTF16("query sugg"), omnibox()->GetText()); |
| 373 | 373 |
| 374 omnibox()->RevertAll(); | 374 omnibox()->RevertAll(); |
| 375 | 375 |
| 376 EXPECT_TRUE(ExecuteScript("suggestion = [{}]")); | 376 EXPECT_TRUE(ExecuteScript("suggestion = [{}]")); |
| 377 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query suggest")); | 377 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query suggest")); |
| 378 EXPECT_EQ(ASCIIToUTF16("query suggest"), omnibox()->GetText()); | 378 EXPECT_EQ(ASCIIToUTF16("query suggest"), omnibox()->GetText()); |
| 379 } | 379 } |
| 380 | 380 |
| 381 // Tests that a previous search suggestion is not discarded if it's not stale. | 381 // Tests that a previous search suggestion is not discarded if it's not stale. |
| 382 IN_PROC_BROWSER_TEST_F(InstantTest, SearchSuggestionIsNotDiscarded) { | 382 IN_PROC_BROWSER_TEST_F(InstantTest, SearchSuggestionIsNotDiscarded) { |
| 383 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 383 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 384 FocusOmniboxAndWaitForInstantSupport(); | 384 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 385 | 385 |
| 386 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 386 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 387 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 387 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
| 388 SetOmniboxText("query sugg"); | 388 SetOmniboxText("query sugg"); |
| 389 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 389 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
| 390 } | 390 } |
| 391 | 391 |
| 392 // Test that Instant doesn't process URLs. | 392 // Test that Instant doesn't process URLs. |
| 393 IN_PROC_BROWSER_TEST_F(InstantTest, RejectsURLs) { | 393 IN_PROC_BROWSER_TEST_F(InstantTest, RejectsURLs) { |
| 394 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 394 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 395 FocusOmniboxAndWaitForInstantSupport(); | 395 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 396 | 396 |
| 397 // Note that we are not actually navigating to these URLs yet. We are just | 397 // Note that we are not actually navigating to these URLs yet. We are just |
| 398 // typing them into the omnibox (without pressing Enter) and checking that | 398 // typing them into the omnibox (without pressing Enter) and checking that |
| 399 // Instant doesn't try to process them. | 399 // Instant doesn't try to process them. |
| 400 SetOmniboxText(content::kChromeUICrashURL); | 400 SetOmniboxText(content::kChromeUICrashURL); |
| 401 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 401 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 402 EXPECT_TRUE(instant()->model()->mode().is_default()); | 402 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 403 | 403 |
| 404 SetOmniboxText(content::kChromeUIHangURL); | 404 SetOmniboxText(content::kChromeUIHangURL); |
| 405 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 405 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 426 EXPECT_EQ(ASCIIToUTF16("baby/beluga"), omnibox()->GetText()); | 426 EXPECT_EQ(ASCIIToUTF16("baby/beluga"), omnibox()->GetText()); |
| 427 | 427 |
| 428 EXPECT_TRUE(instant()->GetOverlayContents()); | 428 EXPECT_TRUE(instant()->GetOverlayContents()); |
| 429 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 429 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 430 EXPECT_TRUE(instant()->model()->mode().is_default()); | 430 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 431 } | 431 } |
| 432 | 432 |
| 433 // Test that transitions between searches and non-searches work as expected. | 433 // Test that transitions between searches and non-searches work as expected. |
| 434 IN_PROC_BROWSER_TEST_F(InstantTest, TransitionsBetweenSearchAndURL) { | 434 IN_PROC_BROWSER_TEST_F(InstantTest, TransitionsBetweenSearchAndURL) { |
| 435 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 435 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 436 FocusOmniboxAndWaitForInstantSupport(); | 436 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 437 | 437 |
| 438 // Type a search, and immediately a URL, without waiting for Instant to show. | 438 // Type a search, and immediately a URL, without waiting for Instant to show. |
| 439 // The page is told about the search. Though the page isn't told about the | 439 // The page is told about the search. Though the page isn't told about the |
| 440 // subsequent URL, it invalidates the search, so a blank query is sent in its | 440 // subsequent URL, it invalidates the search, so a blank query is sent in its |
| 441 // place to indicate that the search is "out of date". | 441 // place to indicate that the search is "out of date". |
| 442 SetOmniboxText("query"); | 442 SetOmniboxText("query"); |
| 443 SetOmniboxText("http://monstrous/nightmare"); | 443 SetOmniboxText("http://monstrous/nightmare"); |
| 444 int min_onchangecalls = 2; | 444 int min_onchangecalls = 2; |
| 445 | 445 |
| 446 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); | 446 EXPECT_TRUE(UpdateSearchState(instant()->GetOverlayContents())); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 526 |
| 527 // Instant shouldn't have done anything. | 527 // Instant shouldn't have done anything. |
| 528 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 528 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 529 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 529 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 530 EXPECT_TRUE(instant()->model()->mode().is_default()); | 530 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 531 } | 531 } |
| 532 | 532 |
| 533 // Test that Instant can't be fooled into committing a URL. | 533 // Test that Instant can't be fooled into committing a URL. |
| 534 IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsTwo) { | 534 IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsTwo) { |
| 535 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 535 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 536 FocusOmniboxAndWaitForInstantSupport(); | 536 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 537 | 537 |
| 538 // Type a query. This causes the overlay to be shown. | 538 // Type a query. This causes the overlay to be shown. |
| 539 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 539 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 540 | 540 |
| 541 content::WebContents* overlay = instant()->GetOverlayContents(); | 541 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 542 EXPECT_TRUE(overlay); | 542 EXPECT_TRUE(overlay); |
| 543 | 543 |
| 544 // Type a URL. This causes the overlay to be hidden. | 544 // Type a URL. This causes the overlay to be hidden. |
| 545 SetOmniboxText("http://hideous/zippleback"); | 545 SetOmniboxText("http://hideous/zippleback"); |
| 546 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 546 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 567 // Test that a non-Instant search provider shows no overlays. | 567 // Test that a non-Instant search provider shows no overlays. |
| 568 IN_PROC_BROWSER_TEST_F(InstantTest, NonInstantSearchProvider) { | 568 IN_PROC_BROWSER_TEST_F(InstantTest, NonInstantSearchProvider) { |
| 569 GURL instant_url = test_server()->GetURL("files/empty.html"); | 569 GURL instant_url = test_server()->GetURL("files/empty.html"); |
| 570 InstantTestBase::Init(instant_url); | 570 InstantTestBase::Init(instant_url); |
| 571 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 571 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 572 | 572 |
| 573 // Focus the omnibox. When the support determination response comes back, | 573 // Focus the omnibox. When the support determination response comes back, |
| 574 // Instant will destroy the non-Instant page, and attempt to recreate it. | 574 // Instant will destroy the non-Instant page, and attempt to recreate it. |
| 575 // We can know this happened by looking at the blacklist. | 575 // We can know this happened by looking at the blacklist. |
| 576 EXPECT_EQ(0, instant()->blacklisted_urls_[instant_url.spec()]); | 576 EXPECT_EQ(0, instant()->blacklisted_urls_[instant_url.spec()]); |
| 577 FocusOmniboxAndWaitForInstantSupport(); | 577 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 578 EXPECT_EQ(1, instant()->blacklisted_urls_[instant_url.spec()]); | 578 EXPECT_EQ(1, instant()->blacklisted_urls_[instant_url.spec()]); |
| 579 } | 579 } |
| 580 | 580 |
| 581 // Test that the renderer doesn't crash if JavaScript is blocked. | 581 // Test that the renderer doesn't crash if JavaScript is blocked. |
| 582 IN_PROC_BROWSER_TEST_F(InstantTest, NoCrashOnBlockedJS) { | 582 IN_PROC_BROWSER_TEST_F(InstantTest, NoCrashOnBlockedJS) { |
| 583 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | 583 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 584 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); | 584 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); |
| 585 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 585 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 586 | 586 |
| 587 // Wait for notification that the Instant API has been determined. As long as | 587 // Wait for notification that the Instant API has been determined. As long as |
| 588 // we get the notification we're good (the renderer didn't crash). | 588 // we get the notification we're good (the renderer didn't crash). |
| 589 FocusOmniboxAndWaitForInstantSupport(); | 589 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 590 } | 590 } |
| 591 | 591 |
| 592 // Test that the overlay and active tab's visibility states are set correctly. | 592 // Test that the overlay and active tab's visibility states are set correctly. |
| 593 IN_PROC_BROWSER_TEST_F(InstantTest, PageVisibility) { | 593 IN_PROC_BROWSER_TEST_F(InstantTest, PageVisibility) { |
| 594 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 594 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 595 FocusOmniboxAndWaitForInstantSupport(); | 595 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 596 | 596 |
| 597 content::WebContents* active_tab = | 597 content::WebContents* active_tab = |
| 598 browser()->tab_strip_model()->GetActiveWebContents(); | 598 browser()->tab_strip_model()->GetActiveWebContents(); |
| 599 content::WebContents* overlay = instant()->GetOverlayContents(); | 599 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 600 | 600 |
| 601 // Inititally, the active tab is showing; the overlay is not. | 601 // Inititally, the active tab is showing; the overlay is not. |
| 602 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); | 602 EXPECT_TRUE(CheckVisibilityIs(active_tab, true)); |
| 603 EXPECT_TRUE(CheckVisibilityIs(overlay, false)); | 603 EXPECT_TRUE(CheckVisibilityIs(overlay, false)); |
| 604 | 604 |
| 605 // Type a query and wait for Instant to show. | 605 // Type a query and wait for Instant to show. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 HistoryService::Handle /* handle */, | 669 HistoryService::Handle /* handle */, |
| 670 std::vector<history::KeywordSearchTermVisit>* terms) { | 670 std::vector<history::KeywordSearchTermVisit>* terms) { |
| 671 for (size_t i = 0; i < terms->size(); ++i) | 671 for (size_t i = 0; i < terms->size(); ++i) |
| 672 result->push_back((*terms)[i].term); | 672 result->push_back((*terms)[i].term); |
| 673 run_loop->Quit(); | 673 run_loop->Quit(); |
| 674 } | 674 } |
| 675 | 675 |
| 676 // Test that the Instant page load is not added to history. | 676 // Test that the Instant page load is not added to history. |
| 677 IN_PROC_BROWSER_TEST_F(InstantTest, History) { | 677 IN_PROC_BROWSER_TEST_F(InstantTest, History) { |
| 678 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 678 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 679 FocusOmniboxAndWaitForInstantSupport(); | 679 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 680 | 680 |
| 681 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( | 681 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( |
| 682 browser()->profile())->GetDefaultSearchProvider(); | 682 browser()->profile())->GetDefaultSearchProvider(); |
| 683 | 683 |
| 684 // |instant_url| is the URL Instant loads. |search_url| is the fake URL we | 684 // |instant_url| is the URL Instant loads. |search_url| is the fake URL we |
| 685 // enter into history for search terms extraction to work correctly. | 685 // enter into history for search terms extraction to work correctly. |
| 686 std::string search_url = template_url->url_ref().ReplaceSearchTerms( | 686 std::string search_url = template_url->url_ref().ReplaceSearchTerms( |
| 687 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("search"))); | 687 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("search"))); |
| 688 | 688 |
| 689 HistoryService* history = HistoryServiceFactory::GetForProfile( | 689 HistoryService* history = HistoryServiceFactory::GetForProfile( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 // actually closer to what we'd like. | 728 // actually closer to what we'd like. |
| 729 #if defined(OS_MACOSX) | 729 #if defined(OS_MACOSX) |
| 730 #define MAYBE_NewWindowDismissesInstant DISABLED_NewWindowDismissesInstant | 730 #define MAYBE_NewWindowDismissesInstant DISABLED_NewWindowDismissesInstant |
| 731 #else | 731 #else |
| 732 #define MAYBE_NewWindowDismissesInstant NewWindowDismissesInstant | 732 #define MAYBE_NewWindowDismissesInstant NewWindowDismissesInstant |
| 733 #endif | 733 #endif |
| 734 // Test that creating a new window hides any currently showing Instant overlay. | 734 // Test that creating a new window hides any currently showing Instant overlay. |
| 735 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NewWindowDismissesInstant) { | 735 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_NewWindowDismissesInstant) { |
| 736 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 736 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 737 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 737 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 738 FocusOmniboxAndWaitForInstantSupport(); | 738 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 739 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); | 739 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("search")); |
| 740 | 740 |
| 741 Browser* previous_window = browser(); | 741 Browser* previous_window = browser(); |
| 742 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); | 742 EXPECT_TRUE(instant()->IsOverlayingSearchResults()); |
| 743 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 743 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 744 | 744 |
| 745 InstantTestModelObserver observer(instant()->model(), | 745 InstantTestModelObserver observer(instant()->model(), |
| 746 SearchMode::MODE_DEFAULT); | 746 SearchMode::MODE_DEFAULT); |
| 747 chrome::NewEmptyWindow(browser()->profile(), | 747 chrome::NewEmptyWindow(browser()->profile(), |
| 748 chrome::HOST_DESKTOP_TYPE_NATIVE); | 748 chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 749 ASSERT_TRUE(observer.WaitForExpectedOverlayState()); | 749 ASSERT_TRUE(observer.WaitForExpectedOverlayState()); |
| 750 | 750 |
| 751 // Even though we just created a new Browser object (for the new window), the | 751 // Even though we just created a new Browser object (for the new window), the |
| 752 // browser() accessor should still give us the first window's Browser object. | 752 // browser() accessor should still give us the first window's Browser object. |
| 753 EXPECT_EQ(previous_window, browser()); | 753 EXPECT_EQ(previous_window, browser()); |
| 754 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 754 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 755 EXPECT_TRUE(instant()->model()->mode().is_default()); | 755 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 756 } | 756 } |
| 757 | 757 |
| 758 // Test that the Instant overlay is recreated when all these conditions are met: | 758 // Test that the Instant overlay is recreated when all these conditions are met: |
| 759 // - The stale overlay timer has fired. | 759 // - The stale overlay timer has fired. |
| 760 // - The overlay is not showing. | 760 // - The overlay is not showing. |
| 761 // - The omnibox doesn't have focus. | 761 // - The omnibox doesn't have focus. |
| 762 IN_PROC_BROWSER_TEST_F(InstantTest, InstantOverlayRefresh) { | 762 IN_PROC_BROWSER_TEST_F(InstantTest, InstantOverlayRefresh) { |
| 763 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 763 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 764 FocusOmniboxAndWaitForInstantSupport(); | 764 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 765 | 765 |
| 766 // The overlay is refreshed only after all three conditions above are met. | 766 // The overlay is refreshed only after all three conditions above are met. |
| 767 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 767 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 768 instant()->overlay_->is_stale_ = true; | 768 instant()->overlay_->is_stale_ = true; |
| 769 instant()->ReloadOverlayIfStale(); | 769 instant()->ReloadOverlayIfStale(); |
| 770 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 770 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 771 instant()->HideOverlay(); | 771 instant()->HideOverlay(); |
| 772 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 772 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 773 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, | 773 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, |
| 774 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 774 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
| 775 EXPECT_FALSE(instant()->overlay_->supports_instant()); | 775 EXPECT_FALSE(instant()->overlay_->supports_instant()); |
| 776 | 776 |
| 777 // Try with a different ordering. | 777 // Try with a different ordering. |
| 778 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 778 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 779 instant()->overlay_->is_stale_ = true; | 779 instant()->overlay_->is_stale_ = true; |
| 780 instant()->ReloadOverlayIfStale(); | 780 instant()->ReloadOverlayIfStale(); |
| 781 EXPECT_TRUE(instant()->overlay_->supports_instant()); | 781 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 782 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, | 782 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, |
| 783 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 783 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
| 784 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideOverlay(). When it | 784 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideOverlay(). When it |
| 785 // stops hiding the overlay eventually, uncomment these two lines: | 785 // stops hiding the overlay eventually, uncomment these two lines: |
| 786 // EXPECT_TRUE(instant()->overlay_->supports_instant()); | 786 // EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 787 // instant()->HideOverlay(); | 787 // instant()->HideOverlay(); |
| 788 EXPECT_FALSE(instant()->overlay_->supports_instant()); | 788 EXPECT_FALSE(instant()->overlay_->supports_instant()); |
| 789 } | 789 } |
| 790 | 790 |
| 791 // Test that suggestions are case insensitive. http://crbug.com/150728 | 791 // Test that suggestions are case insensitive. http://crbug.com/150728 |
| 792 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { | 792 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { |
| 793 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 793 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 794 FocusOmniboxAndWaitForInstantSupport(); | 794 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 795 | 795 |
| 796 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]")); | 796 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]")); |
| 797 | 797 |
| 798 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("in")); | 798 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("in")); |
| 799 EXPECT_EQ(ASCIIToUTF16("instant"), omnibox()->GetText()); | 799 EXPECT_EQ(ASCIIToUTF16("instant"), omnibox()->GetText()); |
| 800 | 800 |
| 801 omnibox()->RevertAll(); | 801 omnibox()->RevertAll(); |
| 802 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("IN")); | 802 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("IN")); |
| 803 EXPECT_EQ(ASCIIToUTF16("INSTANT"), omnibox()->GetText()); | 803 EXPECT_EQ(ASCIIToUTF16("INSTANT"), omnibox()->GetText()); |
| 804 | 804 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 | 847 |
| 848 // Flakes on Windows and Mac: http://crbug.com/170677 | 848 // Flakes on Windows and Mac: http://crbug.com/170677 |
| 849 #if defined(OS_WIN) || defined(OS_MACOSX) | 849 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 850 #define MAYBE_CommitInNewTab DISABLED_CommitInNewTab | 850 #define MAYBE_CommitInNewTab DISABLED_CommitInNewTab |
| 851 #else | 851 #else |
| 852 #define MAYBE_CommitInNewTab CommitInNewTab | 852 #define MAYBE_CommitInNewTab CommitInNewTab |
| 853 #endif | 853 #endif |
| 854 // Test that the overlay can be committed onto a new tab. | 854 // Test that the overlay can be committed onto a new tab. |
| 855 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_CommitInNewTab) { | 855 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_CommitInNewTab) { |
| 856 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 856 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 857 FocusOmniboxAndWaitForInstantSupport(); | 857 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 858 | 858 |
| 859 // Use the Instant page as the active tab, so we can exploit its visibility | 859 // Use the Instant page as the active tab, so we can exploit its visibility |
| 860 // handler to check visibility transitions. | 860 // handler to check visibility transitions. |
| 861 ui_test_utils::NavigateToURL(browser(), instant_url()); | 861 ui_test_utils::NavigateToURL(browser(), instant_url()); |
| 862 content::WebContents* active_tab = | 862 content::WebContents* active_tab = |
| 863 browser()->tab_strip_model()->GetActiveWebContents(); | 863 browser()->tab_strip_model()->GetActiveWebContents(); |
| 864 | 864 |
| 865 int active_tab_onvisibilitycalls = -1; | 865 int active_tab_onvisibilitycalls = -1; |
| 866 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", | 866 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", |
| 867 &active_tab_onvisibilitycalls)); | 867 &active_tab_onvisibilitycalls)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 // The ex-active tab should've gotten a visibility change marking it hidden. | 926 // The ex-active tab should've gotten a visibility change marking it hidden. |
| 927 EXPECT_NE(active_tab, overlay); | 927 EXPECT_NE(active_tab, overlay); |
| 928 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", | 928 EXPECT_TRUE(GetIntFromJS(active_tab, "onvisibilitycalls", |
| 929 &active_tab_onvisibilitycalls)); | 929 &active_tab_onvisibilitycalls)); |
| 930 EXPECT_EQ(1, active_tab_onvisibilitycalls); | 930 EXPECT_EQ(1, active_tab_onvisibilitycalls); |
| 931 } | 931 } |
| 932 | 932 |
| 933 // Test that suggestions are reusable. | 933 // Test that suggestions are reusable. |
| 934 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreReusable) { | 934 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreReusable) { |
| 935 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 935 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 936 FocusOmniboxAndWaitForInstantSupport(); | 936 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 937 | 937 |
| 938 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'instant' } ];" | 938 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'instant' } ];" |
| 939 "behavior = 'never';")); | 939 "behavior = 'never';")); |
| 940 | 940 |
| 941 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("in")); | 941 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("in")); |
| 942 EXPECT_EQ(ASCIIToUTF16("stant"), GetGrayText()); | 942 EXPECT_EQ(ASCIIToUTF16("stant"), GetGrayText()); |
| 943 | 943 |
| 944 SetOmniboxText("ins"); | 944 SetOmniboxText("ins"); |
| 945 EXPECT_EQ(ASCIIToUTF16("tant"), GetGrayText()); | 945 EXPECT_EQ(ASCIIToUTF16("tant"), GetGrayText()); |
| 946 | 946 |
| 947 SetOmniboxText("in"); | 947 SetOmniboxText("in"); |
| 948 EXPECT_EQ(ASCIIToUTF16("stant"), GetGrayText()); | 948 EXPECT_EQ(ASCIIToUTF16("stant"), GetGrayText()); |
| 949 | 949 |
| 950 SetOmniboxText("insane"); | 950 SetOmniboxText("insane"); |
| 951 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); | 951 EXPECT_EQ(ASCIIToUTF16(""), GetGrayText()); |
| 952 } | 952 } |
| 953 | 953 |
| 954 // Test that the Instant overlay is recreated if it gets destroyed. | 954 // Test that the Instant overlay is recreated if it gets destroyed. |
| 955 IN_PROC_BROWSER_TEST_F(InstantTest, InstantRenderViewGone) { | 955 IN_PROC_BROWSER_TEST_F(InstantTest, InstantRenderViewGone) { |
| 956 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 956 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 957 FocusOmniboxAndWaitForInstantSupport(); | 957 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 958 | 958 |
| 959 // Type partial query, get suggestion to show. | 959 // Type partial query, get suggestion to show. |
| 960 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("q")); | 960 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("q")); |
| 961 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 961 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
| 962 | 962 |
| 963 // Kill the Instant renderer and wait for Instant support again. | 963 // Kill the Instant renderer and wait for Instant support again. |
| 964 KillInstantRenderView(); | 964 KillInstantRenderView(); |
| 965 FocusOmniboxAndWaitForInstantSupport(); | 965 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 966 | 966 |
| 967 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("qu")); | 967 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("qu")); |
| 968 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 968 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
| 969 } | 969 } |
| 970 | 970 |
| 971 IN_PROC_BROWSER_TEST_F(InstantTest, ProcessIsolation) { | 971 IN_PROC_BROWSER_TEST_F(InstantTest, ProcessIsolation) { |
| 972 // Prior to setup no render process is dedicated to Instant. | 972 // Prior to setup no render process is dedicated to Instant. |
| 973 InstantService* instant_service = | 973 InstantService* instant_service = |
| 974 InstantServiceFactory::GetForProfile(browser()->profile()); | 974 InstantServiceFactory::GetForProfile(browser()->profile()); |
| 975 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 975 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 976 EXPECT_EQ(0, instant_service->GetInstantProcessCount()); | 976 EXPECT_EQ(0, instant_service->GetInstantProcessCount()); |
| 977 | 977 |
| 978 // Setup Instant. | 978 // Setup Instant. |
| 979 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 979 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 980 FocusOmniboxAndWaitForInstantSupport(); | 980 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 981 | 981 |
| 982 // Now there should be a registered Instant render process. | 982 // Now there should be a registered Instant render process. |
| 983 EXPECT_LT(0, instant_service->GetInstantProcessCount()); | 983 EXPECT_LT(0, instant_service->GetInstantProcessCount()); |
| 984 | 984 |
| 985 // And the Instant overlay should live inside it. | 985 // And the Instant overlay should live inside it. |
| 986 content::WebContents* overlay = instant()->GetOverlayContents(); | 986 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 987 EXPECT_TRUE(instant_service->IsInstantProcess( | 987 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 988 overlay->GetRenderProcessHost()->GetID())); | 988 overlay->GetRenderProcessHost()->GetID())); |
| 989 | 989 |
| 990 // Search and commit the search by pressing Alt-Enter. | 990 // Search and commit the search by pressing Alt-Enter. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1013 "testImage.src = 'data:image/png;base64,Qk1GAAAAAAAAADYAAAAoAAAAAgAAAAIA" | 1013 "testImage.src = 'data:image/png;base64,Qk1GAAAAAAAAADYAAAAoAAAAAgAAAAIA" |
| 1014 "AAABABgAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAA/w==';"; | 1014 "AAABABgAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAA/w==';"; |
| 1015 | 1015 |
| 1016 Profile* profile = browser()->profile(); | 1016 Profile* profile = browser()->profile(); |
| 1017 | 1017 |
| 1018 // Block images through content settings. | 1018 // Block images through content settings. |
| 1019 profile->GetHostContentSettingsMap()->SetDefaultContentSetting( | 1019 profile->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 1020 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); | 1020 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
| 1021 | 1021 |
| 1022 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1022 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1023 FocusOmniboxAndWaitForInstantSupport(); | 1023 FocusOmniboxAndWaitForInstantOverlaySupport(); |
| 1024 | 1024 |
| 1025 InstantService* instant_service = | 1025 InstantService* instant_service = |
| 1026 InstantServiceFactory::GetForProfile(profile); | 1026 InstantServiceFactory::GetForProfile(profile); |
| 1027 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); | 1027 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 1028 | 1028 |
| 1029 // Make sure this is an Instant process. | 1029 // Make sure this is an Instant process. |
| 1030 content::WebContents* overlay = instant()->GetOverlayContents(); | 1030 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1031 EXPECT_TRUE(instant_service->IsInstantProcess( | 1031 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 1032 overlay->GetRenderProcessHost()->GetID())); | 1032 overlay->GetRenderProcessHost()->GetID())); |
| 1033 | 1033 |
| 1034 bool result; | 1034 bool result; |
| 1035 EXPECT_TRUE(ExecuteScriptAndExtractBool(overlay, kImageRenderScript, | 1035 EXPECT_TRUE(ExecuteScriptAndExtractBool(overlay, kImageRenderScript, |
| 1036 &result)); | 1036 &result)); |
| 1037 EXPECT_TRUE(result); | 1037 EXPECT_TRUE(result); |
| 1038 } | 1038 } |
| OLD | NEW |