Chromium Code Reviews| Index: chrome/test/base/in_process_browser_test.cc |
| diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc |
| index 027e905caa123dab2e6f3c20437ef54b402fb2bf..fc5af62cc152355036defc71273ad047a992a802 100644 |
| --- a/chrome/test/base/in_process_browser_test.cc |
| +++ b/chrome/test/base/in_process_browser_test.cc |
| @@ -20,6 +20,7 @@ |
| #include "base/threading/non_thread_safe.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/devtools/devtools_window.h" |
| #include "chrome/browser/lifetime/application_lifetime.h" |
| #include "chrome/browser/net/net_error_tab_helper.h" |
| #include "chrome/browser/profiles/profile.h" |
| @@ -43,8 +44,10 @@ |
| #include "chrome/test/base/test_launcher_utils.h" |
| #include "chrome/test/base/test_switches.h" |
| #include "chrome/test/base/testing_browser_process.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| #include "components/google/core/browser/google_util.h" |
| #include "components/os_crypt/os_crypt.h" |
| +#include "content/public/browser/devtools_agent_host.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_types.h" |
| #include "content/public/test/browser_test_utils.h" |
| @@ -409,6 +412,28 @@ void InProcessBrowserTest::CloseAllBrowsers() { |
| #endif |
| } |
| +void InProcessBrowserTest::OpenDevToolsWindow( |
| + content::WebContents* web_contents) { |
| +#if defined(OS_MACOSX) |
| + // Opening a Devtools Window can cause AppKit to throw objects into the |
| + // autorelease pool. Flush the pool when this function returns. |
| + base::mac::ScopedNSAutoreleasePool pool; |
| +#endif // OS_MACOSX |
| + ASSERT_FALSE(content::DevToolsAgentHost::HasFor(web_contents)); |
| + DevToolsWindow::OpenDevToolsWindow(web_contents); |
| + ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents)); |
| +} |
| + |
| +Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile, |
| + const GURL& url) { |
| +#if defined(OS_MACOSX) |
| + // Opening an incognito window can cause AppKit to throw objects into the |
| + // autorelease pool. Flush the pool when this function returns. |
| + base::mac::ScopedNSAutoreleasePool pool; |
| +#endif |
| + return ui_test_utils::OpenURLOffTheRecord(profile, url); |
|
Robert Sesek
2015/07/09 15:11:46
For this case, how will callers know to choose the
erikchen
2015/07/10 00:14:41
I removed the UTU version and migrated all calls t
|
| +} |
| + |
| // TODO(alexmos): This function should expose success of the underlying |
| // navigation to tests, which should make sure navigations succeed when |
| // appropriate. See https://crbug.com/425335 |
| @@ -443,6 +468,11 @@ bool InProcessBrowserTest::SetUpUserDataDirectory() { |
| // Creates a browser with a single tab (about:blank), waits for the tab to |
| // finish loading and shows the browser. |
| Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { |
| +#if defined(OS_MACOSX) |
| + // Making a browser window can cause AppKit to throw objects into the |
| + // autorelease pool. Flush the pool when this function returns. |
| + base::mac::ScopedNSAutoreleasePool pool; |
| +#endif |
| Browser* browser = new Browser( |
| Browser::CreateParams(profile, chrome::GetActiveDesktop())); |
| AddBlankTabAndShow(browser); |
| @@ -450,6 +480,11 @@ Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) { |
| } |
| Browser* InProcessBrowserTest::CreateIncognitoBrowser() { |
| +#if defined(OS_MACOSX) |
| + // Making a browser window can cause AppKit to throw objects into the |
| + // autorelease pool. Flush the pool when this function returns. |
| + base::mac::ScopedNSAutoreleasePool pool; |
| +#endif |
| // Create a new browser with using the incognito profile. |
| Browser* incognito = new Browser( |
| Browser::CreateParams(browser()->profile()->GetOffTheRecordProfile(), |
| @@ -459,6 +494,11 @@ Browser* InProcessBrowserTest::CreateIncognitoBrowser() { |
| } |
| Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) { |
| +#if defined(OS_MACOSX) |
| + // Making a browser window can cause AppKit to throw objects into the |
| + // autorelease pool. Flush the pool when this function returns. |
| + base::mac::ScopedNSAutoreleasePool pool; |
| +#endif |
| Browser* browser = |
| new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile, |
| chrome::GetActiveDesktop())); |
| @@ -469,6 +509,11 @@ Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) { |
| Browser* InProcessBrowserTest::CreateBrowserForApp( |
| const std::string& app_name, |
| Profile* profile) { |
| +#if defined(OS_MACOSX) |
| + // Making a browser window can cause AppKit to throw objects into the |
| + // autorelease pool. Flush the pool when this function returns. |
| + base::mac::ScopedNSAutoreleasePool pool; |
| +#endif |
| Browser* browser = new Browser( |
| Browser::CreateParams::CreateForApp( |
| app_name, false /* trusted_source */, gfx::Rect(), profile, |