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

Side by Side Diff: chrome/browser/debugger/devtools_sanity_unittest.cc

Issue 295020: DevTools: test that content scripts are visible in the debugger scripts list (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/devtools/extensions/simple_content_script/manifest.json » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/browser.h" 6 #include "chrome/browser/browser.h"
7 #include "chrome/browser/debugger/devtools_client_host.h" 7 #include "chrome/browser/debugger/devtools_client_host.h"
8 #include "chrome/browser/debugger/devtools_manager.h" 8 #include "chrome/browser/debugger/devtools_manager.h"
9 #include "chrome/browser/debugger/devtools_window.h" 9 #include "chrome/browser/debugger/devtools_window.h"
10 #include "chrome/browser/extensions/extensions_service.h"
11 #include "chrome/browser/profile.h"
10 #include "chrome/browser/renderer_host/render_view_host.h" 12 #include "chrome/browser/renderer_host/render_view_host.h"
11 #include "chrome/browser/tab_contents/tab_contents.h" 13 #include "chrome/browser/tab_contents/tab_contents.h"
14 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/notification_registrar.h" 16 #include "chrome/common/notification_registrar.h"
14 #include "chrome/common/notification_service.h" 17 #include "chrome/common/notification_service.h"
15 #include "chrome/test/in_process_browser_test.h" 18 #include "chrome/test/in_process_browser_test.h"
16 #include "chrome/test/ui_test_utils.h" 19 #include "chrome/test/ui_test_utils.h"
17 20
18 21
19 namespace { 22 namespace {
20 23
21 // Used to block until a dev tools client window's browser is closed. 24 // Used to block until a dev tools client window's browser is closed.
(...skipping 29 matching lines...) Expand all
51 const wchar_t kSyntaxErrorTestPage[] = 54 const wchar_t kSyntaxErrorTestPage[] =
52 L"files/devtools/script_syntax_error.html"; 55 L"files/devtools/script_syntax_error.html";
53 const wchar_t kDebuggerStepTestPage[] = 56 const wchar_t kDebuggerStepTestPage[] =
54 L"files/devtools/debugger_step.html"; 57 L"files/devtools/debugger_step.html";
55 const wchar_t kDebuggerClosurePage[] = 58 const wchar_t kDebuggerClosurePage[] =
56 L"files/devtools/debugger_closure.html"; 59 L"files/devtools/debugger_closure.html";
57 const wchar_t kDebuggerIntrinsicPropertiesPage[] = 60 const wchar_t kDebuggerIntrinsicPropertiesPage[] =
58 L"files/devtools/debugger_intrinsic_properties.html"; 61 L"files/devtools/debugger_intrinsic_properties.html";
59 const wchar_t kCompletionOnPause[] = 62 const wchar_t kCompletionOnPause[] =
60 L"files/devtools/completion_on_pause.html"; 63 L"files/devtools/completion_on_pause.html";
64 const wchar_t kPageWithContentScript[] =
65 L"files/devtools/page_with_content_script.html";
61 66
62 67
63 class DevToolsSanityTest : public InProcessBrowserTest { 68 class DevToolsSanityTest : public InProcessBrowserTest {
64 public: 69 public:
65 DevToolsSanityTest() { 70 DevToolsSanityTest() {
66 set_show_window(true); 71 set_show_window(true);
67 EnableDOMAutomation(); 72 EnableDOMAutomation();
68 } 73 }
69 74
70 protected: 75 protected:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 Browser* browser = window_->browser(); 128 Browser* browser = window_->browser();
124 devtools_manager->UnregisterDevToolsClientHostFor(inspected_rvh_); 129 devtools_manager->UnregisterDevToolsClientHostFor(inspected_rvh_);
125 BrowserClosedObserver close_observer(browser); 130 BrowserClosedObserver close_observer(browser);
126 } 131 }
127 132
128 TabContents* client_contents_; 133 TabContents* client_contents_;
129 DevToolsWindow* window_; 134 DevToolsWindow* window_;
130 RenderViewHost* inspected_rvh_; 135 RenderViewHost* inspected_rvh_;
131 }; 136 };
132 137
138
139 // Base class for DevTools tests that test devtools functionality for
140 // extensions and content scripts.
141 class DevToolsExtensionDebugTest : public DevToolsSanityTest,
142 public NotificationObserver {
143 public:
144 DevToolsExtensionDebugTest() : DevToolsSanityTest() {
145 PathService::Get(chrome::DIR_TEST_DATA, &test_extensions_dir_);
146 test_extensions_dir_ = test_extensions_dir_.AppendASCII("devtools");
147 test_extensions_dir_ = test_extensions_dir_.AppendASCII("extensions");
148 }
149
150 protected:
151 // Load an extention from test\data\devtools\extensions\<extension_name>
152 void LoadExtension(const char* extension_name) {
153 FilePath path = test_extensions_dir_.AppendASCII(extension_name);
154 ASSERT_TRUE(LoadExtensionFromPath(path)) << "Failed to load extension.";
155 }
156
157 private:
158 bool LoadExtensionFromPath(const FilePath& path) {
159 ExtensionsService* service = browser()->profile()->GetExtensionsService();
160 size_t num_before = service->extensions()->size();
161 {
162 NotificationRegistrar registrar;
163 registrar.Add(this, NotificationType::EXTENSION_LOADED,
164 NotificationService::AllSources());
165 MessageLoop::current()->PostDelayedTask(
166 FROM_HERE, new MessageLoop::QuitTask, 5*1000);
167 service->LoadExtension(path);
168 ui_test_utils::RunMessageLoop();
169 }
170 size_t num_after = service->extensions()->size();
171 return (num_after == (num_before + 1));
172 }
173
174 void Observe(NotificationType type,
175 const NotificationSource& source,
176 const NotificationDetails& details) {
177 switch (type.value) {
178 case NotificationType::EXTENSION_LOADED:
179 std::cout << "Got EXTENSION_LOADED notification.\n";
180 MessageLoopForUI::current()->Quit();
181 break;
182
183 default:
184 NOTREACHED();
185 break;
186 }
187 }
188
189 FilePath test_extensions_dir_;
190 };
191
192
133 // WebInspector opens. 193 // WebInspector opens.
134 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestHostIsPresent) { 194 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestHostIsPresent) {
135 RunTest("testHostIsPresent", kSimplePage); 195 RunTest("testHostIsPresent", kSimplePage);
136 } 196 }
137 197
138 // Tests elements panel basics. 198 // Tests elements panel basics.
139 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestElementsTreeRoot) { 199 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestElementsTreeRoot) {
140 RunTest("testElementsTreeRoot", kSimplePage); 200 RunTest("testElementsTreeRoot", kSimplePage);
141 } 201 }
142 202
(...skipping 15 matching lines...) Expand all
158 // Tests profiler panel. 218 // Tests profiler panel.
159 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestProfilerTab) { 219 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestProfilerTab) {
160 RunTest("testProfilerTab", kJsPage); 220 RunTest("testProfilerTab", kJsPage);
161 } 221 }
162 222
163 // Tests scripts panel showing. 223 // Tests scripts panel showing.
164 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestShowScriptsTab) { 224 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestShowScriptsTab) {
165 RunTest("testShowScriptsTab", kDebuggerTestPage); 225 RunTest("testShowScriptsTab", kDebuggerTestPage);
166 } 226 }
167 227
228 // Tests that a content script is in the scripts list.
229 IN_PROC_BROWSER_TEST_F(DevToolsExtensionDebugTest,
230 TestContentScriptIsPresent) {
231 LoadExtension("simple_content_script");
232 RunTest("testContentScriptIsPresent", kPageWithContentScript);
233 }
234
168 // Tests that scripts are not duplicated after Scripts Panel switch. 235 // Tests that scripts are not duplicated after Scripts Panel switch.
169 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, 236 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest,
170 TestNoScriptDuplicatesOnPanelSwitch) { 237 TestNoScriptDuplicatesOnPanelSwitch) {
171 RunTest("testNoScriptDuplicatesOnPanelSwitch", kDebuggerTestPage); 238 RunTest("testNoScriptDuplicatesOnPanelSwitch", kDebuggerTestPage);
172 } 239 }
173 240
174 // Tests set breakpoint. 241 // Tests set breakpoint.
175 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestSetBreakpoint) { 242 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestSetBreakpoint) {
176 RunTest("testSetBreakpoint", kDebuggerTestPage); 243 RunTest("testSetBreakpoint", kDebuggerTestPage);
177 } 244 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestConsoleLog) { 298 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestConsoleLog) {
232 RunTest("testConsoleLog", kConsoleTestPage); 299 RunTest("testConsoleLog", kConsoleTestPage);
233 } 300 }
234 301
235 // Tests eval global values. 302 // Tests eval global values.
236 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestEvalGlobal) { 303 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestEvalGlobal) {
237 RunTest("testEvalGlobal", kEvalTestPage); 304 RunTest("testEvalGlobal", kEvalTestPage);
238 } 305 }
239 306
240 } // namespace 307 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/devtools/extensions/simple_content_script/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698