diff options
author | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 07:17:17 +0000 |
---|---|---|
committer | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 07:17:17 +0000 |
commit | 2c7b4d74870fe18ea04dcb281e43c4982c57f414 (patch) | |
tree | 75ce568f38bea39b676626939403982675985988 /chrome/browser/debugger | |
parent | 28cf9883c15d5322b8becbdbd400e66774477201 (diff) | |
download | chromium_src-2c7b4d74870fe18ea04dcb281e43c4982c57f414.zip chromium_src-2c7b4d74870fe18ea04dcb281e43c4982c57f414.tar.gz chromium_src-2c7b4d74870fe18ea04dcb281e43c4982c57f414.tar.bz2 |
DevTools: test that content scripts are visible in the debugger scripts list
BUG=25294,24214
TEST=DevToolsExtensionDebugTest.TestContentScriptIsPresent
Review URL: http://codereview.chromium.org/295020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger')
-rw-r--r-- | chrome/browser/debugger/devtools_sanity_unittest.cc | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc index c257da2..726d192 100644 --- a/chrome/browser/debugger/devtools_sanity_unittest.cc +++ b/chrome/browser/debugger/devtools_sanity_unittest.cc @@ -7,8 +7,11 @@ #include "chrome/browser/debugger/devtools_client_host.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/debugger/devtools_window.h" +#include "chrome/browser/extensions/extensions_service.h" +#include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" @@ -58,6 +61,8 @@ const wchar_t kDebuggerIntrinsicPropertiesPage[] = L"files/devtools/debugger_intrinsic_properties.html"; const wchar_t kCompletionOnPause[] = L"files/devtools/completion_on_pause.html"; +const wchar_t kPageWithContentScript[] = + L"files/devtools/page_with_content_script.html"; class DevToolsSanityTest : public InProcessBrowserTest { @@ -130,6 +135,61 @@ class DevToolsSanityTest : public InProcessBrowserTest { RenderViewHost* inspected_rvh_; }; + +// Base class for DevTools tests that test devtools functionality for +// extensions and content scripts. +class DevToolsExtensionDebugTest : public DevToolsSanityTest, + public NotificationObserver { + public: + DevToolsExtensionDebugTest() : DevToolsSanityTest() { + PathService::Get(chrome::DIR_TEST_DATA, &test_extensions_dir_); + test_extensions_dir_ = test_extensions_dir_.AppendASCII("devtools"); + test_extensions_dir_ = test_extensions_dir_.AppendASCII("extensions"); + } + + protected: + // Load an extention from test\data\devtools\extensions\<extension_name> + void LoadExtension(const char* extension_name) { + FilePath path = test_extensions_dir_.AppendASCII(extension_name); + ASSERT_TRUE(LoadExtensionFromPath(path)) << "Failed to load extension."; + } + + private: + bool LoadExtensionFromPath(const FilePath& path) { + ExtensionsService* service = browser()->profile()->GetExtensionsService(); + size_t num_before = service->extensions()->size(); + { + NotificationRegistrar registrar; + registrar.Add(this, NotificationType::EXTENSION_LOADED, + NotificationService::AllSources()); + MessageLoop::current()->PostDelayedTask( + FROM_HERE, new MessageLoop::QuitTask, 5*1000); + service->LoadExtension(path); + ui_test_utils::RunMessageLoop(); + } + size_t num_after = service->extensions()->size(); + return (num_after == (num_before + 1)); + } + + void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + switch (type.value) { + case NotificationType::EXTENSION_LOADED: + std::cout << "Got EXTENSION_LOADED notification.\n"; + MessageLoopForUI::current()->Quit(); + break; + + default: + NOTREACHED(); + break; + } + } + + FilePath test_extensions_dir_; +}; + + // WebInspector opens. IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestHostIsPresent) { RunTest("testHostIsPresent", kSimplePage); @@ -165,6 +225,13 @@ IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestShowScriptsTab) { RunTest("testShowScriptsTab", kDebuggerTestPage); } +// Tests that a content script is in the scripts list. +IN_PROC_BROWSER_TEST_F(DevToolsExtensionDebugTest, + TestContentScriptIsPresent) { + LoadExtension("simple_content_script"); + RunTest("testContentScriptIsPresent", kPageWithContentScript); +} + // Tests that scripts are not duplicated after Scripts Panel switch. IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNoScriptDuplicatesOnPanelSwitch) { |