OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/webkit_test_controller.h" | 5 #include "content/shell/browser/webkit_test_controller.h" |
6 | 6 |
7 #include <iostream> | 7 #include <iostream> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 DCHECK(instance_); | 198 DCHECK(instance_); |
199 return instance_; | 199 return instance_; |
200 } | 200 } |
201 | 201 |
202 WebKitTestController::WebKitTestController() | 202 WebKitTestController::WebKitTestController() |
203 : main_window_(NULL), | 203 : main_window_(NULL), |
204 test_phase_(BETWEEN_TESTS), | 204 test_phase_(BETWEEN_TESTS), |
205 is_leak_detection_enabled_( | 205 is_leak_detection_enabled_( |
206 base::CommandLine::ForCurrentProcess()->HasSwitch( | 206 base::CommandLine::ForCurrentProcess()->HasSwitch( |
207 switches::kEnableLeakDetection)), | 207 switches::kEnableLeakDetection)), |
208 crash_when_leak_found_(false) { | 208 crash_when_leak_found_(false), |
| 209 devtools_frontend_(NULL) { |
209 CHECK(!instance_); | 210 CHECK(!instance_); |
210 instance_ = this; | 211 instance_ = this; |
211 | 212 |
212 if (is_leak_detection_enabled_) { | 213 if (is_leak_detection_enabled_) { |
213 std::string switchValue = | 214 std::string switchValue = |
214 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 215 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
215 switches::kEnableLeakDetection); | 216 switches::kEnableLeakDetection); |
216 crash_when_leak_found_ = switchValue == switches::kCrashOnFailure; | 217 crash_when_leak_found_ = switchValue == switches::kCrashOnFailure; |
217 } | 218 } |
218 | 219 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 ShellContentBrowserClient::Get()->browser_context(); | 580 ShellContentBrowserClient::Get()->browser_context(); |
580 StoragePartition* storage_partition = | 581 StoragePartition* storage_partition = |
581 BrowserContext::GetStoragePartition(browser_context, NULL); | 582 BrowserContext::GetStoragePartition(browser_context, NULL); |
582 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( | 583 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( |
583 content::LayoutTestDevToolsFrontend::GetDevToolsPathAsURL("", "") | 584 content::LayoutTestDevToolsFrontend::GetDevToolsPathAsURL("", "") |
584 .GetOrigin()); | 585 .GetOrigin()); |
585 } | 586 } |
586 | 587 |
587 void WebKitTestController::OnShowDevTools(const std::string& settings, | 588 void WebKitTestController::OnShowDevTools(const std::string& settings, |
588 const std::string& frontend_url) { | 589 const std::string& frontend_url) { |
589 main_window_->ShowDevToolsForTest(settings, frontend_url); | 590 if (!devtools_frontend_) { |
| 591 devtools_frontend_ = LayoutTestDevToolsFrontend::Show( |
| 592 main_window_->web_contents(), settings, frontend_url); |
| 593 } else { |
| 594 devtools_frontend_->SwitchToTarget(main_window_->web_contents()); |
| 595 } |
| 596 devtools_frontend_->Activate(); |
| 597 devtools_frontend_->Focus(); |
590 } | 598 } |
591 | 599 |
592 void WebKitTestController::OnCloseDevTools() { | 600 void WebKitTestController::OnCloseDevTools() { |
593 main_window_->CloseDevTools(); | 601 if (devtools_frontend_) |
| 602 devtools_frontend_->DisconnectFromTarget(); |
594 } | 603 } |
595 | 604 |
596 void WebKitTestController::OnGoToOffset(int offset) { | 605 void WebKitTestController::OnGoToOffset(int offset) { |
597 main_window_->GoBackOrForward(offset); | 606 main_window_->GoBackOrForward(offset); |
598 } | 607 } |
599 | 608 |
600 void WebKitTestController::OnReload() { | 609 void WebKitTestController::OnReload() { |
601 main_window_->Reload(); | 610 main_window_->Reload(); |
602 } | 611 } |
603 | 612 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 655 |
647 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), | 656 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), |
648 routing_ids, | 657 routing_ids, |
649 session_histories, | 658 session_histories, |
650 current_entry_indexes)); | 659 current_entry_indexes)); |
651 } | 660 } |
652 | 661 |
653 void WebKitTestController::OnCloseRemainingWindows() { | 662 void WebKitTestController::OnCloseRemainingWindows() { |
654 DevToolsAgentHost::DetachAllClients(); | 663 DevToolsAgentHost::DetachAllClients(); |
655 std::vector<Shell*> open_windows(Shell::windows()); | 664 std::vector<Shell*> open_windows(Shell::windows()); |
| 665 Shell* devtools_shell = devtools_frontend_ ? |
| 666 devtools_frontend_->frontend_shell() : NULL; |
656 for (size_t i = 0; i < open_windows.size(); ++i) { | 667 for (size_t i = 0; i < open_windows.size(); ++i) { |
657 if (open_windows[i] != main_window_) | 668 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell) |
658 open_windows[i]->Close(); | 669 open_windows[i]->Close(); |
659 } | 670 } |
660 base::MessageLoop::current()->RunUntilIdle(); | 671 base::MessageLoop::current()->RunUntilIdle(); |
661 } | 672 } |
662 | 673 |
663 void WebKitTestController::OnResetDone() { | 674 void WebKitTestController::OnResetDone() { |
664 if (is_leak_detection_enabled_) { | 675 if (is_leak_detection_enabled_) { |
665 if (main_window_ && main_window_->web_contents()) { | 676 if (main_window_ && main_window_->web_contents()) { |
666 RenderViewHost* render_view_host = | 677 RenderViewHost* render_view_host = |
667 main_window_->web_contents()->GetRenderViewHost(); | 678 main_window_->web_contents()->GetRenderViewHost(); |
(...skipping 17 matching lines...) Expand all Loading... |
685 | 696 |
686 printer_->AddErrorMessage( | 697 printer_->AddErrorMessage( |
687 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, | 698 base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, |
688 result.detail.c_str())); | 699 result.detail.c_str())); |
689 CHECK(!crash_when_leak_found_); | 700 CHECK(!crash_when_leak_found_); |
690 | 701 |
691 DiscardMainWindow(); | 702 DiscardMainWindow(); |
692 } | 703 } |
693 | 704 |
694 } // namespace content | 705 } // namespace content |
OLD | NEW |