Chromium Code Reviews| 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 | |
|
benwells
2012/10/24 03:24:08
There is a pattern in use for this kind of jiggery
tapted
2012/10/24 04:03:57
Done.
| |
| 711 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, 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 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FAILS_DevToolsOpenedWithReload) { | |
| 717 #endif | |
| 718 using content::DevToolsAgentHostRegistry; | |
| 719 | |
| 720 ExtensionTestMessageListener launched_listener("Launched", false); | |
| 721 const Extension* extension = LoadAndLaunchPlatformApp("minimal_id"); | |
| 722 ASSERT_TRUE(extension); | |
| 723 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | |
| 724 ShellWindow* window = GetFirstShellWindow(); | |
| 725 ASSERT_TRUE(window); | |
| 726 content::RenderViewHost* rvh = window->web_contents()->GetRenderViewHost(); | |
| 727 ASSERT_TRUE(rvh); | |
| 728 | |
| 729 // Ensure no DevTools open for the ShellWindow, then open one. | |
| 730 ASSERT_FALSE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); | |
| 731 DevToolsWindow* devtools_window = DevToolsWindow::OpenDevToolsWindow(rvh); | |
| 732 content::WindowedNotificationObserver loaded_observer( | |
| 733 content::NOTIFICATION_LOAD_STOP, | |
| 734 content::Source<content::NavigationController>( | |
| 735 &devtools_window->tab_contents()->web_contents()->GetController())); | |
| 736 loaded_observer.Wait(); | |
| 737 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); | |
| 738 | |
| 739 // Close the ShellWindow, and ensure it is gone. | |
| 740 CloseShellWindow(window); | |
| 741 ASSERT_FALSE(GetFirstShellWindow()); | |
| 742 | |
| 743 // Relaunch the app and get a new ShellWindow. | |
| 744 content::WindowedNotificationObserver app_loaded_observer( | |
| 745 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | |
| 746 content::NotificationService::AllSources()); | |
| 747 application_launch::OpenApplication(application_launch::LaunchParams( | |
| 748 browser()->profile(), extension, extension_misc::LAUNCH_NONE, | |
| 749 NEW_WINDOW)); | |
| 750 app_loaded_observer.Wait(); | |
| 751 window = GetFirstShellWindow(); | |
| 752 ASSERT_TRUE(window); | |
| 753 | |
| 754 // DevTools should have reopened with the relaunch. | |
| 755 rvh = window->web_contents()->GetRenderViewHost(); | |
| 756 ASSERT_TRUE(rvh); | |
| 757 ASSERT_TRUE(DevToolsAgentHostRegistry::HasDevToolsAgentHost(rvh)); | |
| 758 } | |
| 759 | |
| 706 } // namespace extensions | 760 } // namespace extensions |
| OLD | NEW |