Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc

Issue 2495053003: Wait for history backend in popup blocker test (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/scoped_feature_list.h" 13 #include "base/test/scoped_feature_list.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
17 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 17 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
18 #include "chrome/browser/history/history_test_utils.h"
18 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/search_engines/template_url_service_factory.h" 20 #include "chrome/browser/search_engines/template_url_service_factory.h"
20 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" 21 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
23 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
25 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" 26 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h"
26 #include "chrome/browser/ui/location_bar/location_bar.h" 27 #include "chrome/browser/ui/location_bar/location_bar.h"
27 #include "chrome/browser/ui/login/login_handler.h" 28 #include "chrome/browser/ui/login/login_handler.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 switches::kDisablePopupBlocking); 331 switches::kDisablePopupBlocking);
331 GURL url( 332 GURL url(
332 embedded_test_server()->GetURL("/popup_blocker/popup-on-unload.html")); 333 embedded_test_server()->GetURL("/popup_blocker/popup-on-unload.html"));
333 ui_test_utils::NavigateToURL(browser(), url); 334 ui_test_utils::NavigateToURL(browser(), url);
334 335
335 NavigateAndCheckPopupShown(embedded_test_server()->GetURL("/popup_blocker/"), 336 NavigateAndCheckPopupShown(embedded_test_server()->GetURL("/popup_blocker/"),
336 ExpectPopup); 337 ExpectPopup);
337 } 338 }
338 339
339 // Verify that when you unblock popup, the popup shows in history and omnibox. 340 // Verify that when you unblock popup, the popup shows in history and omnibox.
340 // TODO(crbug.com/663333) Flaky on Linux.
341 #if defined(OS_LINUX)
342 #define MAYBE_UnblockedPopupShowsInHistoryAndOmnibox \
343 DISABLED_UnblockedPopupShowsInHistoryAndOmnibox
344 #else
345 #define MAYBE_UnblockedPopupShowsInHistoryAndOmnibox \
346 UnblockedPopupShowsInHistoryAndOmnibox
347 #endif
348 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, 341 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
349 MAYBE_UnblockedPopupShowsInHistoryAndOmnibox) { 342 UnblockedPopupShowsInHistoryAndOmnibox) {
350 base::CommandLine::ForCurrentProcess()->AppendSwitch( 343 base::CommandLine::ForCurrentProcess()->AppendSwitch(
351 switches::kDisablePopupBlocking); 344 switches::kDisablePopupBlocking);
352 GURL url(embedded_test_server()->GetURL( 345 GURL url(embedded_test_server()->GetURL(
353 "/popup_blocker/popup-blocked-to-post-blank.html")); 346 "/popup_blocker/popup-blocked-to-post-blank.html"));
354 NavigateAndCheckPopupShown(url, ExpectTab); 347 NavigateAndCheckPopupShown(url, ExpectTab);
355 348
356 std::string search_string = 349 std::string search_string =
357 "data:text/html,<title>Popup Success!</title>you should not see this " 350 "data:text/html,<title>Popup Success!</title>you should not see this "
358 "message if popup blocker is enabled"; 351 "message if popup blocker is enabled";
359 352
353 WaitForHistoryBackendToRun(browser()->profile());
360 ui_test_utils::HistoryEnumerator history(browser()->profile()); 354 ui_test_utils::HistoryEnumerator history(browser()->profile());
361 std::vector<GURL>& history_urls = history.urls(); 355 std::vector<GURL>& history_urls = history.urls();
362 ASSERT_EQ(2u, history_urls.size()); 356 ASSERT_EQ(2u, history_urls.size());
363 ASSERT_EQ(GURL(search_string), history_urls[0]); 357 ASSERT_EQ(GURL(search_string), history_urls[0]);
364 ASSERT_EQ(url, history_urls[1]); 358 ASSERT_EQ(url, history_urls[1]);
365 359
366 TemplateURLService* service = TemplateURLServiceFactory::GetForProfile( 360 TemplateURLService* service = TemplateURLServiceFactory::GetForProfile(
367 browser()->profile()); 361 browser()->profile());
368 search_test_utils::WaitForTemplateURLServiceToLoad(service); 362 search_test_utils::WaitForTemplateURLServiceToLoad(service);
369 LocationBar* location_bar = browser()->window()->GetLocationBar(); 363 LocationBar* location_bar = browser()->window()->GetLocationBar();
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 701
708 wait_for_new_tab.Wait(); 702 wait_for_new_tab.Wait();
709 703
710 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); 704 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile()));
711 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 705 ASSERT_EQ(2, browser()->tab_strip_model()->count());
712 // Check that we create the background tab. 706 // Check that we create the background tab.
713 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); 707 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
714 } 708 }
715 709
716 } // namespace 710 } // namespace
OLDNEW
« chrome/browser/history/history_test_utils.cc ('K') | « chrome/browser/history/history_test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698