| OLD | NEW |
| 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/tab_contents/render_view_context_menu.h" | 11 #include "chrome/browser/debugger/devtools_window.h" |
| 12 #include "chrome/browser/extensions/app_restore_service_factory.h" | 12 #include "chrome/browser/extensions/app_restore_service_factory.h" |
| 13 #include "chrome/browser/extensions/app_restore_service.h" | 13 #include "chrome/browser/extensions/app_restore_service.h" |
| 14 #include "chrome/browser/extensions/extension_browsertest.h" | 14 #include "chrome/browser/extensions/extension_browsertest.h" |
| 15 #include "chrome/browser/extensions/extension_prefs.h" | 15 #include "chrome/browser/extensions/extension_prefs.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_system.h" | 17 #include "chrome/browser/extensions/extension_system.h" |
| 18 #include "chrome/browser/extensions/extension_test_message_listener.h" | 18 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 19 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 19 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
| 20 #include "chrome/browser/extensions/platform_app_launcher.h" | 20 #include "chrome/browser/extensions/platform_app_launcher.h" |
| 21 #include "chrome/browser/extensions/shell_window_registry.h" | 21 #include "chrome/browser/extensions/shell_window_registry.h" |
| 22 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_tabstrip.h" | 24 #include "chrome/browser/ui/browser_tabstrip.h" |
| 24 #include "chrome/browser/ui/extensions/application_launch.h" | 25 #include "chrome/browser/ui/extensions/application_launch.h" |
| 25 #include "chrome/browser/ui/extensions/shell_window.h" | 26 #include "chrome/browser/ui/extensions/shell_window.h" |
| 27 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 28 #include "chrome/test/base/ui_test_utils.h" | 30 #include "chrome/test/base/ui_test_utils.h" |
| 31 #include "content/public/browser/devtools_agent_host_registry.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; |
| 36 | 39 |
| 37 namespace extensions { | 40 namespace extensions { |
| 38 | 41 |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 #ifdef NDEBUG |
| 711 #define MAYBE_DevToolsOpenedWithReload DevToolsOpenedWithReload |
| 712 #else |
| 713 // This is currently expected to fail in debug builds due to a segfault in |
| 714 // WebKit triggered by a dereference between #ifndef NDEBUG guards see |
| 715 // http://crbug.com/157097 . |
| 716 #define MAYBE_DevToolsOpenedWithReload FAILS_DevToolsOpenedWithReload |
| 717 #endif |
| 718 |
| 719 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_DevToolsOpenedWithReload) { |
| 720 using content::DevToolsAgentHostRegistry; |
| 721 |
| 722 ExtensionTestMessageListener launched_listener("Launched", false); |
| 723 const Extension* extension = LoadAndLaunchPlatformApp("minimal_id"); |
| 724 ASSERT_TRUE(extension); |
| 725 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 726 ShellWindow* window = GetFirstShellWindow(); |
| 727 ASSERT_TRUE(window); |
| 728 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost(); |
| 729 ASSERT_TRUE(rvh); |
| 730 |
| 731 // Ensure no DevTools open for the ShellWindow, then open one. |
| 732 ASSERT_FALSE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); |
| 733 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(rvh); |
| 734 content::WindowedNotificationObserver loaded_observer( |
| 735 content::NOTIFICATION_LOAD_STOP, |
| 736 content::Source<content::NavigationController>( |
| 737 &devtools_window->tab_contents()->web_contents()->GetController())); |
| 738 loaded_observer.Wait(); |
| 739 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); |
| 740 |
| 741 // Close the ShellWindow, and ensure it is gone. |
| 742 CloseShellWindow(window); |
| 743 ASSERT_FALSE(GetFirstShellWindow()); |
| 744 |
| 745 // Relaunch the app and get a new ShellWindow. |
| 746 content::WindowedNotificationObserver app_loaded_observer( |
| 747 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 748 content::NotificationService::AllSources()); |
| 749 application_launch::OpenApplication(application_launch::LaunchParams( |
| 750 browser()->profile(), extension, extension_misc::LAUNCH_NONE, |
| 751 NEW_WINDOW)); |
| 752 app_loaded_observer.Wait(); |
| 753 window = GetFirstShellWindow(); |
| 754 ASSERT_TRUE(window); |
| 755 |
| 756 // DevTools should have reopened with the relaunch. |
| 757 rvh = window->web_contents()->GetRenderViewHost(); |
| 758 ASSERT_TRUE(rvh); |
| 759 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); |
| 760 } |
| 761 |
| 706 } // namespace extensions | 762 } // namespace extensions |
| OLD | NEW |