| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram_base.h" | 8 #include "base/metrics/histogram_base.h" |
| 9 #include "base/metrics/histogram_samples.h" | 9 #include "base/metrics/histogram_samples.h" |
| 10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "chrome/browser/search/search.h" | 39 #include "chrome/browser/search/search.h" |
| 40 #include "chrome/browser/search_engines/template_url_service.h" | 40 #include "chrome/browser/search_engines/template_url_service.h" |
| 41 #include "chrome/browser/search_engines/template_url_service_factory.h" | 41 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 42 #include "chrome/browser/task_manager/task_manager.h" | 42 #include "chrome/browser/task_manager/task_manager.h" |
| 43 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 43 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 44 #include "chrome/browser/themes/theme_service.h" | 44 #include "chrome/browser/themes/theme_service.h" |
| 45 #include "chrome/browser/themes/theme_service_factory.h" | 45 #include "chrome/browser/themes/theme_service_factory.h" |
| 46 #include "chrome/browser/ui/browser_list.h" | 46 #include "chrome/browser/ui/browser_list.h" |
| 47 #include "chrome/browser/ui/browser_tabstrip.h" | 47 #include "chrome/browser/ui/browser_tabstrip.h" |
| 48 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 48 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 49 #include "chrome/browser/ui/search/instant_ntp.h" |
| 50 #include "chrome/browser/ui/search/instant_ntp_prerenderer.h" |
| 49 #include "chrome/browser/ui/search/instant_tab.h" | 51 #include "chrome/browser/ui/search/instant_tab.h" |
| 50 #include "chrome/browser/ui/search/instant_test_utils.h" | 52 #include "chrome/browser/ui/search/instant_test_utils.h" |
| 51 #include "chrome/browser/ui/search/search_tab_helper.h" | 53 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 52 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 54 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 53 #include "chrome/browser/ui/webui/theme_source.h" | 55 #include "chrome/browser/ui/webui/theme_source.h" |
| 54 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
| 55 #include "chrome/common/instant_types.h" | 57 #include "chrome/common/instant_types.h" |
| 56 #include "chrome/common/pref_names.h" | 58 #include "chrome/common/pref_names.h" |
| 57 #include "chrome/common/thumbnail_score.h" | 59 #include "chrome/common/thumbnail_score.h" |
| 58 #include "chrome/common/url_constants.h" | 60 #include "chrome/common/url_constants.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 on_focus_changed_calls_(0), | 146 on_focus_changed_calls_(0), |
| 145 is_focused_(false), | 147 is_focused_(false), |
| 146 on_toggle_voice_search_calls_(0) { | 148 on_toggle_voice_search_calls_(0) { |
| 147 } | 149 } |
| 148 protected: | 150 protected: |
| 149 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 151 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 150 chrome::EnableQueryExtractionForTesting(); | 152 chrome::EnableQueryExtractionForTesting(); |
| 151 ASSERT_TRUE(https_test_server().Start()); | 153 ASSERT_TRUE(https_test_server().Start()); |
| 152 GURL instant_url = https_test_server().GetURL( | 154 GURL instant_url = https_test_server().GetURL( |
| 153 "files/instant_extended.html?strk=1&"); | 155 "files/instant_extended.html?strk=1&"); |
| 154 GURL ntp_url = https_test_server().GetURL( | 156 InstantTestBase::Init(instant_url, false); |
| 155 "files/instant_extended_ntp.html?strk=1&"); | |
| 156 InstantTestBase::Init(instant_url, ntp_url, false); | |
| 157 } | 157 } |
| 158 | 158 |
| 159 int64 GetHistogramCount(const char* name) { | 159 int64 GetHistogramCount(const char* name) { |
| 160 base::HistogramBase* histogram = | 160 base::HistogramBase* histogram = |
| 161 base::StatisticsRecorder::FindHistogram(name); | 161 base::StatisticsRecorder::FindHistogram(name); |
| 162 if (!histogram) { | 162 if (!histogram) { |
| 163 // If no histogram is found, it's possible that no values have been | 163 // If no histogram is found, it's possible that no values have been |
| 164 // recorded yet. Assume that the value is zero. | 164 // recorded yet. Assume that the value is zero. |
| 165 return 0; | 165 return 0; |
| 166 } | 166 } |
| 167 return histogram->SnapshotSamples()->TotalCount(); | 167 return histogram->SnapshotSamples()->TotalCount(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void SendDownArrow() { |
| 171 omnibox()->model()->OnUpOrDownKeyPressed(1); |
| 172 // Wait for JavaScript to run the key handler by executing a blank script. |
| 173 EXPECT_TRUE(ExecuteScript(std::string())); |
| 174 } |
| 175 |
| 176 void SendUpArrow() { |
| 177 omnibox()->model()->OnUpOrDownKeyPressed(-1); |
| 178 // Wait for JavaScript to run the key handler by executing a blank script. |
| 179 EXPECT_TRUE(ExecuteScript(std::string())); |
| 180 } |
| 181 |
| 182 void SendEscape() { |
| 183 omnibox()->model()->OnEscapeKeyPressed(); |
| 184 // Wait for JavaScript to run the key handler by executing a blank script. |
| 185 EXPECT_TRUE(ExecuteScript(std::string())); |
| 186 } |
| 187 |
| 170 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT { | 188 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT { |
| 171 return GetIntFromJS(contents, "onMostVisitedChangedCalls", | 189 return GetIntFromJS(contents, "onMostVisitedChangedCalls", |
| 172 &on_most_visited_change_calls_) && | 190 &on_most_visited_change_calls_) && |
| 173 GetIntFromJS(contents, "mostVisitedItemsCount", | 191 GetIntFromJS(contents, "mostVisitedItemsCount", |
| 174 &most_visited_items_count_) && | 192 &most_visited_items_count_) && |
| 175 GetIntFromJS(contents, "firstMostVisitedItemId", | 193 GetIntFromJS(contents, "firstMostVisitedItemId", |
| 176 &first_most_visited_item_id_) && | 194 &first_most_visited_item_id_) && |
| 177 GetIntFromJS(contents, "onNativeSuggestionsCalls", | 195 GetIntFromJS(contents, "onNativeSuggestionsCalls", |
| 178 &on_native_suggestions_calls_) && | 196 &on_native_suggestions_calls_) && |
| 179 GetIntFromJS(contents, "onChangeCalls", | 197 GetIntFromJS(contents, "onChangeCalls", |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 InstantExtendedPrefetchTest() | 272 InstantExtendedPrefetchTest() |
| 255 : factory_(new net::URLFetcherImplFactory()), | 273 : factory_(new net::URLFetcherImplFactory()), |
| 256 fake_factory_(new net::FakeURLFetcherFactory(factory_.get())) { | 274 fake_factory_(new net::FakeURLFetcherFactory(factory_.get())) { |
| 257 } | 275 } |
| 258 | 276 |
| 259 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 277 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 260 chrome::EnableQueryExtractionForTesting(); | 278 chrome::EnableQueryExtractionForTesting(); |
| 261 ASSERT_TRUE(https_test_server().Start()); | 279 ASSERT_TRUE(https_test_server().Start()); |
| 262 GURL instant_url = https_test_server().GetURL( | 280 GURL instant_url = https_test_server().GetURL( |
| 263 "files/instant_extended.html?strk=1&"); | 281 "files/instant_extended.html?strk=1&"); |
| 264 GURL ntp_url = https_test_server().GetURL( | 282 InstantTestBase::Init(instant_url, true); |
| 265 "files/instant_extended_ntp.html?strk=1&"); | |
| 266 InstantTestBase::Init(instant_url, ntp_url, true); | |
| 267 } | 283 } |
| 268 | 284 |
| 269 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 285 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 270 command_line->AppendSwitchASCII( | 286 command_line->AppendSwitchASCII( |
| 271 switches::kForceFieldTrials, | 287 switches::kForceFieldTrials, |
| 272 "EmbeddedSearch/Group11 prefetch_results_srp:1/"); | 288 "EmbeddedSearch/Group11 prefetch_results_srp:1 use_cacheable_ntp:0/"); |
| 273 } | 289 } |
| 274 | 290 |
| 275 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); } | 291 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); } |
| 276 | 292 |
| 277 private: | 293 private: |
| 278 // Used to instantiate FakeURLFetcherFactory. | 294 // Used to instantiate FakeURLFetcherFactory. |
| 279 scoped_ptr<net::URLFetcherImplFactory> factory_; | 295 scoped_ptr<net::URLFetcherImplFactory> factory_; |
| 280 | 296 |
| 281 // Used to mock default search provider suggest response. | 297 // Used to mock default search provider suggest response. |
| 282 scoped_ptr<net::FakeURLFetcherFactory> fake_factory_; | 298 scoped_ptr<net::FakeURLFetcherFactory> fake_factory_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 312 // loads a theme that provides a background image. | 328 // loads a theme that provides a background image. |
| 313 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { | 329 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { |
| 314 public: | 330 public: |
| 315 InstantPolicyTest() {} | 331 InstantPolicyTest() {} |
| 316 | 332 |
| 317 protected: | 333 protected: |
| 318 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 334 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 319 ASSERT_TRUE(https_test_server().Start()); | 335 ASSERT_TRUE(https_test_server().Start()); |
| 320 GURL instant_url = https_test_server().GetURL( | 336 GURL instant_url = https_test_server().GetURL( |
| 321 "files/instant_extended.html?strk=1&"); | 337 "files/instant_extended.html?strk=1&"); |
| 322 GURL ntp_url = https_test_server().GetURL( | 338 InstantTestBase::Init(instant_url, false); |
| 323 "files/instant_extended_ntp.html?strk=1&"); | |
| 324 InstantTestBase::Init(instant_url, ntp_url, false); | |
| 325 } | 339 } |
| 326 | 340 |
| 327 void InstallThemeSource() { | 341 void InstallThemeSource() { |
| 328 ThemeSource* theme = new ThemeSource(profile()); | 342 ThemeSource* theme = new ThemeSource(profile()); |
| 329 content::URLDataSource::Add(profile(), theme); | 343 content::URLDataSource::Add(profile(), theme); |
| 330 } | 344 } |
| 331 | 345 |
| 332 void InstallThemeAndVerify(const std::string& theme_dir, | 346 void InstallThemeAndVerify(const std::string& theme_dir, |
| 333 const std::string& theme_name) { | 347 const std::string& theme_name) { |
| 334 const extensions::Extension* theme = | 348 const extensions::Extension* theme = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 345 ThemeServiceFactory::GetThemeForProfile( | 359 ThemeServiceFactory::GetThemeForProfile( |
| 346 ExtensionBrowserTest::browser()->profile()); | 360 ExtensionBrowserTest::browser()->profile()); |
| 347 ASSERT_NE(static_cast<extensions::Extension*>(NULL), new_theme); | 361 ASSERT_NE(static_cast<extensions::Extension*>(NULL), new_theme); |
| 348 ASSERT_EQ(new_theme->name(), theme_name); | 362 ASSERT_EQ(new_theme->name(), theme_name); |
| 349 } | 363 } |
| 350 | 364 |
| 351 private: | 365 private: |
| 352 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); | 366 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); |
| 353 }; | 367 }; |
| 354 | 368 |
| 369 IN_PROC_BROWSER_TEST_F(InstantExtendedNetworkTest, NTPReactsToNetworkChanges) { |
| 370 // Setup Instant. |
| 371 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 372 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 373 |
| 374 InstantService* instant_service = |
| 375 InstantServiceFactory::GetForProfile(browser()->profile()); |
| 376 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); |
| 377 |
| 378 // The setup first initializes the platform specific NetworkChangeNotifier. |
| 379 // The InstantExtendedNetworkTest replaces it with a fake, but by the time, |
| 380 // InstantNTPPrerenderer has already registered itself. So the |
| 381 // InstantNTPPrerenderer needs to register itself as NetworkChangeObserver |
| 382 // again. |
| 383 net::NetworkChangeNotifier::AddNetworkChangeObserver( |
| 384 instant_service->ntp_prerenderer()); |
| 385 |
| 386 // The fake network change notifier will provide the network state to be |
| 387 // offline, so the ntp will be local. |
| 388 ASSERT_NE(static_cast<InstantNTP*>(NULL), |
| 389 instant_service->ntp_prerenderer()->ntp()); |
| 390 EXPECT_TRUE(instant_service->ntp_prerenderer()->ntp()->IsLocal()); |
| 391 |
| 392 // Change the connect state, and wait for the notifications to be run, and NTP |
| 393 // support to be determined. |
| 394 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET); |
| 395 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 396 |
| 397 // Verify the network state is fine, and InstantNTPPrerenderer doesn't want |
| 398 // to switch to local NTP anymore. |
| 399 EXPECT_FALSE(net::NetworkChangeNotifier::IsOffline()); |
| 400 EXPECT_FALSE(instant_service->ntp_prerenderer()->ShouldSwitchToLocalNTP()); |
| 401 |
| 402 // Open new tab. |
| 403 ui_test_utils::NavigateToURLWithDisposition( |
| 404 browser(), |
| 405 GURL(chrome::kChromeUINewTabURL), |
| 406 NEW_FOREGROUND_TAB, |
| 407 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 408 content::WebContents* active_tab = |
| 409 browser()->tab_strip_model()->GetActiveWebContents(); |
| 410 |
| 411 // Verify new NTP is not local. |
| 412 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); |
| 413 EXPECT_NE(instant_service->ntp_prerenderer()->GetLocalInstantURL(), |
| 414 active_tab->GetURL().spec()); |
| 415 ASSERT_NE(static_cast<InstantNTP*>(NULL), |
| 416 instant_service->ntp_prerenderer()->ntp()); |
| 417 EXPECT_FALSE(instant_service->ntp_prerenderer()->ntp()->IsLocal()); |
| 418 |
| 419 SetConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE); |
| 420 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 421 |
| 422 // Verify the network state is fine, and InstantNTPPrerenderer doesn't want |
| 423 // to switch to local NTP anymore. |
| 424 EXPECT_TRUE(net::NetworkChangeNotifier::IsOffline()); |
| 425 EXPECT_TRUE(instant_service->ntp_prerenderer()->ShouldSwitchToLocalNTP()); |
| 426 |
| 427 // Open new tab. Preloaded NTP contents should have been used. |
| 428 ui_test_utils::NavigateToURLWithDisposition( |
| 429 browser(), |
| 430 GURL(chrome::kChromeUINewTabURL), |
| 431 NEW_FOREGROUND_TAB, |
| 432 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 433 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 434 |
| 435 // Verify new NTP is not local. |
| 436 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); |
| 437 EXPECT_EQ(instant_service->ntp_prerenderer()->GetLocalInstantURL(), |
| 438 active_tab->GetURL().spec()); |
| 439 ASSERT_NE(static_cast<InstantNTP*>(NULL), |
| 440 instant_service->ntp_prerenderer()->ntp()); |
| 441 EXPECT_TRUE(instant_service->ntp_prerenderer()->ntp()->IsLocal()); |
| 442 } |
| 443 |
| 355 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, SearchReusesInstantTab) { | 444 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, SearchReusesInstantTab) { |
| 356 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 445 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 357 FocusOmnibox(); | 446 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 358 | 447 |
| 359 content::WindowedNotificationObserver observer( | 448 content::WindowedNotificationObserver observer( |
| 360 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 449 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 361 content::NotificationService::AllSources()); | 450 content::NotificationService::AllSources()); |
| 362 SetOmniboxText("flowers"); | 451 SetOmniboxText("flowers"); |
| 363 PressEnterAndWaitForNavigation(); | 452 PressEnterAndWaitForNavigation(); |
| 364 observer.Wait(); | 453 observer.Wait(); |
| 365 | 454 |
| 366 // Just did a regular search. | 455 // Just did a regular search. |
| 367 content::WebContents* active_tab = | 456 content::WebContents* active_tab = |
| 368 browser()->tab_strip_model()->GetActiveWebContents(); | 457 browser()->tab_strip_model()->GetActiveWebContents(); |
| 369 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=flowers")); | 458 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=flowers")); |
| 370 ASSERT_TRUE(UpdateSearchState(active_tab)); | 459 ASSERT_TRUE(UpdateSearchState(active_tab)); |
| 371 ASSERT_EQ(0, submit_count_); | 460 ASSERT_EQ(0, submit_count_); |
| 372 | 461 |
| 373 SetOmniboxText("puppies"); | 462 SetOmniboxText("puppies"); |
| 374 PressEnterAndWaitForNavigation(); | 463 PressEnterAndWaitForNavigation(); |
| 375 | 464 |
| 376 // Should have reused the tab and sent an onsubmit message. | 465 // Should have reused the tab and sent an onsubmit message. |
| 377 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 466 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 378 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies")); | 467 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies")); |
| 379 ASSERT_TRUE(UpdateSearchState(active_tab)); | 468 ASSERT_TRUE(UpdateSearchState(active_tab)); |
| 380 EXPECT_EQ(1, submit_count_); | 469 EXPECT_EQ(1, submit_count_); |
| 381 } | 470 } |
| 382 | 471 |
| 383 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 472 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 384 SearchDoesntReuseInstantTabWithoutSupport) { | 473 SearchDoesntReuseInstantTabWithoutSupport) { |
| 385 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 474 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 386 FocusOmnibox(); | 475 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 387 | 476 |
| 388 // Don't wait for the navigation to complete. | 477 // Don't wait for the navigation to complete. |
| 389 SetOmniboxText("flowers"); | 478 SetOmniboxText("flowers"); |
| 390 browser()->window()->GetLocationBar()->AcceptInput(); | 479 browser()->window()->GetLocationBar()->AcceptInput(); |
| 391 | 480 |
| 392 SetOmniboxText("puppies"); | 481 SetOmniboxText("puppies"); |
| 393 browser()->window()->GetLocationBar()->AcceptInput(); | 482 browser()->window()->GetLocationBar()->AcceptInput(); |
| 394 | 483 |
| 395 // Should not have reused the tab. | 484 // Should not have reused the tab. |
| 396 ASSERT_THAT( | 485 ASSERT_THAT( |
| 397 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(), | 486 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(), |
| 398 HasSubstr("q=puppies")); | 487 HasSubstr("q=puppies")); |
| 399 } | 488 } |
| 400 | 489 |
| 401 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 490 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 402 TypedSearchURLDoesntReuseInstantTab) { | 491 TypedSearchURLDoesntReuseInstantTab) { |
| 403 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 492 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 404 FocusOmnibox(); | 493 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 405 | 494 |
| 406 // Create an observer to wait for the instant tab to support Instant. | 495 // Create an observer to wait for the instant tab to support Instant. |
| 407 content::WindowedNotificationObserver observer_1( | 496 content::WindowedNotificationObserver observer_1( |
| 408 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 497 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 409 content::NotificationService::AllSources()); | 498 content::NotificationService::AllSources()); |
| 410 SetOmniboxText("flowers"); | 499 SetOmniboxText("flowers"); |
| 411 PressEnterAndWaitForNavigation(); | 500 PressEnterAndWaitForNavigation(); |
| 412 observer_1.Wait(); | 501 observer_1.Wait(); |
| 413 | 502 |
| 414 // Just did a regular search. | 503 // Just did a regular search. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 426 PressEnterAndWaitForNavigation(); | 515 PressEnterAndWaitForNavigation(); |
| 427 observer_2.Wait(); | 516 observer_2.Wait(); |
| 428 | 517 |
| 429 // Should not have reused the tab. | 518 // Should not have reused the tab. |
| 430 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 519 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 431 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies")); | 520 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies")); |
| 432 } | 521 } |
| 433 | 522 |
| 434 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxMarginSetForSearchURLs) { | 523 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxMarginSetForSearchURLs) { |
| 435 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 524 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 436 FocusOmnibox(); | 525 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 437 | 526 |
| 438 // Create an observer to wait for the instant tab to support Instant. | 527 // Create an observer to wait for the instant tab to support Instant. |
| 439 content::WindowedNotificationObserver observer( | 528 content::WindowedNotificationObserver observer( |
| 440 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 529 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 441 content::NotificationService::AllSources()); | 530 content::NotificationService::AllSources()); |
| 442 | 531 |
| 443 SetOmniboxText("flowers"); | 532 SetOmniboxText("flowers"); |
| 444 browser()->window()->GetLocationBar()->AcceptInput(); | 533 browser()->window()->GetLocationBar()->AcceptInput(); |
| 445 observer.Wait(); | 534 observer.Wait(); |
| 446 | 535 |
| 447 const std::string& url = | 536 const std::string& url = |
| 448 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(); | 537 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(); |
| 449 // Make sure we actually used search_url, not instant_url. | 538 // Make sure we actually used search_url, not instant_url. |
| 450 ASSERT_THAT(url, HasSubstr("&is_search")); | 539 ASSERT_THAT(url, HasSubstr("&is_search")); |
| 451 EXPECT_THAT(url, HasSubstr("&es_sm=")); | 540 EXPECT_THAT(url, HasSubstr("&es_sm=")); |
| 452 } | 541 } |
| 453 | 542 |
| 454 // Test to verify that switching tabs should not dispatch onmostvisitedchanged | 543 // Test to verify that switching tabs should not dispatch onmostvisitedchanged |
| 455 // events. | 544 // events. |
| 456 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoMostVisitedChangedOnTabSwitch) { | 545 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoMostVisitedChangedOnTabSwitch) { |
| 457 // Initialize Instant. | 546 // Initialize Instant. |
| 458 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 547 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 548 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 459 | 549 |
| 460 // Open new tab. | 550 // Open new tab. Preloaded NTP contents should have been used. |
| 461 ui_test_utils::NavigateToURLWithDisposition( | 551 ui_test_utils::NavigateToURLWithDisposition( |
| 462 browser(), | 552 browser(), |
| 463 GURL(chrome::kChromeUINewTabURL), | 553 GURL(chrome::kChromeUINewTabURL), |
| 464 NEW_FOREGROUND_TAB, | 554 NEW_FOREGROUND_TAB, |
| 465 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 555 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 466 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 467 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 556 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 468 | 557 |
| 469 // Make sure new tab received the onmostvisitedchanged event once. | 558 // Make sure new tab received the onmostvisitedchanged event once. |
| 470 content::WebContents* active_tab = | 559 content::WebContents* active_tab = |
| 471 browser()->tab_strip_model()->GetActiveWebContents(); | 560 browser()->tab_strip_model()->GetActiveWebContents(); |
| 472 EXPECT_TRUE(UpdateSearchState(active_tab)); | 561 EXPECT_TRUE(UpdateSearchState(active_tab)); |
| 473 EXPECT_EQ(1, on_most_visited_change_calls_); | 562 EXPECT_EQ(1, on_most_visited_change_calls_); |
| 474 | 563 |
| 475 // Activate the previous tab. | 564 // Activate the previous tab. |
| 476 browser()->tab_strip_model()->ActivateTabAt(0, false); | 565 browser()->tab_strip_model()->ActivateTabAt(0, false); |
| 477 | 566 |
| 478 // Switch back to new tab. | 567 // Switch back to new tab. |
| 479 browser()->tab_strip_model()->ActivateTabAt(1, false); | 568 browser()->tab_strip_model()->ActivateTabAt(1, false); |
| 480 | 569 |
| 481 // Confirm that new tab got no onmostvisitedchanged event. | 570 // Confirm that new tab got no onmostvisitedchanged event. |
| 482 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 571 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 483 EXPECT_TRUE(UpdateSearchState(active_tab)); | 572 EXPECT_TRUE(UpdateSearchState(active_tab)); |
| 484 EXPECT_EQ(1, on_most_visited_change_calls_); | 573 EXPECT_EQ(1, on_most_visited_change_calls_); |
| 485 } | 574 } |
| 486 | 575 |
| 487 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { | 576 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) { |
| 488 InstallThemeSource(); | 577 InstallThemeSource(); |
| 489 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); | 578 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); |
| 490 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 579 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 580 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 491 | 581 |
| 492 // The "Instant" New Tab should have access to chrome-search: scheme but not | 582 // The "Instant" New Tab should have access to chrome-search: scheme but not |
| 493 // chrome: scheme. | 583 // chrome: scheme. |
| 494 ui_test_utils::NavigateToURLWithDisposition( | 584 ui_test_utils::NavigateToURLWithDisposition( |
| 495 browser(), | 585 browser(), |
| 496 GURL(chrome::kChromeUINewTabURL), | 586 GURL(chrome::kChromeUINewTabURL), |
| 497 NEW_FOREGROUND_TAB, | 587 NEW_FOREGROUND_TAB, |
| 498 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 588 ui_test_utils::BROWSER_TEST_NONE); |
| 499 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 500 | 589 |
| 501 content::RenderViewHost* rvh = | 590 content::RenderViewHost* rvh = |
| 502 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); | 591 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(); |
| 503 | 592 |
| 504 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); | 593 const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND"); |
| 505 const std::string search_url( | 594 const std::string search_url( |
| 506 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); | 595 "chrome-search://theme/IDR_THEME_NTP_BACKGROUND"); |
| 507 bool loaded = false; | 596 bool loaded = false; |
| 508 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); | 597 ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded)); |
| 509 EXPECT_FALSE(loaded) << chrome_url; | 598 EXPECT_FALSE(loaded) << chrome_url; |
| 510 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); | 599 ASSERT_TRUE(LoadImage(rvh, search_url, &loaded)); |
| 511 EXPECT_TRUE(loaded) << search_url; | 600 EXPECT_TRUE(loaded) << search_url; |
| 512 } | 601 } |
| 513 | 602 |
| 514 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, | 603 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, |
| 515 NoThemeBackgroundChangeEventOnTabSwitch) { | 604 NoThemeBackgroundChangeEventOnTabSwitch) { |
| 516 InstallThemeSource(); | 605 InstallThemeSource(); |
| 517 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 606 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 607 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 518 | 608 |
| 519 // Install a theme. | 609 // Install a theme. |
| 520 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); | 610 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); |
| 521 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 611 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 522 | 612 |
| 523 // Open new tab. | 613 // Open new tab. Preloaded NTP contents should have been used. |
| 524 ui_test_utils::NavigateToURLWithDisposition( | 614 ui_test_utils::NavigateToURLWithDisposition( |
| 525 browser(), | 615 browser(), |
| 526 GURL(chrome::kChromeUINewTabURL), | 616 GURL(chrome::kChromeUINewTabURL), |
| 527 NEW_FOREGROUND_TAB, | 617 NEW_FOREGROUND_TAB, |
| 528 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 618 ui_test_utils::BROWSER_TEST_NONE); |
| 529 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 530 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 619 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 531 | 620 |
| 532 content::WebContents* active_tab = | 621 content::WebContents* active_tab = |
| 533 browser()->tab_strip_model()->GetActiveWebContents(); | 622 browser()->tab_strip_model()->GetActiveWebContents(); |
| 534 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); | 623 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 535 int on_theme_changed_calls = 0; | 624 int on_theme_changed_calls = 0; |
| 536 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", | 625 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", |
| 537 &on_theme_changed_calls)); | 626 &on_theme_changed_calls)); |
| 538 EXPECT_EQ(1, on_theme_changed_calls); | 627 EXPECT_EQ(1, on_theme_changed_calls); |
| 539 | 628 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 557 // Flaky on Linux: http://crbug.com/265971 | 646 // Flaky on Linux: http://crbug.com/265971 |
| 558 #if defined(OS_LINUX) | 647 #if defined(OS_LINUX) |
| 559 #define MAYBE_SendThemeBackgroundChangedEvent DISABLED_SendThemeBackgroundChange
dEvent | 648 #define MAYBE_SendThemeBackgroundChangedEvent DISABLED_SendThemeBackgroundChange
dEvent |
| 560 #else | 649 #else |
| 561 #define MAYBE_SendThemeBackgroundChangedEvent SendThemeBackgroundChangedEvent | 650 #define MAYBE_SendThemeBackgroundChangedEvent SendThemeBackgroundChangedEvent |
| 562 #endif | 651 #endif |
| 563 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, | 652 IN_PROC_BROWSER_TEST_F(InstantPolicyTest, |
| 564 MAYBE_SendThemeBackgroundChangedEvent) { | 653 MAYBE_SendThemeBackgroundChangedEvent) { |
| 565 InstallThemeSource(); | 654 InstallThemeSource(); |
| 566 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 655 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 656 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 567 | 657 |
| 568 // Install a theme. | 658 // Install a theme. |
| 569 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); | 659 ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme")); |
| 570 | 660 |
| 571 // Open new tab. | 661 // Open new tab. Preloaded NTP contents should have been used. |
| 572 ui_test_utils::NavigateToURLWithDisposition( | 662 ui_test_utils::NavigateToURLWithDisposition( |
| 573 browser(), | 663 browser(), |
| 574 GURL(chrome::kChromeUINewTabURL), | 664 GURL(chrome::kChromeUINewTabURL), |
| 575 NEW_FOREGROUND_TAB, | 665 NEW_FOREGROUND_TAB, |
| 576 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 666 ui_test_utils::BROWSER_TEST_NONE); |
| 577 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 578 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 667 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 579 | 668 |
| 580 // Make sure new tab received an onthemechanged event. | 669 // Make sure new tab received an onthemechanged event. |
| 581 content::WebContents* active_tab = | 670 content::WebContents* active_tab = |
| 582 browser()->tab_strip_model()->GetActiveWebContents(); | 671 browser()->tab_strip_model()->GetActiveWebContents(); |
| 583 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); | 672 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 584 int on_theme_changed_calls = 0; | 673 int on_theme_changed_calls = 0; |
| 585 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", | 674 EXPECT_TRUE(GetIntFromJS(active_tab, "onThemeChangedCalls", |
| 586 &on_theme_changed_calls)); | 675 &on_theme_changed_calls)); |
| 587 EXPECT_EQ(1, on_theme_changed_calls); | 676 EXPECT_EQ(1, on_theme_changed_calls); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 602 #else | 691 #else |
| 603 #define MAYBE_UpdateSearchQueryOnBackNavigation UpdateSearchQueryOnBackNavigatio
n | 692 #define MAYBE_UpdateSearchQueryOnBackNavigation UpdateSearchQueryOnBackNavigatio
n |
| 604 #endif | 693 #endif |
| 605 // Test to verify that the omnibox search query is updated on browser | 694 // Test to verify that the omnibox search query is updated on browser |
| 606 // back button press event. | 695 // back button press event. |
| 607 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 696 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 608 MAYBE_UpdateSearchQueryOnBackNavigation) { | 697 MAYBE_UpdateSearchQueryOnBackNavigation) { |
| 609 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 698 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 610 | 699 |
| 611 // Focus omnibox and confirm overlay isn't shown. | 700 // Focus omnibox and confirm overlay isn't shown. |
| 612 FocusOmnibox(); | 701 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 613 | 702 |
| 614 // Create an observer to wait for the instant tab to support Instant. | 703 // Create an observer to wait for the instant tab to support Instant. |
| 615 content::WindowedNotificationObserver observer( | 704 content::WindowedNotificationObserver observer( |
| 616 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 705 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 617 content::NotificationService::AllSources()); | 706 content::NotificationService::AllSources()); |
| 618 | 707 |
| 619 SetOmniboxText("flowers"); | 708 SetOmniboxText("flowers"); |
| 620 // Commit the search by pressing 'Enter'. | 709 // Commit the search by pressing 'Enter'. |
| 621 PressEnterAndWaitForNavigation(); | 710 PressEnterAndWaitForNavigation(); |
| 622 observer.Wait(); | 711 observer.Wait(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 649 } | 738 } |
| 650 | 739 |
| 651 // Flaky: crbug.com/253092. | 740 // Flaky: crbug.com/253092. |
| 652 // Test to verify that the omnibox search query is updated on browser | 741 // Test to verify that the omnibox search query is updated on browser |
| 653 // forward button press events. | 742 // forward button press events. |
| 654 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 743 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 655 DISABLED_UpdateSearchQueryOnForwardNavigation) { | 744 DISABLED_UpdateSearchQueryOnForwardNavigation) { |
| 656 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 745 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 657 | 746 |
| 658 // Focus omnibox and confirm overlay isn't shown. | 747 // Focus omnibox and confirm overlay isn't shown. |
| 659 FocusOmnibox(); | 748 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 660 | 749 |
| 661 // Create an observer to wait for the instant tab to support Instant. | 750 // Create an observer to wait for the instant tab to support Instant. |
| 662 content::WindowedNotificationObserver observer( | 751 content::WindowedNotificationObserver observer( |
| 663 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 752 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 664 content::NotificationService::AllSources()); | 753 content::NotificationService::AllSources()); |
| 665 | 754 |
| 666 SetOmniboxText("flowers"); | 755 SetOmniboxText("flowers"); |
| 667 // Commit the search by pressing 'Enter'. | 756 // Commit the search by pressing 'Enter'. |
| 668 PressEnterAndWaitForNavigation(); | 757 PressEnterAndWaitForNavigation(); |
| 669 observer.Wait(); | 758 observer.Wait(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 // Commit the search by pressing 'Enter'. | 791 // Commit the search by pressing 'Enter'. |
| 703 FocusOmnibox(); | 792 FocusOmnibox(); |
| 704 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); | 793 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); |
| 705 PressEnterAndWaitForNavigation(); | 794 PressEnterAndWaitForNavigation(); |
| 706 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); | 795 EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); |
| 707 } | 796 } |
| 708 | 797 |
| 709 // Flaky on all bots since re-enabled in r208032, crbug.com/253092 | 798 // Flaky on all bots since re-enabled in r208032, crbug.com/253092 |
| 710 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) { | 799 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) { |
| 711 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 800 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 712 FocusOmnibox(); | 801 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 713 | 802 |
| 714 // Open a new tab page. | 803 // Open a new tab page. |
| 715 ui_test_utils::NavigateToURLWithDisposition( | 804 ui_test_utils::NavigateToURLWithDisposition( |
| 716 browser(), | 805 browser(), |
| 717 GURL(chrome::kChromeUINewTabURL), | 806 GURL(chrome::kChromeUINewTabURL), |
| 718 NEW_FOREGROUND_TAB, | 807 NEW_FOREGROUND_TAB, |
| 719 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 808 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 720 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 721 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 809 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 722 | 810 |
| 723 content::WindowedNotificationObserver observer( | 811 content::WindowedNotificationObserver observer( |
| 724 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | 812 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 725 content::NotificationService::AllSources()); | 813 content::NotificationService::AllSources()); |
| 726 SetOmniboxText("flowers"); | 814 SetOmniboxText("flowers"); |
| 727 PressEnterAndWaitForNavigation(); | 815 PressEnterAndWaitForNavigation(); |
| 728 observer.Wait(); | 816 observer.Wait(); |
| 729 | 817 |
| 730 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); | 818 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 851 |
| 764 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 852 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 765 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); | 853 EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); |
| 766 } | 854 } |
| 767 | 855 |
| 768 // Flaky: crbug.com/267119 | 856 // Flaky: crbug.com/267119 |
| 769 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 857 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 770 DISABLED_DispatchMVChangeEventWhileNavigatingBackToNTP) { | 858 DISABLED_DispatchMVChangeEventWhileNavigatingBackToNTP) { |
| 771 // Setup Instant. | 859 // Setup Instant. |
| 772 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 860 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 773 FocusOmnibox(); | 861 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 774 | 862 |
| 775 // Open new tab. | 863 // Open new tab. Preloaded NTP contents should have been used. |
| 776 ui_test_utils::NavigateToURLWithDisposition( | 864 ui_test_utils::NavigateToURLWithDisposition( |
| 777 browser(), | 865 browser(), |
| 778 GURL(chrome::kChromeUINewTabURL), | 866 GURL(chrome::kChromeUINewTabURL), |
| 779 NEW_FOREGROUND_TAB, | 867 NEW_FOREGROUND_TAB, |
| 780 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 868 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 781 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 782 | 869 |
| 783 content::WebContents* active_tab = | 870 content::WebContents* active_tab = |
| 784 browser()->tab_strip_model()->GetActiveWebContents(); | 871 browser()->tab_strip_model()->GetActiveWebContents(); |
| 785 EXPECT_TRUE(UpdateSearchState(active_tab)); | 872 EXPECT_TRUE(UpdateSearchState(active_tab)); |
| 786 EXPECT_EQ(1, on_most_visited_change_calls_); | 873 EXPECT_EQ(1, on_most_visited_change_calls_); |
| 787 | 874 |
| 788 content::WindowedNotificationObserver observer( | 875 content::WindowedNotificationObserver observer( |
| 789 content::NOTIFICATION_LOAD_STOP, | 876 content::NOTIFICATION_LOAD_STOP, |
| 790 content::NotificationService::AllSources()); | 877 content::NotificationService::AllSources()); |
| 791 // Set the text and press enter to navigate from NTP. | 878 // Set the text and press enter to navigate from NTP. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 805 | 892 |
| 806 // Verify that onmostvisitedchange event is dispatched when we navigate from | 893 // Verify that onmostvisitedchange event is dispatched when we navigate from |
| 807 // SRP to NTP. | 894 // SRP to NTP. |
| 808 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 895 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 809 EXPECT_TRUE(UpdateSearchState(active_tab)); | 896 EXPECT_TRUE(UpdateSearchState(active_tab)); |
| 810 EXPECT_EQ(1, on_most_visited_change_calls_); | 897 EXPECT_EQ(1, on_most_visited_change_calls_); |
| 811 } | 898 } |
| 812 | 899 |
| 813 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) { | 900 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) { |
| 814 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 901 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 815 FocusOmnibox(); | 902 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 816 | 903 |
| 817 content::WindowedNotificationObserver new_tab_observer( | 904 content::WindowedNotificationObserver new_tab_observer( |
| 818 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 905 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 819 content::NotificationService::AllSources()); | 906 content::NotificationService::AllSources()); |
| 820 ui_test_utils::NavigateToURLWithDisposition( | 907 ui_test_utils::NavigateToURLWithDisposition( |
| 821 browser(), | 908 browser(), |
| 822 GURL(chrome::kChromeUINewTabURL), | 909 GURL(chrome::kChromeUINewTabURL), |
| 823 CURRENT_TAB, | 910 CURRENT_TAB, |
| 824 ui_test_utils::BROWSER_TEST_NONE); | 911 ui_test_utils::BROWSER_TEST_NONE); |
| 825 new_tab_observer.Wait(); | 912 new_tab_observer.Wait(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 content::WebContents* active_tab = | 952 content::WebContents* active_tab = |
| 866 browser()->tab_strip_model()->GetActiveWebContents(); | 953 browser()->tab_strip_model()->GetActiveWebContents(); |
| 867 ASSERT_TRUE(UpdateSearchState(active_tab)); | 954 ASSERT_TRUE(UpdateSearchState(active_tab)); |
| 868 ASSERT_TRUE(SearchProvider::ShouldPrefetch(*( | 955 ASSERT_TRUE(SearchProvider::ShouldPrefetch(*( |
| 869 omnibox()->model()->result().default_match()))); | 956 omnibox()->model()->result().default_match()))); |
| 870 ASSERT_EQ("puppy", prefetch_query_value_); | 957 ASSERT_EQ("puppy", prefetch_query_value_); |
| 871 } | 958 } |
| 872 | 959 |
| 873 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, ClearPrefetchedResults) { | 960 IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, ClearPrefetchedResults) { |
| 874 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 961 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 875 FocusOmnibox(); | 962 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 876 | 963 |
| 877 content::WindowedNotificationObserver new_tab_observer( | 964 content::WindowedNotificationObserver new_tab_observer( |
| 878 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 965 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 879 content::NotificationService::AllSources()); | 966 content::NotificationService::AllSources()); |
| 880 ui_test_utils::NavigateToURLWithDisposition( | 967 ui_test_utils::NavigateToURLWithDisposition( |
| 881 browser(), | 968 browser(), |
| 882 GURL(chrome::kChromeUINewTabURL), | 969 GURL(chrome::kChromeUINewTabURL), |
| 883 CURRENT_TAB, | 970 CURRENT_TAB, |
| 884 ui_test_utils::BROWSER_TEST_NONE); | 971 ui_test_utils::BROWSER_TEST_NONE); |
| 885 new_tab_observer.Wait(); | 972 new_tab_observer.Wait(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 // the search terms is sufficient. | 1044 // the search terms is sufficient. |
| 958 EXPECT_NE(ASCIIToUTF16("foo"), omnibox()->GetText()); | 1045 EXPECT_NE(ASCIIToUTF16("foo"), omnibox()->GetText()); |
| 959 } | 1046 } |
| 960 | 1047 |
| 961 // Check that clicking on a result sends the correct referrer. | 1048 // Check that clicking on a result sends the correct referrer. |
| 962 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, Referrer) { | 1049 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, Referrer) { |
| 963 ASSERT_TRUE(test_server()->Start()); | 1050 ASSERT_TRUE(test_server()->Start()); |
| 964 GURL result_url = | 1051 GURL result_url = |
| 965 test_server()->GetURL("files/referrer_policy/referrer-policy-log.html"); | 1052 test_server()->GetURL("files/referrer_policy/referrer-policy-log.html"); |
| 966 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1053 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 967 FocusOmnibox(); | 1054 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 968 | 1055 |
| 969 // Type a query and press enter to get results. | 1056 // Type a query and press enter to get results. |
| 970 SetOmniboxText("query"); | 1057 SetOmniboxText("query"); |
| 971 PressEnterAndWaitForNavigation(); | 1058 PressEnterAndWaitForNavigation(); |
| 972 | 1059 |
| 973 // Simulate going to a result. | 1060 // Simulate going to a result. |
| 974 content::WebContents* contents = | 1061 content::WebContents* contents = |
| 975 browser()->tab_strip_model()->GetActiveWebContents(); | 1062 browser()->tab_strip_model()->GetActiveWebContents(); |
| 976 std::ostringstream stream; | 1063 std::ostringstream stream; |
| 977 stream << "var link = document.createElement('a');"; | 1064 stream << "var link = document.createElement('a');"; |
| 978 stream << "link.href = \"" << result_url.spec() << "\";"; | 1065 stream << "link.href = \"" << result_url.spec() << "\";"; |
| 979 stream << "document.body.appendChild(link);"; | 1066 stream << "document.body.appendChild(link);"; |
| 980 stream << "link.click();"; | 1067 stream << "link.click();"; |
| 981 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); | 1068 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); |
| 982 | 1069 |
| 983 content::WaitForLoadStop(contents); | 1070 content::WaitForLoadStop(contents); |
| 984 std::string expected_title = | 1071 std::string expected_title = |
| 985 "Referrer is " + instant_url().GetWithEmptyPath().spec(); | 1072 "Referrer is " + instant_url().GetWithEmptyPath().spec(); |
| 986 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); | 1073 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); |
| 987 } | 1074 } |
| OLD | NEW |