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

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

Issue 11238055: Re-open DevTools windows for PackagedApps if they are reloaded with DevTools open. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: adds unit test but hits http://crbug.com/157097 on debug builds 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 unified diff | Download patch
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/debugger/devtools_window.h"
12 #include "content/public/browser/devtools_agent_host_registry.h"
11 #include "chrome/browser/tab_contents/render_view_context_menu.h" 13 #include "chrome/browser/tab_contents/render_view_context_menu.h"
12 #include "chrome/browser/extensions/app_restore_service_factory.h" 14 #include "chrome/browser/extensions/app_restore_service_factory.h"
13 #include "chrome/browser/extensions/app_restore_service.h" 15 #include "chrome/browser/extensions/app_restore_service.h"
14 #include "chrome/browser/extensions/extension_browsertest.h" 16 #include "chrome/browser/extensions/extension_browsertest.h"
15 #include "chrome/browser/extensions/extension_prefs.h" 17 #include "chrome/browser/extensions/extension_prefs.h"
16 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system.h" 19 #include "chrome/browser/extensions/extension_system.h"
18 #include "chrome/browser/extensions/extension_test_message_listener.h" 20 #include "chrome/browser/extensions/extension_test_message_listener.h"
19 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 21 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
20 #include "chrome/browser/extensions/platform_app_launcher.h" 22 #include "chrome/browser/extensions/platform_app_launcher.h"
21 #include "chrome/browser/extensions/shell_window_registry.h" 23 #include "chrome/browser/extensions/shell_window_registry.h"
22 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_tabstrip.h" 25 #include "chrome/browser/ui/browser_tabstrip.h"
24 #include "chrome/browser/ui/extensions/application_launch.h" 26 #include "chrome/browser/ui/extensions/application_launch.h"
25 #include "chrome/browser/ui/extensions/shell_window.h" 27 #include "chrome/browser/ui/extensions/shell_window.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents.h"
26 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
27 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
28 #include "chrome/test/base/ui_test_utils.h" 31 #include "chrome/test/base/ui_test_utils.h"
29 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/web_intents_dispatcher.h" 33 #include "content/public/browser/web_intents_dispatcher.h"
31 #include "content/public/test/test_utils.h" 34 #include "content/public/test/test_utils.h"
32 #include "googleurl/src/gurl.h" 35 #include "googleurl/src/gurl.h"
33 #include "webkit/glue/web_intent_data.h" 36 #include "webkit/glue/web_intent_data.h"
34 37
35 using content::WebContents; 38 using content::WebContents;
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 699
697 // Pretend that the app is supposed to be running. 700 // Pretend that the app is supposed to be running.
698 extension_prefs->SetExtensionRunning(extension->id(), true); 701 extension_prefs->SetExtensionRunning(extension->id(), true);
699 702
700 ExtensionTestMessageListener restart_listener("onRestarted", false); 703 ExtensionTestMessageListener restart_listener("onRestarted", false);
701 AppRestoreServiceFactory::GetForProfile(browser()->profile())-> 704 AppRestoreServiceFactory::GetForProfile(browser()->profile())->
702 HandleStartup(true); 705 HandleStartup(true);
703 restart_listener.WaitUntilSatisfied(); 706 restart_listener.WaitUntilSatisfied();
704 } 707 }
705 708
709 // Tests that relaunching an app with devtools open reopens devtools.
710 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DevToolsOpenedWithReload) {
711 using content::DevToolsAgentHostRegistry;
712
713 ExtensionTestMessageListener launched_listener("Launched", false);
714 const Extension* extension = LoadAndLaunchPlatformApp("minimal_id");
715 ASSERT_TRUE(extension);
716 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
717 ShellWindow* window = GetFirstShellWindow();
718 ASSERT_TRUE(window);
719 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost();
720 ASSERT_TRUE(rvh);
721 ASSERT_FALSE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
722 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(rvh);
723 content::WindowedNotificationObserver loaded_observer(
724 content::NOTIFICATION_LOAD_STOP,
725 content::Source<content::NavigationController>(
726 &devtools_window->tab_contents()
727 ->web_contents()->GetController()));
728
729 loaded_observer.Wait();
730 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
731
732 CloseShellWindow(window);
tapted 2012/10/23 10:16:45 This line triggers http://crbug.com/157097 when (W
benwells 2012/10/23 10:27:14 #if NDEBUG sg, with a comment linking to the bug.
tapted 2012/10/23 23:41:15 Done.
733 ASSERT_FALSE(GetFirstShellWindow()); // No ShellWindows.
734
735 content::WindowedNotificationObserver app_loaded_observer(
736 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
737 content::NotificationService::AllSources());
738 application_launch::OpenApplication(application_launch::LaunchParams(
739 browser()->profile(), extension, extension_misc::LAUNCH_NONE,
740 NEW_WINDOW));
741 app_loaded_observer.Wait();
742 window = GetFirstShellWindow();
743 ASSERT_TRUE(window);
744 rvh = window->web_contents()->GetRenderViewHost();
745 ASSERT_TRUE(rvh);
746 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh));
747 }
748
706 } // namespace extensions 749 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/app_window/app_window_api.cc ('k') | chrome/browser/extensions/shell_window_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698