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/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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 "files/workers/debug_shared_worker_initialization.html"; | 82 "files/workers/debug_shared_worker_initialization.html"; |
83 | 83 |
84 void RunTestFunction(DevToolsWindow* window, const char* test_name) { | 84 void RunTestFunction(DevToolsWindow* window, const char* test_name) { |
85 std::string result; | 85 std::string result; |
86 | 86 |
87 // At first check that JavaScript part of the front-end is loaded by | 87 // At first check that JavaScript part of the front-end is loaded by |
88 // checking that global variable uiTests exists(it's created after all js | 88 // checking that global variable uiTests exists(it's created after all js |
89 // files have been loaded) and has runTest method. | 89 // files have been loaded) and has runTest method. |
90 ASSERT_TRUE( | 90 ASSERT_TRUE( |
91 content::ExecuteScriptAndExtractString( | 91 content::ExecuteScriptAndExtractString( |
92 window->web_contents()->GetRenderViewHost(), | 92 window->web_contents_for_test()->GetRenderViewHost(), |
93 "window.domAutomationController.send(" | 93 "window.domAutomationController.send(" |
94 " '' + (window.uiTests && (typeof uiTests.runTest)));", | 94 " '' + (window.uiTests && (typeof uiTests.runTest)));", |
95 &result)); | 95 &result)); |
96 | 96 |
97 ASSERT_EQ("function", result) << "DevTools front-end is broken."; | 97 ASSERT_EQ("function", result) << "DevTools front-end is broken."; |
98 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 98 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
99 window->web_contents()->GetRenderViewHost(), | 99 window->web_contents_for_test()->GetRenderViewHost(), |
100 base::StringPrintf("uiTests.runTest('%s')", test_name), | 100 base::StringPrintf("uiTests.runTest('%s')", test_name), |
101 &result)); | 101 &result)); |
102 EXPECT_EQ("[OK]", result); | 102 EXPECT_EQ("[OK]", result); |
103 } | 103 } |
104 | 104 |
105 } // namespace | 105 } // namespace |
106 | 106 |
107 class DevToolsSanityTest : public InProcessBrowserTest { | 107 class DevToolsSanityTest : public InProcessBrowserTest { |
108 public: | 108 public: |
109 DevToolsSanityTest() | 109 DevToolsSanityTest() |
(...skipping 22 matching lines...) Expand all Loading... |
132 ui_test_utils::WaitUntilDevToolsWindowLoaded(window_); | 132 ui_test_utils::WaitUntilDevToolsWindowLoaded(window_); |
133 } | 133 } |
134 | 134 |
135 WebContents* GetInspectedTab() { | 135 WebContents* GetInspectedTab() { |
136 return browser()->tab_strip_model()->GetWebContentsAt(0); | 136 return browser()->tab_strip_model()->GetWebContentsAt(0); |
137 } | 137 } |
138 | 138 |
139 void ToggleDevToolsWindow() { | 139 void ToggleDevToolsWindow() { |
140 content::WindowedNotificationObserver close_observer( | 140 content::WindowedNotificationObserver close_observer( |
141 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 141 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
142 content::Source<content::WebContents>(window_->web_contents())); | 142 content::Source<content::WebContents>( |
| 143 window_->web_contents_for_test())); |
143 DevToolsWindow::ToggleDevToolsWindow(inspected_rvh_, false, | 144 DevToolsWindow::ToggleDevToolsWindow(inspected_rvh_, false, |
144 DevToolsToggleAction::Toggle()); | 145 DevToolsToggleAction::Toggle()); |
145 close_observer.Wait(); | 146 close_observer.Wait(); |
146 } | 147 } |
147 | 148 |
148 void ToggleDevToolsWindowDontWait() { | 149 void ToggleDevToolsWindowDontWait() { |
149 DevToolsWindow::ToggleDevToolsWindow(inspected_rvh_, false, | 150 DevToolsWindow::ToggleDevToolsWindow(inspected_rvh_, false, |
150 DevToolsToggleAction::Toggle()); | 151 DevToolsToggleAction::Toggle()); |
151 } | 152 } |
152 | 153 |
153 void CloseDevToolsWindow() { | 154 void CloseDevToolsWindow() { |
154 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 155 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
155 content::WindowedNotificationObserver close_observer( | 156 content::WindowedNotificationObserver close_observer( |
156 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 157 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
157 content::Source<content::WebContents>(window_->web_contents())); | 158 content::Source<content::WebContents>( |
| 159 window_->web_contents_for_test())); |
158 devtools_manager->CloseAllClientHosts(); | 160 devtools_manager->CloseAllClientHosts(); |
159 close_observer.Wait(); | 161 close_observer.Wait(); |
160 } | 162 } |
161 | 163 |
162 DevToolsWindow* window_; | 164 DevToolsWindow* window_; |
163 RenderViewHost* inspected_rvh_; | 165 RenderViewHost* inspected_rvh_; |
164 }; | 166 }; |
165 | 167 |
166 // Used to block until a dev tools window gets beforeunload event. | 168 // Used to block until a dev tools window gets beforeunload event. |
167 class DevToolsWindowBeforeUnloadObserver | 169 class DevToolsWindowBeforeUnloadObserver |
168 : public content::WebContentsObserver { | 170 : public content::WebContentsObserver { |
169 public: | 171 public: |
170 explicit DevToolsWindowBeforeUnloadObserver(DevToolsWindow*); | 172 explicit DevToolsWindowBeforeUnloadObserver(DevToolsWindow*); |
171 void Wait(); | 173 void Wait(); |
172 private: | 174 private: |
173 // Invoked when the beforeunload handler fires. | 175 // Invoked when the beforeunload handler fires. |
174 virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE; | 176 virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE; |
175 | 177 |
176 bool m_fired; | 178 bool m_fired; |
177 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 179 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
178 DISALLOW_COPY_AND_ASSIGN(DevToolsWindowBeforeUnloadObserver); | 180 DISALLOW_COPY_AND_ASSIGN(DevToolsWindowBeforeUnloadObserver); |
179 }; | 181 }; |
180 | 182 |
181 DevToolsWindowBeforeUnloadObserver::DevToolsWindowBeforeUnloadObserver( | 183 DevToolsWindowBeforeUnloadObserver::DevToolsWindowBeforeUnloadObserver( |
182 DevToolsWindow* devtools_window) | 184 DevToolsWindow* devtools_window) |
183 : WebContentsObserver(devtools_window->web_contents()), | 185 : WebContentsObserver(devtools_window->web_contents_for_test()), |
184 m_fired(false) { | 186 m_fired(false) { |
185 } | 187 } |
186 | 188 |
187 void DevToolsWindowBeforeUnloadObserver::Wait() { | 189 void DevToolsWindowBeforeUnloadObserver::Wait() { |
188 if (m_fired) | 190 if (m_fired) |
189 return; | 191 return; |
190 message_loop_runner_ = new content::MessageLoopRunner; | 192 message_loop_runner_ = new content::MessageLoopRunner; |
191 message_loop_runner_->Run(); | 193 message_loop_runner_->Run(); |
192 } | 194 } |
193 | 195 |
(...skipping 14 matching lines...) Expand all Loading... |
208 void CloseInspectedTab() { | 210 void CloseInspectedTab() { |
209 browser()->tab_strip_model()->CloseWebContentsAt(0, | 211 browser()->tab_strip_model()->CloseWebContentsAt(0, |
210 TabStripModel::CLOSE_NONE); | 212 TabStripModel::CLOSE_NONE); |
211 } | 213 } |
212 | 214 |
213 void CloseDockedDevTools() { | 215 void CloseDockedDevTools() { |
214 ToggleDevToolsWindowDontWait(); | 216 ToggleDevToolsWindowDontWait(); |
215 } | 217 } |
216 | 218 |
217 void CloseUndockedDevTools() { | 219 void CloseUndockedDevTools() { |
218 chrome::CloseWindow(window_->browser()); | 220 chrome::CloseWindow(window_->browser_for_test()); |
219 } | 221 } |
220 | 222 |
221 void CloseInspectedBrowser() { | 223 void CloseInspectedBrowser() { |
222 chrome::CloseWindow(browser()); | 224 chrome::CloseWindow(browser()); |
223 } | 225 } |
224 protected: | 226 protected: |
225 void InjectBeforeUnloadListener(content::WebContents* web_contents) { | 227 void InjectBeforeUnloadListener(content::WebContents* web_contents) { |
226 ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(), | 228 ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(), |
227 "window.addEventListener('beforeunload'," | 229 "window.addEventListener('beforeunload'," |
228 "function(event) { event.returnValue = 'Foo'; });")); | 230 "function(event) { event.returnValue = 'Foo'; });")); |
229 } | 231 } |
230 | 232 |
231 void RunBeforeUnloadSanityTest(bool is_docked, | 233 void RunBeforeUnloadSanityTest(bool is_docked, |
232 base::Callback<void(void)> close_method, | 234 base::Callback<void(void)> close_method, |
233 bool wait_for_browser_close = true) { | 235 bool wait_for_browser_close = true) { |
234 OpenDevToolsWindow(kDebuggerTestPage, is_docked); | 236 OpenDevToolsWindow(kDebuggerTestPage, is_docked); |
235 content::WindowedNotificationObserver devtools_close_observer( | 237 content::WindowedNotificationObserver devtools_close_observer( |
236 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 238 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
237 content::Source<content::WebContents>(window_->web_contents())); | 239 content::Source<content::WebContents>( |
238 InjectBeforeUnloadListener(window_->web_contents()); | 240 window_->web_contents_for_test())); |
| 241 InjectBeforeUnloadListener(window_->web_contents_for_test()); |
239 { | 242 { |
240 DevToolsWindowBeforeUnloadObserver before_unload_observer(window_); | 243 DevToolsWindowBeforeUnloadObserver before_unload_observer(window_); |
241 close_method.Run(); | 244 close_method.Run(); |
242 CancelModalDialog(); | 245 CancelModalDialog(); |
243 before_unload_observer.Wait(); | 246 before_unload_observer.Wait(); |
244 } | 247 } |
245 { | 248 { |
246 content::WindowedNotificationObserver close_observer( | 249 content::WindowedNotificationObserver close_observer( |
247 chrome::NOTIFICATION_BROWSER_CLOSED, | 250 chrome::NOTIFICATION_BROWSER_CLOSED, |
248 content::Source<Browser>(browser())); | 251 content::Source<Browser>(browser())); |
(...skipping 11 matching lines...) Expand all Loading... |
260 contents->GetRenderViewHost(), is_docked); | 263 contents->GetRenderViewHost(), is_docked); |
261 ui_test_utils::WaitUntilDevToolsWindowLoaded(window); | 264 ui_test_utils::WaitUntilDevToolsWindowLoaded(window); |
262 return window; | 265 return window; |
263 } | 266 } |
264 | 267 |
265 void OpenDevToolsPopupWindow(DevToolsWindow* devtools_window) { | 268 void OpenDevToolsPopupWindow(DevToolsWindow* devtools_window) { |
266 content::WindowedNotificationObserver observer( | 269 content::WindowedNotificationObserver observer( |
267 content::NOTIFICATION_LOAD_STOP, | 270 content::NOTIFICATION_LOAD_STOP, |
268 content::NotificationService::AllSources()); | 271 content::NotificationService::AllSources()); |
269 ASSERT_TRUE(content::ExecuteScript( | 272 ASSERT_TRUE(content::ExecuteScript( |
270 devtools_window->web_contents()->GetRenderViewHost(), | 273 devtools_window->web_contents_for_test()->GetRenderViewHost(), |
271 "window.open(\"\", \"\", \"location=0\");")); | 274 "window.open(\"\", \"\", \"location=0\");")); |
272 observer.Wait(); | 275 observer.Wait(); |
273 } | 276 } |
274 | 277 |
275 void CloseDevToolsPopupWindow(DevToolsWindow* devtools_window) { | 278 void CloseDevToolsPopupWindow(DevToolsWindow* devtools_window) { |
276 Browser* popup_browser = NULL; | 279 Browser* popup_browser = NULL; |
277 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 280 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
278 if (it->is_devtools()) { | 281 if (it->is_devtools()) { |
279 content::WebContents* contents = | 282 content::WebContents* contents = |
280 it->tab_strip_model()->GetWebContentsAt(0); | 283 it->tab_strip_model()->GetWebContentsAt(0); |
281 if (devtools_window->web_contents() != contents) { | 284 if (devtools_window->web_contents_for_test() != contents) { |
282 popup_browser = *it; | 285 popup_browser = *it; |
283 break; | 286 break; |
284 } | 287 } |
285 } | 288 } |
286 } | 289 } |
287 ASSERT_FALSE(popup_browser == NULL); | 290 ASSERT_FALSE(popup_browser == NULL); |
288 content::WindowedNotificationObserver close_observer( | 291 content::WindowedNotificationObserver close_observer( |
289 chrome::NOTIFICATION_BROWSER_CLOSED, | 292 chrome::NOTIFICATION_BROWSER_CLOSED, |
290 content::Source<Browser>(popup_browser)); | 293 content::Source<Browser>(popup_browser)); |
291 chrome::CloseWindow(popup_browser); | 294 chrome::CloseWindow(popup_browser); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 return worker_data; | 535 return worker_data; |
533 } | 536 } |
534 | 537 |
535 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { | 538 void OpenDevToolsWindowForSharedWorker(WorkerData* worker_data) { |
536 Profile* profile = browser()->profile(); | 539 Profile* profile = browser()->profile(); |
537 scoped_refptr<DevToolsAgentHost> agent_host( | 540 scoped_refptr<DevToolsAgentHost> agent_host( |
538 DevToolsAgentHost::GetForWorker( | 541 DevToolsAgentHost::GetForWorker( |
539 worker_data->worker_process_id, | 542 worker_data->worker_process_id, |
540 worker_data->worker_route_id)); | 543 worker_data->worker_route_id)); |
541 window_ = DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); | 544 window_ = DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); |
542 RenderViewHost* client_rvh = window_->web_contents()->GetRenderViewHost(); | 545 content::WaitForLoadStop(window_->web_contents_for_test()); |
543 WebContents* client_contents = WebContents::FromRenderViewHost(client_rvh); | |
544 content::WaitForLoadStop(client_contents); | |
545 } | 546 } |
546 | 547 |
547 void CloseDevToolsWindow() { | 548 void CloseDevToolsWindow() { |
548 Browser* browser = window_->browser(); | 549 Browser* browser = window_->browser_for_test(); |
549 content::WindowedNotificationObserver close_observer( | 550 content::WindowedNotificationObserver close_observer( |
550 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 551 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
551 content::Source<content::WebContents>(window_->web_contents())); | 552 content::Source<content::WebContents>( |
| 553 window_->web_contents_for_test())); |
552 browser->tab_strip_model()->CloseAllTabs(); | 554 browser->tab_strip_model()->CloseAllTabs(); |
553 close_observer.Wait(); | 555 close_observer.Wait(); |
554 } | 556 } |
555 | 557 |
556 DevToolsWindow* window_; | 558 DevToolsWindow* window_; |
557 }; | 559 }; |
558 | 560 |
559 // Tests that BeforeUnload event gets called on docked devtools if | 561 // Tests that BeforeUnload event gets called on docked devtools if |
560 // we try to close them. | 562 // we try to close them. |
561 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, TestDockedDevToolsClose) { | 563 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, TestDockedDevToolsClose) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 // @see http://crbug.com/322380 | 617 // @see http://crbug.com/322380 |
616 IN_PROC_BROWSER_TEST_F(DevToolsUnresponsiveBeforeUnloadTest, | 618 IN_PROC_BROWSER_TEST_F(DevToolsUnresponsiveBeforeUnloadTest, |
617 TestUndockedDevToolsUnresponsive) { | 619 TestUndockedDevToolsUnresponsive) { |
618 ASSERT_TRUE(test_server()->Start()); | 620 ASSERT_TRUE(test_server()->Start()); |
619 LoadTestPage(kDebuggerTestPage); | 621 LoadTestPage(kDebuggerTestPage); |
620 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( | 622 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( |
621 GetInspectedTab(), false); | 623 GetInspectedTab(), false); |
622 content::WindowedNotificationObserver devtools_close_observer( | 624 content::WindowedNotificationObserver devtools_close_observer( |
623 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 625 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
624 content::Source<content::WebContents>( | 626 content::Source<content::WebContents>( |
625 devtools_window->web_contents())); | 627 devtools_window->web_contents_for_test())); |
626 | 628 |
627 ASSERT_TRUE(content::ExecuteScript( | 629 ASSERT_TRUE(content::ExecuteScript( |
628 devtools_window->web_contents()->GetRenderViewHost(), | 630 devtools_window->web_contents_for_test()->GetRenderViewHost(), |
629 "window.addEventListener('beforeunload'," | 631 "window.addEventListener('beforeunload'," |
630 "function(event) { while (true); });")); | 632 "function(event) { while (true); });")); |
631 CloseInspectedTab(); | 633 CloseInspectedTab(); |
632 devtools_close_observer.Wait(); | 634 devtools_close_observer.Wait(); |
633 } | 635 } |
634 | 636 |
635 // Tests that closing worker inspector window does not cause browser crash | 637 // Tests that closing worker inspector window does not cause browser crash |
636 // @see http://crbug.com/323031 | 638 // @see http://crbug.com/323031 |
637 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, | 639 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, |
638 TestWorkerWindowClosing) { | 640 TestWorkerWindowClosing) { |
639 ASSERT_TRUE(test_server()->Start()); | 641 ASSERT_TRUE(test_server()->Start()); |
640 LoadTestPage(kDebuggerTestPage); | 642 LoadTestPage(kDebuggerTestPage); |
641 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( | 643 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( |
642 GetInspectedTab(), false); | 644 GetInspectedTab(), false); |
643 content::WindowedNotificationObserver devtools_close_observer( | 645 content::WindowedNotificationObserver devtools_close_observer( |
644 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 646 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
645 content::Source<content::WebContents>( | 647 content::Source<content::WebContents>( |
646 devtools_window->web_contents())); | 648 devtools_window->web_contents_for_test())); |
647 | 649 |
648 OpenDevToolsPopupWindow(devtools_window); | 650 OpenDevToolsPopupWindow(devtools_window); |
649 CloseDevToolsPopupWindow(devtools_window); | 651 CloseDevToolsPopupWindow(devtools_window); |
650 } | 652 } |
651 | 653 |
652 // Tests that BeforeUnload event gets called on devtools that are opened | 654 // Tests that BeforeUnload event gets called on devtools that are opened |
653 // on another devtools. | 655 // on another devtools. |
654 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, | 656 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, |
655 TestDevToolsOnDevTools) { | 657 TestDevToolsOnDevTools) { |
656 ASSERT_TRUE(test_server()->Start()); | 658 ASSERT_TRUE(test_server()->Start()); |
657 LoadTestPage(kDebuggerTestPage); | 659 LoadTestPage(kDebuggerTestPage); |
658 | 660 |
659 std::vector<DevToolsWindow*> windows; | 661 std::vector<DevToolsWindow*> windows; |
660 std::vector<content::WindowedNotificationObserver*> close_observers; | 662 std::vector<content::WindowedNotificationObserver*> close_observers; |
661 content::WebContents* inspected_web_contents = GetInspectedTab(); | 663 content::WebContents* inspected_web_contents = GetInspectedTab(); |
662 for (int i = 0; i < 3; ++i) { | 664 for (int i = 0; i < 3; ++i) { |
663 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( | 665 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( |
664 inspected_web_contents, i == 0); | 666 inspected_web_contents, i == 0); |
665 windows.push_back(devtools_window); | 667 windows.push_back(devtools_window); |
666 content::WindowedNotificationObserver* close_observer = | 668 content::WindowedNotificationObserver* close_observer = |
667 new content::WindowedNotificationObserver( | 669 new content::WindowedNotificationObserver( |
668 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 670 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
669 content::Source<content::WebContents>( | 671 content::Source<content::WebContents>( |
670 devtools_window->web_contents())); | 672 devtools_window->web_contents_for_test())); |
671 close_observers.push_back(close_observer); | 673 close_observers.push_back(close_observer); |
672 inspected_web_contents = devtools_window->web_contents(); | 674 inspected_web_contents = devtools_window->web_contents_for_test(); |
673 } | 675 } |
674 | 676 |
675 InjectBeforeUnloadListener(windows[0]->web_contents()); | 677 InjectBeforeUnloadListener(windows[0]->web_contents_for_test()); |
676 InjectBeforeUnloadListener(windows[2]->web_contents()); | 678 InjectBeforeUnloadListener(windows[2]->web_contents_for_test()); |
677 // Try to close second devtools. | 679 // Try to close second devtools. |
678 { | 680 { |
679 content::WindowedNotificationObserver cancel_browser( | 681 content::WindowedNotificationObserver cancel_browser( |
680 chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, | 682 chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, |
681 content::NotificationService::AllSources()); | 683 content::NotificationService::AllSources()); |
682 chrome::CloseWindow(windows[1]->browser()); | 684 chrome::CloseWindow(windows[1]->browser_for_test()); |
683 CancelModalDialog(); | 685 CancelModalDialog(); |
684 cancel_browser.Wait(); | 686 cancel_browser.Wait(); |
685 } | 687 } |
686 // Try to close browser window. | 688 // Try to close browser window. |
687 { | 689 { |
688 content::WindowedNotificationObserver cancel_browser( | 690 content::WindowedNotificationObserver cancel_browser( |
689 chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, | 691 chrome::NOTIFICATION_BROWSER_CLOSE_CANCELLED, |
690 content::NotificationService::AllSources()); | 692 content::NotificationService::AllSources()); |
691 chrome::CloseWindow(browser()); | 693 chrome::CloseWindow(browser()); |
692 AcceptModalDialog(); | 694 AcceptModalDialog(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 | 851 |
850 // Tests that external navigation from inspector page is always handled by | 852 // Tests that external navigation from inspector page is always handled by |
851 // DevToolsWindow and results in inspected page navigation. | 853 // DevToolsWindow and results in inspected page navigation. |
852 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsExternalNavigation) { | 854 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsExternalNavigation) { |
853 OpenDevToolsWindow(kDebuggerTestPage, true); | 855 OpenDevToolsWindow(kDebuggerTestPage, true); |
854 GURL url = test_server()->GetURL(kNavigateBackTestPage); | 856 GURL url = test_server()->GetURL(kNavigateBackTestPage); |
855 // TODO(dgozman): remove this once notifications are gone. | 857 // TODO(dgozman): remove this once notifications are gone. |
856 // Right now notifications happen after observers, so DevTools window is | 858 // Right now notifications happen after observers, so DevTools window is |
857 // already loaded, but we still catch it's notification when looking for | 859 // already loaded, but we still catch it's notification when looking for |
858 // all sources. | 860 // all sources. |
859 content::WaitForLoadStop(window_->web_contents()); | 861 content::WaitForLoadStop(window_->web_contents_for_test()); |
860 content::WindowedNotificationObserver observer( | 862 content::WindowedNotificationObserver observer( |
861 content::NOTIFICATION_LOAD_STOP, | 863 content::NOTIFICATION_LOAD_STOP, |
862 content::NotificationService::AllSources()); | 864 content::NotificationService::AllSources()); |
863 ASSERT_TRUE(content::ExecuteScript( | 865 ASSERT_TRUE(content::ExecuteScript( |
864 window_->web_contents(), | 866 window_->web_contents_for_test(), |
865 std::string("window.location = \"") + url.spec() + "\"")); | 867 std::string("window.location = \"") + url.spec() + "\"")); |
866 observer.Wait(); | 868 observer.Wait(); |
867 | 869 |
868 ASSERT_TRUE(window_->web_contents()->GetURL(). | 870 ASSERT_TRUE(window_->web_contents_for_test()->GetURL(). |
869 SchemeIs(content::kChromeDevToolsScheme)); | 871 SchemeIs(content::kChromeDevToolsScheme)); |
870 ASSERT_EQ(url, GetInspectedTab()->GetURL()); | 872 ASSERT_EQ(url, GetInspectedTab()->GetURL()); |
871 CloseDevToolsWindow(); | 873 CloseDevToolsWindow(); |
872 } | 874 } |
873 | 875 |
874 // Tests that inspector will reattach to inspected page when it is reloaded | 876 // Tests that inspector will reattach to inspected page when it is reloaded |
875 // after a crash. See http://crbug.com/101952 | 877 // after a crash. See http://crbug.com/101952 |
876 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestReattachAfterCrash) { | 878 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestReattachAfterCrash) { |
877 RunTest("testReattachAfterCrash", std::string()); | 879 RunTest("testReattachAfterCrash", std::string()); |
878 } | 880 } |
879 | 881 |
880 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) { | 882 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) { |
881 OpenDevToolsWindow("about:blank", false); | 883 OpenDevToolsWindow("about:blank", false); |
882 std::string result; | 884 std::string result; |
883 ASSERT_TRUE( | 885 ASSERT_TRUE( |
884 content::ExecuteScriptAndExtractString( | 886 content::ExecuteScriptAndExtractString( |
885 window_->web_contents()->GetRenderViewHost(), | 887 window_->web_contents_for_test()->GetRenderViewHost(), |
886 "window.domAutomationController.send(" | 888 "window.domAutomationController.send(" |
887 " '' + (window.uiTests && (typeof uiTests.runTest)));", | 889 " '' + (window.uiTests && (typeof uiTests.runTest)));", |
888 &result)); | 890 &result)); |
889 ASSERT_EQ("function", result) << "DevTools front-end is broken."; | 891 ASSERT_EQ("function", result) << "DevTools front-end is broken."; |
890 CloseDevToolsWindow(); | 892 CloseDevToolsWindow(); |
891 } | 893 } |
892 | 894 |
893 #if defined(OS_MACOSX) | 895 #if defined(OS_MACOSX) |
894 #define MAYBE_InspectSharedWorker DISABLED_InspectSharedWorker | 896 #define MAYBE_InspectSharedWorker DISABLED_InspectSharedWorker |
895 #else | 897 #else |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 | 967 |
966 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) { | 968 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) { |
967 #if defined(OS_WIN) && defined(USE_ASH) | 969 #if defined(OS_WIN) && defined(USE_ASH) |
968 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 970 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
969 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 971 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
970 return; | 972 return; |
971 #endif | 973 #endif |
972 | 974 |
973 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; | 975 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; |
974 } | 976 } |
OLD | NEW |