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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 GURL GetTestURL() { 48 GURL GetTestURL() {
49 return ui_test_utils::GetTestUrl( 49 return ui_test_utils::GetTestUrl(
50 base::FilePath(kTestDir), 50 base::FilePath(kTestDir),
51 base::FilePath(FILE_PATH_LITERAL("popup-blocked-to-post-blank.html"))); 51 base::FilePath(FILE_PATH_LITERAL("popup-blocked-to-post-blank.html")));
52 } 52 }
53 53
54 std::vector<WebContents*> GetBlockedContents(Browser* browser) { 54 std::vector<WebContents*> GetBlockedContents(Browser* browser) {
55 // Do a round trip to the renderer first to flush any in-flight IPCs to 55 // Do a round trip to the renderer first to flush any in-flight IPCs to
56 // create a to-be-blocked window. 56 // create a to-be-blocked window.
57 WebContents* tab = browser->tab_strip_model()->GetActiveWebContents(); 57 WebContents* tab = browser->tab_strip_model()->GetActiveWebContents();
58 CHECK(content::ExecuteScript(tab, "")); 58 CHECK(content::ExecuteScript(tab, std::string()));
59 BlockedContentTabHelper* blocked_content_tab_helper = 59 BlockedContentTabHelper* blocked_content_tab_helper =
60 BlockedContentTabHelper::FromWebContents(tab); 60 BlockedContentTabHelper::FromWebContents(tab);
61 std::vector<WebContents*> blocked_contents; 61 std::vector<WebContents*> blocked_contents;
62 blocked_content_tab_helper->GetBlockedContents(&blocked_contents); 62 blocked_content_tab_helper->GetBlockedContents(&blocked_contents);
63 return blocked_contents; 63 return blocked_contents;
64 } 64 }
65 65
66 void NavigateAndCheckPopupShown(Browser* browser, const GURL& url) { 66 void NavigateAndCheckPopupShown(Browser* browser, const GURL& url) {
67 content::WindowedNotificationObserver observer( 67 content::WindowedNotificationObserver observer(
68 chrome::NOTIFICATION_TAB_ADDED, 68 chrome::NOTIFICATION_TAB_ADDED,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 kTestDir), base::FilePath(FILE_PATH_LITERAL("popup-many.html")))); 120 kTestDir), base::FilePath(FILE_PATH_LITERAL("popup-many.html"))));
121 ui_test_utils::NavigateToURL(browser(), url); 121 ui_test_utils::NavigateToURL(browser(), url);
122 std::vector<WebContents*> blocked_contents = GetBlockedContents(browser()); 122 std::vector<WebContents*> blocked_contents = GetBlockedContents(browser());
123 ASSERT_EQ(2u, blocked_contents.size()); 123 ASSERT_EQ(2u, blocked_contents.size());
124 } 124 }
125 125
126 // Verify that popups are launched on browser back button. 126 // Verify that popups are launched on browser back button.
127 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, 127 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
128 AllowPopupThroughContentSetting) { 128 AllowPopupThroughContentSetting) {
129 GURL url(GetTestURL()); 129 GURL url(GetTestURL());
130 browser()->profile()->GetHostContentSettingsMap()->SetContentSetting( 130 browser()->profile()->GetHostContentSettingsMap()
131 ContentSettingsPattern::FromURL(url), 131 ->SetContentSetting(ContentSettingsPattern::FromURL(url),
132 ContentSettingsPattern::Wildcard(), 132 ContentSettingsPattern::Wildcard(),
133 CONTENT_SETTINGS_TYPE_POPUPS, 133 CONTENT_SETTINGS_TYPE_POPUPS,
134 "", 134 std::string(),
135 CONTENT_SETTING_ALLOW); 135 CONTENT_SETTING_ALLOW);
136 136
137 NavigateAndCheckPopupShown(browser(), url); 137 NavigateAndCheckPopupShown(browser(), url);
138 } 138 }
139 139
140 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, PopupsLaunchWhenTabIsClosed) { 140 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, PopupsLaunchWhenTabIsClosed) {
141 CommandLine::ForCurrentProcess()->AppendSwitch( 141 CommandLine::ForCurrentProcess()->AppendSwitch(
142 switches::kDisablePopupBlocking); 142 switches::kDisablePopupBlocking);
143 GURL url = ui_test_utils::GetTestUrl( 143 GURL url = ui_test_utils::GetTestUrl(
144 base::FilePath(kTestDir), 144 base::FilePath(kTestDir),
145 base::FilePath(FILE_PATH_LITERAL("popup-on-unload.html"))); 145 base::FilePath(FILE_PATH_LITERAL("popup-on-unload.html")));
(...skipping 24 matching lines...) Expand all
170 browser()->profile()); 170 browser()->profile());
171 ui_test_utils::WaitForTemplateURLServiceToLoad(service); 171 ui_test_utils::WaitForTemplateURLServiceToLoad(service);
172 LocationBar* location_bar = browser()->window()->GetLocationBar(); 172 LocationBar* location_bar = browser()->window()->GetLocationBar();
173 ui_test_utils::SendToOmniboxAndSubmit(location_bar, search_string); 173 ui_test_utils::SendToOmniboxAndSubmit(location_bar, search_string);
174 OmniboxEditModel* model = location_bar->GetLocationEntry()->model(); 174 OmniboxEditModel* model = location_bar->GetLocationEntry()->model();
175 EXPECT_EQ(GURL(search_string), model->CurrentMatch().destination_url); 175 EXPECT_EQ(GURL(search_string), model->CurrentMatch().destination_url);
176 EXPECT_EQ(ASCIIToUTF16(search_string), model->CurrentMatch().contents); 176 EXPECT_EQ(ASCIIToUTF16(search_string), model->CurrentMatch().contents);
177 } 177 }
178 178
179 } // namespace 179 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/policy/url_blacklist_manager_unittest.cc ('k') | chrome/browser/predictors/autocomplete_action_predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698