Index: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc |
diff --git a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc |
index eb8799ff8e990522b002d7c2200193f39e1a8eea..166413349501ab0918a2437799c5cdb1ef5a4241 100644 |
--- a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc |
+++ b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc |
@@ -4,15 +4,23 @@ |
#include "base/macros.h" |
#include "base/run_loop.h" |
+#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/extensions/extension_uninstall_dialog.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_window.h" |
#include "chrome/test/base/in_process_browser_test.h" |
#include "content/public/test/test_utils.h" |
+#include "extensions/browser/extension_system.h" |
#include "extensions/common/extension.h" |
#include "extensions/common/extension_builder.h" |
#include "extensions/common/value_builder.h" |
+#if defined(OS_MACOSX) |
+#include "base/command_line.h" |
+#include "chrome/browser/ui/browser_dialogs.h" |
+#include "content/public/common/content_switches.h" |
+#endif |
+ |
namespace { |
scoped_refptr<extensions::Extension> BuildTestExtension() { |
@@ -53,14 +61,19 @@ class TestExtensionUninstallDialogDelegate |
typedef InProcessBrowserTest ExtensionUninstallDialogViewBrowserTest; |
// Test that ExtensionUninstallDialog cancels the uninstall if the aura::Window |
-// which is passed to ExtensionUninstallDialog::Create() is destroyed. |
+// which is passed to ExtensionUninstallDialog::Create() is destroyed before |
+// ExtensionUninstallDialogDelegateView is created. |
IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, |
TrackParentWindowDestruction) { |
- // Create a second browser to prevent the app from exiting when the browser is |
- // closed. |
- CreateBrowser(browser()->profile()); |
+#if defined(OS_MACOSX) |
+ base::CommandLine::ForCurrentProcess()-> |
+ AppendSwitchASCII(switches::kEnableFeatures, |
+ chrome::kMacViewsWebUIDialogs.name); |
+#endif |
scoped_refptr<extensions::Extension> extension(BuildTestExtension()); |
+ extensions::ExtensionSystem::Get(browser()->profile())->extension_service() |
+ ->AddExtension(extension.get()); |
base::RunLoop run_loop; |
TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure()); |
@@ -77,3 +90,38 @@ IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, |
run_loop.Run(); |
EXPECT_TRUE(delegate.canceled()); |
} |
+ |
+// Test that ExtensionUninstallDialog cancels the uninstall if the aura::Window |
+// which is passed to ExtensionUninstallDialog::Create() is destroyed after |
+// ExtensionUninstallDialogDelegateView is created. |
+IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, |
+ TrackParentWindowDestructionAfterViewCreation) { |
+#if defined(OS_MACOSX) |
+ base::CommandLine::ForCurrentProcess()-> |
+ AppendSwitchASCII(switches::kEnableFeatures, |
+ chrome::kMacViewsWebUIDialogs.name); |
+#endif |
+ |
+ scoped_refptr<extensions::Extension> extension(BuildTestExtension()); |
+ extensions::ExtensionSystem::Get(browser()->profile())->extension_service() |
+ ->AddExtension(extension.get()); |
+ |
+ base::RunLoop run_loop; |
+ TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure()); |
+ std::unique_ptr<extensions::ExtensionUninstallDialog> dialog( |
+ extensions::ExtensionUninstallDialog::Create( |
+ browser()->profile(), browser()->window()->GetNativeWindow(), |
+ &delegate)); |
+ content::RunAllPendingInMessageLoop(); |
+ |
+ dialog->ConfirmUninstall(extension.get(), |
+ extensions::UNINSTALL_REASON_FOR_TESTING, |
+ extensions::UNINSTALL_SOURCE_FOR_TESTING); |
+ |
+ content::RunAllPendingInMessageLoop(); |
+ |
+ // Kill parent window. |
+ browser()->window()->Close(); |
+ run_loop.Run(); |
+ EXPECT_TRUE(delegate.canceled()); |
+} |