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

Side by Side Diff: chrome/browser/devtools/devtools_sanity_browsertest.cc

Issue 108213012: [DevTools] Remove dock side knowledge from browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac tests Created 6 years, 11 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/cancelable_callback.h" 6 #include "base/cancelable_callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 content::ExecuteScriptAndExtractString( 99 content::ExecuteScriptAndExtractString(
100 window->GetRenderViewHost(), 100 window->GetRenderViewHost(),
101 base::StringPrintf("uiTests.runTest('%s')", test_name), 101 base::StringPrintf("uiTests.runTest('%s')", test_name),
102 &result)); 102 &result));
103 EXPECT_EQ("[OK]", result); 103 EXPECT_EQ("[OK]", result);
104 } else { 104 } else {
105 FAIL() << "DevTools front-end is broken."; 105 FAIL() << "DevTools front-end is broken.";
106 } 106 }
107 } 107 }
108 108
109 } // namespace
110
109 class DevToolsSanityTest : public InProcessBrowserTest { 111 class DevToolsSanityTest : public InProcessBrowserTest {
110 public: 112 public:
111 DevToolsSanityTest() 113 DevToolsSanityTest()
112 : window_(NULL), 114 : window_(NULL),
113 inspected_rvh_(NULL) {} 115 inspected_rvh_(NULL) {}
114 116
115 protected: 117 protected:
116 void RunTest(const std::string& test_name, const std::string& test_page) { 118 void RunTest(const std::string& test_name, const std::string& test_page) {
117 OpenDevToolsWindow(test_page); 119 OpenDevToolsWindow(test_page, false);
118 RunTestFunction(window_, test_name.c_str()); 120 RunTestFunction(window_, test_name.c_str());
119 CloseDevToolsWindow(); 121 CloseDevToolsWindow();
120 } 122 }
121 123
122 void LoadTestPage(const std::string& test_page) { 124 void LoadTestPage(const std::string& test_page) {
123 content::WindowedNotificationObserver load_observer( 125 content::WindowedNotificationObserver load_observer(
124 content::NOTIFICATION_LOAD_STOP, 126 content::NOTIFICATION_LOAD_STOP,
125 content::NotificationService::AllSources()); 127 content::NotificationService::AllSources());
126 GURL url = test_server()->GetURL(test_page); 128 GURL url = test_server()->GetURL(test_page);
127 ui_test_utils::NavigateToURL(browser(), url); 129 ui_test_utils::NavigateToURL(browser(), url);
128 load_observer.Wait(); 130 load_observer.Wait();
129 } 131 }
130 132
131 void OpenDevToolsWindow(const std::string& test_page) { 133 void OpenDevToolsWindow(const std::string& test_page, bool is_docked) {
132 ASSERT_TRUE(test_server()->Start()); 134 ASSERT_TRUE(test_server()->Start());
133 LoadTestPage(test_page); 135 LoadTestPage(test_page);
134 136
135 content::WindowedNotificationObserver observer( 137 content::WindowedNotificationObserver observer(
136 content::NOTIFICATION_LOAD_STOP, 138 content::NOTIFICATION_LOAD_STOP,
137 content::NotificationService::AllSources()); 139 content::NotificationService::AllSources());
138 inspected_rvh_ = GetInspectedTab()->GetRenderViewHost(); 140 inspected_rvh_ = GetInspectedTab()->GetRenderViewHost();
139 window_ = DevToolsWindow::OpenDevToolsWindow(inspected_rvh_); 141 window_ =
142 DevToolsWindow::OpenDevToolsWindowForTest(inspected_rvh_, is_docked);
140 observer.Wait(); 143 observer.Wait();
141 } 144 }
142 145
143 WebContents* GetInspectedTab() { 146 WebContents* GetInspectedTab() {
144 return browser()->tab_strip_model()->GetWebContentsAt(0); 147 return browser()->tab_strip_model()->GetWebContentsAt(0);
145 } 148 }
146 149
147 void ToggleDevToolsWindow() { 150 void ToggleDevToolsWindow() {
148 content::WindowedNotificationObserver close_observer( 151 content::WindowedNotificationObserver close_observer(
149 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 152 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
150 content::Source<content::WebContents>(window_->web_contents())); 153 content::Source<content::WebContents>(window_->web_contents()));
151 DevToolsWindow::ToggleDevToolsWindow(inspected_rvh_, false, 154 DevToolsWindow::ToggleDevToolsWindow(inspected_rvh_, false,
152 DevToolsToggleAction::Toggle()); 155 DevToolsToggleAction::Toggle());
153 close_observer.Wait(); 156 close_observer.Wait();
154 } 157 }
155 158
159 void ToggleDevToolsWindowDontWait() {
160 DevToolsWindow::ToggleDevToolsWindow(inspected_rvh_, false,
161 DevToolsToggleAction::Toggle());
162 }
163
156 void CloseDevToolsWindow() { 164 void CloseDevToolsWindow() {
157 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); 165 DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
158 content::WindowedNotificationObserver close_observer( 166 content::WindowedNotificationObserver close_observer(
159 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 167 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
160 content::Source<content::WebContents>(window_->web_contents())); 168 content::Source<content::WebContents>(window_->web_contents()));
161 devtools_manager->CloseAllClientHosts(); 169 devtools_manager->CloseAllClientHosts();
162 close_observer.Wait(); 170 close_observer.Wait();
163 } 171 }
164 172
165 DevToolsWindow* window_; 173 DevToolsWindow* window_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 command_line->AppendSwitch( 215 command_line->AppendSwitch(
208 switches::kDisableHangMonitor); 216 switches::kDisableHangMonitor);
209 } 217 }
210 218
211 void CloseInspectedTab() { 219 void CloseInspectedTab() {
212 browser()->tab_strip_model()->CloseWebContentsAt(0, 220 browser()->tab_strip_model()->CloseWebContentsAt(0,
213 TabStripModel::CLOSE_NONE); 221 TabStripModel::CLOSE_NONE);
214 } 222 }
215 223
216 void CloseDockedDevTools() { 224 void CloseDockedDevTools() {
217 DevToolsWindow::ToggleDevToolsWindow(inspected_rvh_, false, 225 ToggleDevToolsWindowDontWait();
218 DevToolsToggleAction::Toggle());
219 } 226 }
220 227
221 void CloseUndockedDevTools() { 228 void CloseUndockedDevTools() {
222 chrome::CloseWindow(window_->browser()); 229 chrome::CloseWindow(window_->browser());
223 } 230 }
224 231
225 void CloseInspectedBrowser() { 232 void CloseInspectedBrowser() {
226 chrome::CloseWindow(browser()); 233 chrome::CloseWindow(browser());
227 } 234 }
228 protected: 235 protected:
229 void InjectBeforeUnloadListener(content::WebContents* web_contents) { 236 void InjectBeforeUnloadListener(content::WebContents* web_contents) {
230 ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(), 237 ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(),
231 "window.addEventListener('beforeunload'," 238 "window.addEventListener('beforeunload',"
232 "function(event) { event.returnValue = 'Foo'; });")); 239 "function(event) { event.returnValue = 'Foo'; });"));
233 } 240 }
234 241
235 void RunBeforeUnloadSanityTest(DevToolsDockSide dock_side, 242 void RunBeforeUnloadSanityTest(bool is_docked,
236 base::Callback<void(void)> close_method, 243 base::Callback<void(void)> close_method,
237 bool wait_for_browser_close = true) { 244 bool wait_for_browser_close = true) {
238 OpenDevToolsWindow(kDebuggerTestPage); 245 OpenDevToolsWindow(kDebuggerTestPage, is_docked);
239 window_->SetDockSideForTest(dock_side);
240 content::WindowedNotificationObserver devtools_close_observer( 246 content::WindowedNotificationObserver devtools_close_observer(
241 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 247 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
242 content::Source<content::WebContents>(window_->web_contents())); 248 content::Source<content::WebContents>(window_->web_contents()));
243 InjectBeforeUnloadListener(window_->web_contents()); 249 InjectBeforeUnloadListener(window_->web_contents());
244 { 250 {
245 DevToolsWindowBeforeUnloadObserver before_unload_observer(window_); 251 DevToolsWindowBeforeUnloadObserver before_unload_observer(window_);
246 close_method.Run(); 252 close_method.Run();
247 CancelModalDialog(); 253 CancelModalDialog();
248 before_unload_observer.Wait(); 254 before_unload_observer.Wait();
249 } 255 }
250 { 256 {
251 content::WindowedNotificationObserver close_observer( 257 content::WindowedNotificationObserver close_observer(
252 chrome::NOTIFICATION_BROWSER_CLOSED, 258 chrome::NOTIFICATION_BROWSER_CLOSED,
253 content::Source<Browser>(browser())); 259 content::Source<Browser>(browser()));
254 close_method.Run(); 260 close_method.Run();
255 AcceptModalDialog(); 261 AcceptModalDialog();
256 if (wait_for_browser_close) 262 if (wait_for_browser_close)
257 close_observer.Wait(); 263 close_observer.Wait();
258 } 264 }
259 devtools_close_observer.Wait(); 265 devtools_close_observer.Wait();
260 } 266 }
261 267
262 DevToolsWindow* OpenDevToolWindowOnWebContents( 268 DevToolsWindow* OpenDevToolWindowOnWebContents(
263 content::WebContents* contents) { 269 content::WebContents* contents, bool is_docked) {
264 content::WindowedNotificationObserver observer( 270 content::WindowedNotificationObserver observer(
265 content::NOTIFICATION_LOAD_STOP, 271 content::NOTIFICATION_LOAD_STOP,
266 content::NotificationService::AllSources()); 272 content::NotificationService::AllSources());
267 DevToolsWindow* window = DevToolsWindow::OpenDevToolsWindow( 273 DevToolsWindow* window = DevToolsWindow::OpenDevToolsWindowForTest(
268 contents->GetRenderViewHost()); 274 contents->GetRenderViewHost(), is_docked);
269 observer.Wait(); 275 observer.Wait();
270 return window; 276 return window;
271 } 277 }
272 278
273 void OpenDevToolsPopupWindow(DevToolsWindow* devtools_window) { 279 void OpenDevToolsPopupWindow(DevToolsWindow* devtools_window) {
274 content::WindowedNotificationObserver observer( 280 content::WindowedNotificationObserver observer(
275 content::NOTIFICATION_LOAD_STOP, 281 content::NOTIFICATION_LOAD_STOP,
276 content::NotificationService::AllSources()); 282 content::NotificationService::AllSources());
277 ASSERT_TRUE(content::ExecuteScript( 283 ASSERT_TRUE(content::ExecuteScript(
278 devtools_window->web_contents()->GetRenderViewHost(), 284 devtools_window->web_contents()->GetRenderViewHost(),
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 scoped_refptr<WorkerData> worker_data(new WorkerData()); 542 scoped_refptr<WorkerData> worker_data(new WorkerData());
537 BrowserThread::PostTask( 543 BrowserThread::PostTask(
538 BrowserThread::IO, FROM_HERE, 544 BrowserThread::IO, FROM_HERE,
539 base::Bind(&WaitForFirstSharedWorkerOnIOThread, worker_data)); 545 base::Bind(&WaitForFirstSharedWorkerOnIOThread, worker_data));
540 content::RunMessageLoop(); 546 content::RunMessageLoop();
541 return worker_data; 547 return worker_data;
542 } 548 }
543 549
544 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { 550 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) {
545 Profile* profile = browser()->profile(); 551 Profile* profile = browser()->profile();
546 window_ = DevToolsWindow::CreateDevToolsWindowForWorker(profile);
547 window_->Show(DevToolsToggleAction::Show());
548 scoped_refptr<DevToolsAgentHost> agent_host( 552 scoped_refptr<DevToolsAgentHost> agent_host(
549 DevToolsAgentHost::GetForWorker( 553 DevToolsAgentHost::GetForWorker(
550 worker_data->worker_process_id, 554 worker_data->worker_process_id,
551 worker_data->worker_route_id)); 555 worker_data->worker_route_id));
552 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( 556 window_ = DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host);
553 agent_host.get(), window_->GetDevToolsClientHostForTest());
554 RenderViewHost* client_rvh = window_->GetRenderViewHost(); 557 RenderViewHost* client_rvh = window_->GetRenderViewHost();
555 WebContents* client_contents = WebContents::FromRenderViewHost(client_rvh); 558 WebContents* client_contents = WebContents::FromRenderViewHost(client_rvh);
556 if (client_contents->IsLoading()) { 559 if (client_contents->IsLoading()) {
557 content::WindowedNotificationObserver observer( 560 content::WindowedNotificationObserver observer(
558 content::NOTIFICATION_LOAD_STOP, 561 content::NOTIFICATION_LOAD_STOP,
559 content::Source<NavigationController>( 562 content::Source<NavigationController>(
560 &client_contents->GetController())); 563 &client_contents->GetController()));
561 observer.Wait(); 564 observer.Wait();
562 } 565 }
563 } 566 }
564 567
565 void CloseDevToolsWindow() { 568 void CloseDevToolsWindow() {
566 Browser* browser = window_->browser(); 569 Browser* browser = window_->browser();
567 content::WindowedNotificationObserver close_observer( 570 content::WindowedNotificationObserver close_observer(
568 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 571 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
569 content::Source<content::WebContents>(window_->web_contents())); 572 content::Source<content::WebContents>(window_->web_contents()));
570 browser->tab_strip_model()->CloseAllTabs(); 573 browser->tab_strip_model()->CloseAllTabs();
571 close_observer.Wait(); 574 close_observer.Wait();
572 } 575 }
573 576
574 DevToolsWindow* window_; 577 DevToolsWindow* window_;
575 }; 578 };
576 579
577 // Tests that BeforeUnload event gets called on docked devtools if 580 // Tests that BeforeUnload event gets called on docked devtools if
578 // we try to close them. 581 // we try to close them.
579 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, TestDockedDevToolsClose) { 582 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, TestDockedDevToolsClose) {
580 RunBeforeUnloadSanityTest(DEVTOOLS_DOCK_SIDE_BOTTOM, base::Bind( 583 RunBeforeUnloadSanityTest(true, base::Bind(
581 &DevToolsBeforeUnloadTest::CloseDockedDevTools, this), false); 584 &DevToolsBeforeUnloadTest::CloseDockedDevTools, this), false);
582 } 585 }
583 586
584 // Tests that BeforeUnload event gets called on docked devtools if 587 // Tests that BeforeUnload event gets called on docked devtools if
585 // we try to close the inspected page. 588 // we try to close the inspected page.
586 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 589 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
587 TestDockedDevToolsInspectedTabClose) { 590 TestDockedDevToolsInspectedTabClose) {
588 RunBeforeUnloadSanityTest(DEVTOOLS_DOCK_SIDE_BOTTOM, base::Bind( 591 RunBeforeUnloadSanityTest(true, base::Bind(
589 &DevToolsBeforeUnloadTest::CloseInspectedTab, this)); 592 &DevToolsBeforeUnloadTest::CloseInspectedTab, this));
590 } 593 }
591 594
592 // Tests that BeforeUnload event gets called on docked devtools if 595 // Tests that BeforeUnload event gets called on docked devtools if
593 // we try to close the inspected browser. 596 // we try to close the inspected browser.
594 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 597 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
595 TestDockedDevToolsInspectedBrowserClose) { 598 TestDockedDevToolsInspectedBrowserClose) {
596 RunBeforeUnloadSanityTest(DEVTOOLS_DOCK_SIDE_BOTTOM, base::Bind( 599 RunBeforeUnloadSanityTest(true, base::Bind(
597 &DevToolsBeforeUnloadTest::CloseInspectedBrowser, this)); 600 &DevToolsBeforeUnloadTest::CloseInspectedBrowser, this));
598 } 601 }
599 602
600 // Tests that BeforeUnload event gets called on undocked devtools if 603 // Tests that BeforeUnload event gets called on undocked devtools if
601 // we try to close them. 604 // we try to close them.
602 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, TestUndockedDevToolsClose) { 605 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, TestUndockedDevToolsClose) {
603 RunBeforeUnloadSanityTest(DEVTOOLS_DOCK_SIDE_UNDOCKED, base::Bind( 606 RunBeforeUnloadSanityTest(false, base::Bind(
604 &DevToolsBeforeUnloadTest::CloseUndockedDevTools, this), false); 607 &DevToolsBeforeUnloadTest::CloseUndockedDevTools, this), false);
605 } 608 }
606 609
607 // Tests that BeforeUnload event gets called on undocked devtools if 610 // Tests that BeforeUnload event gets called on undocked devtools if
608 // we try to close the inspected page. 611 // we try to close the inspected page.
609 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 612 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
610 TestUndockedDevToolsInspectedTabClose) { 613 TestUndockedDevToolsInspectedTabClose) {
611 RunBeforeUnloadSanityTest(DEVTOOLS_DOCK_SIDE_UNDOCKED, base::Bind( 614 RunBeforeUnloadSanityTest(false, base::Bind(
612 &DevToolsBeforeUnloadTest::CloseInspectedTab, this)); 615 &DevToolsBeforeUnloadTest::CloseInspectedTab, this));
613 } 616 }
614 617
615 // Tests that BeforeUnload event gets called on undocked devtools if 618 // Tests that BeforeUnload event gets called on undocked devtools if
616 // we try to close the inspected browser. 619 // we try to close the inspected browser.
617 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 620 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
618 TestUndockedDevToolsInspectedBrowserClose) { 621 TestUndockedDevToolsInspectedBrowserClose) {
619 RunBeforeUnloadSanityTest(DEVTOOLS_DOCK_SIDE_UNDOCKED, base::Bind( 622 RunBeforeUnloadSanityTest(false, base::Bind(
620 &DevToolsBeforeUnloadTest::CloseInspectedBrowser, this)); 623 &DevToolsBeforeUnloadTest::CloseInspectedBrowser, this));
621 } 624 }
622 625
623 // Tests that BeforeUnload event gets called on undocked devtools if 626 // Tests that BeforeUnload event gets called on undocked devtools if
624 // we try to exit application. 627 // we try to exit application.
625 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 628 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
626 TestUndockedDevToolsApplicationClose) { 629 TestUndockedDevToolsApplicationClose) {
627 RunBeforeUnloadSanityTest(DEVTOOLS_DOCK_SIDE_UNDOCKED, base::Bind( 630 RunBeforeUnloadSanityTest(false, base::Bind(
628 &chrome::CloseAllBrowsers)); 631 &chrome::CloseAllBrowsers));
629 } 632 }
630 633
631 // Tests that inspected tab gets closed if devtools renderer 634 // Tests that inspected tab gets closed if devtools renderer
632 // becomes unresponsive during beforeunload event interception. 635 // becomes unresponsive during beforeunload event interception.
633 // @see http://crbug.com/322380 636 // @see http://crbug.com/322380
634 IN_PROC_BROWSER_TEST_F(DevToolsUnresponsiveBeforeUnloadTest, 637 IN_PROC_BROWSER_TEST_F(DevToolsUnresponsiveBeforeUnloadTest,
635 TestUndockedDevToolsUnresponsive) { 638 TestUndockedDevToolsUnresponsive) {
636 ASSERT_TRUE(test_server()->Start()); 639 ASSERT_TRUE(test_server()->Start());
637 LoadTestPage(kDebuggerTestPage); 640 LoadTestPage(kDebuggerTestPage);
638 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( 641 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents(
639 GetInspectedTab()); 642 GetInspectedTab(), false);
640 devtools_window->SetDockSideForTest(DEVTOOLS_DOCK_SIDE_UNDOCKED);
641 content::WindowedNotificationObserver devtools_close_observer( 643 content::WindowedNotificationObserver devtools_close_observer(
642 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 644 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
643 content::Source<content::WebContents>( 645 content::Source<content::WebContents>(
644 devtools_window->web_contents())); 646 devtools_window->web_contents()));
645 647
646 ASSERT_TRUE(content::ExecuteScript( 648 ASSERT_TRUE(content::ExecuteScript(
647 devtools_window->web_contents()->GetRenderViewHost(), 649 devtools_window->web_contents()->GetRenderViewHost(),
648 "window.addEventListener('beforeunload'," 650 "window.addEventListener('beforeunload',"
649 "function(event) { while (true); });")); 651 "function(event) { while (true); });"));
650 CloseInspectedTab(); 652 CloseInspectedTab();
651 devtools_close_observer.Wait(); 653 devtools_close_observer.Wait();
652 } 654 }
653 655
654 // Tests that closing worker inspector window does not cause browser crash 656 // Tests that closing worker inspector window does not cause browser crash
655 // @see http://crbug.com/323031 657 // @see http://crbug.com/323031
656 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 658 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
657 TestWorkerWindowClosing) { 659 TestWorkerWindowClosing) {
658 ASSERT_TRUE(test_server()->Start()); 660 ASSERT_TRUE(test_server()->Start());
659 LoadTestPage(kDebuggerTestPage); 661 LoadTestPage(kDebuggerTestPage);
660 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( 662 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents(
661 GetInspectedTab()); 663 GetInspectedTab(), false);
662 devtools_window->SetDockSideForTest(DEVTOOLS_DOCK_SIDE_UNDOCKED);
663 content::WindowedNotificationObserver devtools_close_observer( 664 content::WindowedNotificationObserver devtools_close_observer(
664 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 665 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
665 content::Source<content::WebContents>( 666 content::Source<content::WebContents>(
666 devtools_window->web_contents())); 667 devtools_window->web_contents()));
667 668
668 OpenDevToolsPopupWindow(devtools_window); 669 OpenDevToolsPopupWindow(devtools_window);
669 CloseDevToolsPopupWindow(devtools_window); 670 CloseDevToolsPopupWindow(devtools_window);
670 } 671 }
671 672
672 // FLaky on Windows bots: see crbug.com/323847, Linux crbug.com/333554 673 // FLaky on Windows bots: see crbug.com/323847, Linux crbug.com/333554
673 #if defined(OS_WIN) || defined(OS_LINUX) 674 #if defined(OS_WIN) || defined(OS_LINUX)
674 #define MAYBE_TestDevToolsOnDevTools DISABLED_TestDevToolsOnDevTools 675 #define MAYBE_TestDevToolsOnDevTools DISABLED_TestDevToolsOnDevTools
675 #else 676 #else
676 #define MAYBE_TestDevToolsOnDevTools TestDevToolsOnDevTools 677 #define MAYBE_TestDevToolsOnDevTools TestDevToolsOnDevTools
677 #endif 678 #endif
678 // Tests that BeforeUnload event gets called on devtools that are opened 679 // Tests that BeforeUnload event gets called on devtools that are opened
679 // on another devtools. 680 // on another devtools.
680 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, 681 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest,
681 MAYBE_TestDevToolsOnDevTools) { 682 MAYBE_TestDevToolsOnDevTools) {
682 ASSERT_TRUE(test_server()->Start()); 683 ASSERT_TRUE(test_server()->Start());
683 LoadTestPage(kDebuggerTestPage); 684 LoadTestPage(kDebuggerTestPage);
684 685
685 std::vector<DevToolsWindow*> windows; 686 std::vector<DevToolsWindow*> windows;
686 std::vector<content::WindowedNotificationObserver*> close_observers; 687 std::vector<content::WindowedNotificationObserver*> close_observers;
687 content::WebContents* inspected_web_contents = GetInspectedTab(); 688 content::WebContents* inspected_web_contents = GetInspectedTab();
688 for (int i = 0; i < 3; ++i) { 689 for (int i = 0; i < 3; ++i) {
689 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( 690 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents(
690 inspected_web_contents); 691 inspected_web_contents, i == 0);
691 windows.push_back(devtools_window); 692 windows.push_back(devtools_window);
692 content::WindowedNotificationObserver* close_observer = 693 content::WindowedNotificationObserver* close_observer =
693 new content::WindowedNotificationObserver( 694 new content::WindowedNotificationObserver(
694 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 695 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
695 content::Source<content::WebContents>( 696 content::Source<content::WebContents>(
696 devtools_window->web_contents())); 697 devtools_window->web_contents()));
697 close_observers.push_back(close_observer); 698 close_observers.push_back(close_observer);
698 inspected_web_contents = devtools_window->web_contents(); 699 inspected_web_contents = devtools_window->web_contents();
699 } 700 }
700 701
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 858
858 // Tests that console messages are not duplicated on navigation back. 859 // Tests that console messages are not duplicated on navigation back.
859 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestConsoleOnNavigateBack) { 860 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestConsoleOnNavigateBack) {
860 RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage); 861 RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage);
861 } 862 }
862 863
863 864
864 // Tests that external navigation from inspector page is always handled by 865 // Tests that external navigation from inspector page is always handled by
865 // DevToolsWindow and results in inspected page navigation. 866 // DevToolsWindow and results in inspected page navigation.
866 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsExternalNavigation) { 867 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsExternalNavigation) {
867 OpenDevToolsWindow(kDebuggerTestPage); 868 OpenDevToolsWindow(kDebuggerTestPage, true);
868 GURL url = test_server()->GetURL(kNavigateBackTestPage); 869 GURL url = test_server()->GetURL(kNavigateBackTestPage);
869 content::WindowedNotificationObserver observer( 870 content::WindowedNotificationObserver observer(
870 content::NOTIFICATION_LOAD_STOP, 871 content::NOTIFICATION_LOAD_STOP,
871 content::NotificationService::AllSources()); 872 content::NotificationService::AllSources());
872 ASSERT_TRUE(content::ExecuteScript( 873 ASSERT_TRUE(content::ExecuteScript(
873 window_->web_contents(), 874 window_->web_contents(),
874 std::string("window.location = \"") + url.spec() + "\"")); 875 std::string("window.location = \"") + url.spec() + "\""));
875 observer.Wait(); 876 observer.Wait();
876 877
877 ASSERT_TRUE(window_->web_contents()->GetURL(). 878 ASSERT_TRUE(window_->web_contents()->GetURL().
878 SchemeIs(chrome::kChromeDevToolsScheme)); 879 SchemeIs(chrome::kChromeDevToolsScheme));
879 ASSERT_EQ(GetInspectedTab()->GetURL(), url); 880 ASSERT_EQ(GetInspectedTab()->GetURL(), url);
880 CloseDevToolsWindow(); 881 CloseDevToolsWindow();
881 } 882 }
882 883
883 #if defined(OS_WIN) || defined(OS_MACOSX) 884 #if defined(OS_WIN) || defined(OS_MACOSX)
884 // Flakily times out: http://crbug.com/163411 885 // Flakily times out: http://crbug.com/163411
885 #define MAYBE_TestReattachAfterCrash DISABLED_TestReattachAfterCrash 886 #define MAYBE_TestReattachAfterCrash DISABLED_TestReattachAfterCrash
886 #else 887 #else
887 #define MAYBE_TestReattachAfterCrash TestReattachAfterCrash 888 #define MAYBE_TestReattachAfterCrash TestReattachAfterCrash
888 #endif 889 #endif
889 // Tests that inspector will reattach to inspected page when it is reloaded 890 // Tests that inspector will reattach to inspected page when it is reloaded
890 // after a crash. See http://crbug.com/101952 891 // after a crash. See http://crbug.com/101952
891 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestReattachAfterCrash) { 892 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestReattachAfterCrash) {
892 OpenDevToolsWindow(kDebuggerTestPage); 893 OpenDevToolsWindow(kDebuggerTestPage, false);
893 894
894 content::CrashTab(GetInspectedTab()); 895 content::CrashTab(GetInspectedTab());
895 content::WindowedNotificationObserver observer( 896 content::WindowedNotificationObserver observer(
896 content::NOTIFICATION_LOAD_STOP, 897 content::NOTIFICATION_LOAD_STOP,
897 content::Source<NavigationController>( 898 content::Source<NavigationController>(
898 &browser()->tab_strip_model()->GetActiveWebContents()-> 899 &browser()->tab_strip_model()->GetActiveWebContents()->
899 GetController())); 900 GetController()));
900 chrome::Reload(browser(), CURRENT_TAB); 901 chrome::Reload(browser(), CURRENT_TAB);
901 observer.Wait(); 902 observer.Wait();
902 903
903 RunTestFunction(window_, "testReattachAfterCrash"); 904 RunTestFunction(window_, "testReattachAfterCrash");
904 CloseDevToolsWindow(); 905 CloseDevToolsWindow();
905 } 906 }
906 907
907 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) { 908 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) {
908 OpenDevToolsWindow("about:blank"); 909 OpenDevToolsWindow("about:blank", false);
909 std::string result; 910 std::string result;
910 ASSERT_TRUE( 911 ASSERT_TRUE(
911 content::ExecuteScriptAndExtractString( 912 content::ExecuteScriptAndExtractString(
912 window_->GetRenderViewHost(), 913 window_->GetRenderViewHost(),
913 "window.domAutomationController.send(" 914 "window.domAutomationController.send("
914 " '' + (window.uiTests && (typeof uiTests.runTest)));", 915 " '' + (window.uiTests && (typeof uiTests.runTest)));",
915 &result)); 916 &result));
916 ASSERT_EQ("function", result) << "DevTools front-end is broken."; 917 ASSERT_EQ("function", result) << "DevTools front-end is broken.";
917 CloseDevToolsWindow(); 918 CloseDevToolsWindow();
918 } 919 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 993
993 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) { 994 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) {
994 #if defined(OS_WIN) && defined(USE_ASH) 995 #if defined(OS_WIN) && defined(USE_ASH)
995 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 996 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
996 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 997 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
997 return; 998 return;
998 #endif 999 #endif
999 1000
1000 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; 1001 ASSERT_TRUE(RunExtensionTest("target_list")) << message_;
1001 } 1002 }
1002
1003 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_embedder_message_dispatcher.cc ('k') | chrome/browser/devtools/devtools_toggle_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698