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