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

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

Issue 10948027: [Panels] Fix browser crash when killing extension on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/ui/panels/panel_view.h » ('j') | chrome/browser/ui/panels/panel_view.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/window_open_apitest.cc
diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc
index a476c10c02fae0ea493ec2905c18433df8e17059..a8f6b747c44864e75f317422e9f3f8de4b340c3d 100644
--- a/chrome/browser/extensions/window_open_apitest.cc
+++ b/chrome/browser/extensions/window_open_apitest.cc
@@ -6,6 +6,8 @@
#include "base/memory/scoped_vector.h"
#include "base/stringprintf.h"
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/extensions/extension_host.h"
+#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -15,7 +17,9 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/result_codes.h"
#include "content/public/test/browser_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "net/base/mock_host_resolver.h"
@@ -282,6 +286,57 @@ IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest,
WaitForTabsAndPopups(browser(), 1, num_popups, 0);
}
+IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, ClosePanelsOnExtensionCrash) {
+#if defined(USE_ASH)
+ // On Ash, new panel windows open as popup windows instead.
+ int num_popups = 4;
+ int num_panels = 0;
+#else
+ int num_popups = 2;
+ int num_panels = 2;
+#endif
+ ASSERT_TRUE(StartTestServer());
+
+ // Setup listeners to wait on strings we expect the extension pages to send.
+ std::vector<std::string> test_strings;
+ test_strings.push_back("content_tab");
+ if (num_panels)
+ test_strings.push_back("content_panel");
+ test_strings.push_back("content_popup");
+
+ ScopedVector<ExtensionTestMessageListener> listeners;
+ for (size_t i = 0; i < test_strings.size(); ++i) {
+ listeners.push_back(
+ new ExtensionTestMessageListener(test_strings[i], false));
+ }
+
+ const extensions::Extension* extension = LoadExtension(
+ test_data_dir_.AppendASCII("window_open").AppendASCII(
+ "close_panels_on_uninstall"));
+ ASSERT_TRUE(extension);
+
+ // Two tabs. One in extension domain and one in non-extension domain.
+ // Two popups - one in extension domain and one in non-extension domain.
+ // Two panels - one in extension domain and one in non-extension domain.
+ WaitForTabsAndPopups(browser(), 2, num_popups, num_panels);
+
+ // Wait on test messages to make sure the pages loaded.
+ for (size_t i = 0; i < listeners.size(); ++i)
+ ASSERT_TRUE(listeners[i]->WaitUntilSatisfied());
+
+ // Crash the extension.
+ extensions::ExtensionHost* extension_host =
+ browser()->profile()->GetExtensionProcessManager()->
+ GetBackgroundHostForExtension(extension->id());
+ ASSERT_TRUE(extension_host);
+ base::KillProcess(extension_host->render_process_host()->GetHandle(),
+ content::RESULT_CODE_KILLED, false);
+ WaitForExtensionCrash(extension->id());
+
+ // Only expect panels to close. The rest stay open to show a sad-tab.
+ WaitForTabsAndPopups(browser(), 2, num_popups, 0);
+}
+
#if defined(USE_ASH)
// This test is not applicable on Ash. Ash opens panel windows as popup
// windows. The modified window.open behavior only applies to panel windows.
« no previous file with comments | « no previous file | chrome/browser/ui/panels/panel_view.h » ('j') | chrome/browser/ui/panels/panel_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698