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

Side by Side Diff: chrome/browser/content_settings/content_settings_browsertest.cc

Issue 1228723002: Extract duplicated code in browser_tests for closing a browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/WithoutWaiting/Asynchronously Created 5 years, 5 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
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/path_service.h" 6 #include "base/path_service.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/content_settings/cookie_settings_factory.h" 10 #include "chrome/browser/content_settings/cookie_settings_factory.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 Browser* incognito = CreateIncognitoBrowser(); 67 Browser* incognito = CreateIncognitoBrowser();
68 ASSERT_TRUE(content::GetCookies(incognito->profile(), url).empty()); 68 ASSERT_TRUE(content::GetCookies(incognito->profile(), url).empty());
69 ui_test_utils::NavigateToURL(incognito, url); 69 ui_test_utils::NavigateToURL(incognito, url);
70 ASSERT_EQ(cookies_enabled, 70 ASSERT_EQ(cookies_enabled,
71 !content::GetCookies(incognito->profile(), url).empty()); 71 !content::GetCookies(incognito->profile(), url).empty());
72 72
73 // Ensure incognito cookies don't leak to regular profile. 73 // Ensure incognito cookies don't leak to regular profile.
74 ASSERT_TRUE(content::GetCookies(browser()->profile(), url).empty()); 74 ASSERT_TRUE(content::GetCookies(browser()->profile(), url).empty());
75 75
76 // Ensure cookies get wiped after last incognito window closes. 76 // Ensure cookies get wiped after last incognito window closes.
77 content::WindowedNotificationObserver signal( 77 CloseBrowserSynchronously(incognito);
78 chrome::NOTIFICATION_BROWSER_CLOSED,
79 content::Source<Browser>(incognito));
80
81 chrome::CloseWindow(incognito);
82
83 #if defined(OS_MACOSX)
84 // BrowserWindowController depends on the auto release pool being recycled
85 // in the message loop to delete itself, which frees the Browser object
86 // which fires this event.
87 AutoreleasePool()->Recycle();
88 #endif
89
90 signal.Wait();
91 78
92 incognito = CreateIncognitoBrowser(); 79 incognito = CreateIncognitoBrowser();
93 ASSERT_TRUE(content::GetCookies(incognito->profile(), url).empty()); 80 ASSERT_TRUE(content::GetCookies(incognito->profile(), url).empty());
94 chrome::CloseWindow(incognito); 81 CloseBrowserSynchronously(incognito);
95 } 82 }
96 83
97 void PreBasic(const GURL& url) { 84 void PreBasic(const GURL& url) {
98 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty()); 85 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
99 86
100 CookieCheckIncognitoWindow(url, true); 87 CookieCheckIncognitoWindow(url, true);
101 88
102 ui_test_utils::NavigateToURL(browser(), url); 89 ui_test_utils::NavigateToURL(browser(), url);
103 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty()); 90 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
104 } 91 }
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 546 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
560 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 547 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
561 switches::kAshBrowserTests)) 548 switches::kAshBrowserTests))
562 return; 549 return;
563 #endif 550 #endif
564 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); 551 RunJavaScriptBlockedTest("load_nacl_no_js.html", true);
565 } 552 }
566 #endif // !defined(DISABLE_NACL) 553 #endif // !defined(DISABLE_NACL)
567 554
568 #endif // defined(ENABLE_PLUGINS) 555 #endif // defined(ENABLE_PLUGINS)
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac_browsertest.mm ('k') | chrome/browser/extensions/app_background_page_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698