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

Side by Side Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 12210107: Fix issue 174250, crash when reloading packaged app. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: comments Created 7 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/shell_window_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/test/test_timeouts.h" 6 #include "base/test/test_timeouts.h"
7 #include "base/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/automation/automation_util.h" 10 #include "chrome/browser/automation/automation_util.h"
11 #include "chrome/browser/devtools/devtools_window.h" 11 #include "chrome/browser/devtools/devtools_window.h"
12 #include "chrome/browser/extensions/api/permissions/permissions_api.h" 12 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
13 #include "chrome/browser/extensions/extension_browsertest.h" 13 #include "chrome/browser/extensions/extension_browsertest.h"
14 #include "chrome/browser/extensions/extension_prefs.h" 14 #include "chrome/browser/extensions/extension_prefs.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_system.h" 16 #include "chrome/browser/extensions/extension_system.h"
17 #include "chrome/browser/extensions/extension_test_message_listener.h" 17 #include "chrome/browser/extensions/extension_test_message_listener.h"
18 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 18 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
19 #include "chrome/browser/extensions/platform_app_launcher.h" 19 #include "chrome/browser/extensions/platform_app_launcher.h"
20 #include "chrome/browser/extensions/shell_window_registry.h" 20 #include "chrome/browser/extensions/shell_window_registry.h"
21 #include "chrome/browser/prefs/pref_service.h" 21 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/tab_contents/render_view_context_menu.h" 22 #include "chrome/browser/tab_contents/render_view_context_menu.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/extensions/application_launch.h" 24 #include "chrome/browser/ui/extensions/application_launch.h"
25 #include "chrome/browser/ui/extensions/native_app_window.h" 25 #include "chrome/browser/ui/extensions/native_app_window.h"
26 #include "chrome/browser/ui/extensions/shell_window.h" 26 #include "chrome/browser/ui/extensions/shell_window.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" 28 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h"
29 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "chrome/test/base/ui_test_utils.h" 32 #include "chrome/test/base/ui_test_utils.h"
32 #include "content/public/browser/devtools_agent_host.h" 33 #include "content/public/browser/devtools_agent_host.h"
33 #include "content/public/browser/render_process_host.h" 34 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/render_widget_host_view.h" 35 #include "content/public/browser/render_widget_host_view.h"
35 #include "content/public/browser/web_contents_view.h" 36 #include "content/public/browser/web_contents_view.h"
36 #include "content/public/browser/web_intents_dispatcher.h" 37 #include "content/public/browser/web_intents_dispatcher.h"
37 #include "content/public/test/test_utils.h" 38 #include "content/public/test/test_utils.h"
38 #include "googleurl/src/gurl.h" 39 #include "googleurl/src/gurl.h"
39 #include "webkit/glue/web_intent_data.h" 40 #include "webkit/glue/web_intent_data.h"
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 760
760 // Tests that an app calling chrome.runtime.reload will reload the app and 761 // Tests that an app calling chrome.runtime.reload will reload the app and
761 // relaunch it if it was running. 762 // relaunch it if it was running.
762 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) { 763 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ReloadRelaunches) {
763 ExtensionTestMessageListener launched_listener("Launched", true); 764 ExtensionTestMessageListener launched_listener("Launched", true);
764 const Extension* extension = LoadAndLaunchPlatformApp("reload"); 765 const Extension* extension = LoadAndLaunchPlatformApp("reload");
765 ASSERT_TRUE(extension); 766 ASSERT_TRUE(extension);
766 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); 767 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
767 ASSERT_TRUE(GetFirstShellWindow()); 768 ASSERT_TRUE(GetFirstShellWindow());
768 769
769 // Now tell the app to reload itself 770 // Now tell the app to reload itself.
770 ExtensionTestMessageListener launched_listener2("Launched", false); 771 ExtensionTestMessageListener launched_listener2("Launched", false);
771 launched_listener.Reply("reload"); 772 launched_listener.Reply("reload");
772 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied()); 773 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
773 ASSERT_TRUE(GetFirstShellWindow()); 774 ASSERT_TRUE(GetFirstShellWindow());
774 } 775 }
775 776
776 namespace { 777 namespace {
777 778
778 // Simple observer to check for NOTIFICATION_EXTENSION_INSTALLED events to 779 // Simple observer to check for NOTIFICATION_EXTENSION_INSTALLED events to
779 // ensure installation does or does not occur in certain scenarios. 780 // ensure installation does or does not occur in certain scenarios.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 #else 922 #else
922 #define MAYBE_WebContentsHasFocus WebContentsHasFocus 923 #define MAYBE_WebContentsHasFocus WebContentsHasFocus
923 #endif 924 #endif
924 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) { 925 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_WebContentsHasFocus) {
925 const Extension* extension = LoadAndLaunchPlatformApp("minimal"); 926 const Extension* extension = LoadAndLaunchPlatformApp("minimal");
926 ShellWindow* window = CreateShellWindow(extension); 927 ShellWindow* window = CreateShellWindow(extension);
927 EXPECT_TRUE(window->web_contents()->GetRenderWidgetHostView()->HasFocus()); 928 EXPECT_TRUE(window->web_contents()->GetRenderWidgetHostView()->HasFocus());
928 CloseShellWindow(window); 929 CloseShellWindow(window);
929 } 930 }
930 931
932 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DontCrashWhenReloading) {
933 // Regression test for http://crbug.com/174250
934 browser()->profile()->GetPrefs()->SetBoolean(
935 prefs::kExtensionsUIDeveloperMode, true);
936 ui_test_utils::NavigateToURL(browser(), GURL("chrome://extensions"));
937 ExtensionTestMessageListener launched_listener("Launched", true);
938 const Extension* extension = LoadAndLaunchPlatformApp("reload");
939 ASSERT_TRUE(extension);
940 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
941 ASSERT_TRUE(GetFirstShellWindow());
942
943 // Now tell the app to reload itself.
944 ExtensionTestMessageListener launched_listener2("Launched", false);
945 launched_listener.Reply("reload");
946 ASSERT_TRUE(launched_listener2.WaitUntilSatisfied());
947 ASSERT_TRUE(GetFirstShellWindow());
948 }
949
931 } // namespace extensions 950 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/shell_window_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698