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

Unified Diff: chrome/browser/extensions/extension_browsertest.cc

Issue 11117011: Keep browser process alive while there are platform apps with background pages running. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Delegated Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_browsertest.cc
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index b3248cdfc5b1f9bf471e8788b8c2dad27f028277..009867ecdc2aad9875a5e65fb7d345df8c69f526 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -23,10 +23,12 @@
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/extensions/shell_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_notification_types.h"
@@ -44,6 +46,7 @@
using extensions::Extension;
using extensions::ExtensionCreator;
+using extensions::ShellWindowRegistry;
ExtensionBrowserTest::ExtensionBrowserTest()
: loaded_(false),
@@ -73,6 +76,10 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) {
command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
command_line->AppendSwitch(switches::kNoFirstRun);
#endif
+
+ // Make event pages get suspended quicker.
+ command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
+ command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1");
}
const Extension* ExtensionBrowserTest::LoadExtensionWithFlags(
@@ -533,6 +540,30 @@ bool ExtensionBrowserTest::WaitForCrxInstallerDone() {
return crx_installers_done_observed_ == (before + 1);
}
+void ExtensionBrowserTest::CloseShellWindow(ShellWindow* window) {
+ content::WindowedNotificationObserver destroyed_observer(
+ content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ content::NotificationService::AllSources());
+ window->GetBaseWindow()->Close();
+ destroyed_observer.Wait();
+}
+
+void ExtensionBrowserTest::CloseShellWindowsAndWaitForAppToExit() {
+ content::WindowedNotificationObserver destroyed_observer(
+ chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
+ content::NotificationService::AllSources());
+
+ ShellWindowRegistry* app_registry =
+ ShellWindowRegistry::Get(browser()->profile());
+ ShellWindowRegistry::const_iterator iter;
+ ShellWindowRegistry::ShellWindowSet shell_windows =
+ app_registry->shell_windows();
+ for (iter = shell_windows.begin(); iter != shell_windows.end(); ++iter)
+ CloseShellWindow(*iter);
+
+ destroyed_observer.Wait();
Yoyo Zhou 2012/10/30 01:35:22 This looks like it's only going to wait for 1 shel
benwells 2012/10/30 02:55:23 It's waiting for the background page to exit. I'll
+}
+
void ExtensionBrowserTest::OpenWindow(content::WebContents* contents,
const GURL& url,
bool newtab_process_should_equal_opener,

Powered by Google App Engine
This is Rietveld 408576698