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

Unified Diff: chrome/browser/ui/panels/panel_browsertest.cc

Issue 8387010: Close all panels originated by the extension when extension unloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build errors from sync and merge. Created 9 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
« chrome/browser/ui/browser.cc ('K') | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_browsertest.cc
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index 379527770f19c13fea93e27e28efc24c36024723..b8681c7dea9252aa9665b90e65d5a3cb0f3893d8 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -21,10 +21,12 @@
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/download/download_manager.h"
#include "content/browser/net/url_request_mock_http_job.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/common/url_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -1313,6 +1315,59 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
panel2->Close();
}
+IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
+ NonExtensionDomainPanelsCloseOnUninstall) {
+ // Create a test extension.
+ DictionaryValue empty_value;
+ scoped_refptr<Extension> extension =
+ CreateExtension(FILE_PATH_LITERAL("TestExtension"),
+ Extension::INVALID, empty_value);
+ std::string extension_app_name =
+ web_app::GenerateApplicationNameFromExtensionId(extension->id());
+
+ PanelManager* panel_manager = PanelManager::GetInstance();
+ EXPECT_EQ(0, panel_manager->num_panels());
+
+ // Create a panel with the extension as host.
+ CreatePanelParams params(extension_app_name, gfx::Rect(), SHOW_AS_INACTIVE);
+ std::string extension_domain_url(chrome::kExtensionScheme);
+ extension_domain_url += "://";
+ extension_domain_url += extension->id();
+ extension_domain_url += "/hello.html";
+ params.url = GURL(extension_domain_url);
+ CreatePanelWithParams(params);
+ EXPECT_EQ(1, panel_manager->num_panels());
+
+ // Create a panel with a non-extension host.
+ CreatePanelParams params1(extension_app_name, gfx::Rect(), SHOW_AS_INACTIVE);
+ params1.url = GURL(chrome::kAboutBlankURL);
+ CreatePanelWithParams(params1);
+ EXPECT_EQ(2, panel_manager->num_panels());
+
+ // Create another extension and a panel from that extension.
+ scoped_refptr<Extension> extension_other =
+ CreateExtension(FILE_PATH_LITERAL("TestExtensionOther"),
+ Extension::INVALID, empty_value);
+ std::string extension_app_name_other =
+ web_app::GenerateApplicationNameFromExtensionId(extension_other->id());
+ Panel* panel_other = CreatePanel(extension_app_name_other);
+
+ // Send unload notification on the first extension and wait for count of
+ // panels to go down to 1.
+ UnloadedExtensionInfo details(extension,
+ extension_misc::UNLOAD_REASON_UNINSTALL);
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_EXTENSION_UNLOADED,
+ content::Source<Profile>(browser()->profile()),
+ content::Details<UnloadedExtensionInfo>(&details));
+ while (panel_manager->num_panels() != 1)
+ MessageLoopForUI::current()->RunAllPending();
Paweł Hajdan Jr. 2011/10/25 09:01:38 NOOOOOO! Don't do that please, it's known to be ba
prasadt 2011/10/25 17:29:28 Spooky response for something that seems to be don
+
+ // Verify that the panel that's left is the panel from the second extension.
+ EXPECT_EQ(panel_other, panel_manager->panels()[0]);
+ panel_other->Close();
+}
+
class PanelDownloadTest : public PanelBrowserTest {
public:
PanelDownloadTest() : PanelBrowserTest() { }
« chrome/browser/ui/browser.cc ('K') | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698