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

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

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 259 }
260 260
261 private: 261 private:
262 DISALLOW_COPY_AND_ASSIGN(PopupBlockerBrowserTest); 262 DISALLOW_COPY_AND_ASSIGN(PopupBlockerBrowserTest);
263 }; 263 };
264 264
265 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, 265 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
266 BlockWebContentsCreation) { 266 BlockWebContentsCreation) {
267 #if defined(OS_WIN) && defined(USE_ASH) 267 #if defined(OS_WIN) && defined(USE_ASH)
268 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 268 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
269 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 269 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
270 switches::kAshBrowserTests))
270 return; 271 return;
271 #endif 272 #endif
272 273
273 RunCheckTest( 274 RunCheckTest(
274 browser(), 275 browser(),
275 "/popup_blocker/popup-blocked-to-post-blank.html", 276 "/popup_blocker/popup-blocked-to-post-blank.html",
276 ExpectTab, 277 ExpectTab,
277 DontCheckTitle); 278 DontCheckTitle);
278 } 279 }
279 280
280 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, 281 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
281 BlockWebContentsCreationIncognito) { 282 BlockWebContentsCreationIncognito) {
282 #if defined(OS_WIN) && defined(USE_ASH) 283 #if defined(OS_WIN) && defined(USE_ASH)
283 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 284 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
284 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 285 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
286 switches::kAshBrowserTests))
285 return; 287 return;
286 #endif 288 #endif
287 289
288 RunCheckTest( 290 RunCheckTest(
289 CreateIncognitoBrowser(), 291 CreateIncognitoBrowser(),
290 "/popup_blocker/popup-blocked-to-post-blank.html", 292 "/popup_blocker/popup-blocked-to-post-blank.html",
291 ExpectTab, 293 ExpectTab,
292 DontCheckTitle); 294 DontCheckTitle);
293 } 295 }
294 296
295 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, 297 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
296 PopupBlockedFakeClickOnAnchor) { 298 PopupBlockedFakeClickOnAnchor) {
297 #if defined(OS_WIN) && defined(USE_ASH) 299 #if defined(OS_WIN) && defined(USE_ASH)
298 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 300 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
299 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 301 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
302 switches::kAshBrowserTests))
300 return; 303 return;
301 #endif 304 #endif
302 305
303 RunCheckTest( 306 RunCheckTest(
304 browser(), 307 browser(),
305 "/popup_blocker/popup-fake-click-on-anchor.html", 308 "/popup_blocker/popup-fake-click-on-anchor.html",
306 ExpectTab, 309 ExpectTab,
307 DontCheckTitle); 310 DontCheckTitle);
308 } 311 }
309 312
310 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, 313 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
311 PopupBlockedFakeClickOnAnchorNoTarget) { 314 PopupBlockedFakeClickOnAnchorNoTarget) {
312 #if defined(OS_WIN) && defined(USE_ASH) 315 #if defined(OS_WIN) && defined(USE_ASH)
313 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 316 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
314 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 317 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
318 switches::kAshBrowserTests))
315 return; 319 return;
316 #endif 320 #endif
317 321
318 RunCheckTest( 322 RunCheckTest(
319 browser(), 323 browser(),
320 "/popup_blocker/popup-fake-click-on-anchor2.html", 324 "/popup_blocker/popup-fake-click-on-anchor2.html",
321 ExpectTab, 325 ExpectTab,
322 DontCheckTitle); 326 DontCheckTitle);
323 } 327 }
324 328
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 std::string(), 378 std::string(),
375 CONTENT_SETTING_ALLOW); 379 CONTENT_SETTING_ALLOW);
376 380
377 // Popup should be blocked. 381 // Popup should be blocked.
378 ui_test_utils::NavigateToURL(browser(), url); 382 ui_test_utils::NavigateToURL(browser(), url);
379 ASSERT_EQ(1, GetBlockedContentsCount()); 383 ASSERT_EQ(1, GetBlockedContentsCount());
380 } 384 }
381 385
382 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, 386 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
383 PopupsLaunchWhenTabIsClosed) { 387 PopupsLaunchWhenTabIsClosed) {
384 CommandLine::ForCurrentProcess()->AppendSwitch( 388 base::CommandLine::ForCurrentProcess()->AppendSwitch(
385 switches::kDisablePopupBlocking); 389 switches::kDisablePopupBlocking);
386 GURL url( 390 GURL url(
387 embedded_test_server()->GetURL("/popup_blocker/popup-on-unload.html")); 391 embedded_test_server()->GetURL("/popup_blocker/popup-on-unload.html"));
388 ui_test_utils::NavigateToURL(browser(), url); 392 ui_test_utils::NavigateToURL(browser(), url);
389 393
390 NavigateAndCheckPopupShown(embedded_test_server()->GetURL("/popup_blocker/"), 394 NavigateAndCheckPopupShown(embedded_test_server()->GetURL("/popup_blocker/"),
391 ExpectPopup); 395 ExpectPopup);
392 } 396 }
393 397
394 // Verify that when you unblock popup, the popup shows in history and omnibox. 398 // Verify that when you unblock popup, the popup shows in history and omnibox.
395 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, 399 IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
396 UnblockedPopupShowsInHistoryAndOmnibox) { 400 UnblockedPopupShowsInHistoryAndOmnibox) {
397 CommandLine::ForCurrentProcess()->AppendSwitch( 401 base::CommandLine::ForCurrentProcess()->AppendSwitch(
398 switches::kDisablePopupBlocking); 402 switches::kDisablePopupBlocking);
399 GURL url(embedded_test_server()->GetURL( 403 GURL url(embedded_test_server()->GetURL(
400 "/popup_blocker/popup-blocked-to-post-blank.html")); 404 "/popup_blocker/popup-blocked-to-post-blank.html"));
401 NavigateAndCheckPopupShown(url, ExpectTab); 405 NavigateAndCheckPopupShown(url, ExpectTab);
402 406
403 std::string search_string = 407 std::string search_string =
404 "data:text/html,<title>Popup Success!</title>you should not see this " 408 "data:text/html,<title>Popup Success!</title>you should not see this "
405 "message if popup blocker is enabled"; 409 "message if popup blocker is enabled";
406 410
407 ui_test_utils::HistoryEnumerator history(browser()->profile()); 411 ui_test_utils::HistoryEnumerator history(browser()->profile());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 583
580 if (popup_browser != chrome::FindLastActiveWithHostDesktopType( 584 if (popup_browser != chrome::FindLastActiveWithHostDesktopType(
581 popup_browser->host_desktop_type())) { 585 popup_browser->host_desktop_type())) {
582 activation_observer.WaitForActivation(); 586 activation_observer.WaitForActivation();
583 } 587 }
584 ASSERT_EQ(popup_browser, chrome::FindLastActiveWithHostDesktopType( 588 ASSERT_EQ(popup_browser, chrome::FindLastActiveWithHostDesktopType(
585 popup_browser->host_desktop_type())); 589 popup_browser->host_desktop_type()));
586 } 590 }
587 591
588 } // namespace 592 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698