| 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/layout_test/blink_test_controller.h" | 5 #include "content/shell/browser/layout_test/blink_test_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 BlinkTestController* BlinkTestController::instance_ = NULL; | 240 BlinkTestController* BlinkTestController::instance_ = NULL; |
| 241 | 241 |
| 242 // static | 242 // static |
| 243 BlinkTestController* BlinkTestController::Get() { | 243 BlinkTestController* BlinkTestController::Get() { |
| 244 DCHECK(instance_); | 244 DCHECK(instance_); |
| 245 return instance_; | 245 return instance_; |
| 246 } | 246 } |
| 247 | 247 |
| 248 BlinkTestController::BlinkTestController() | 248 BlinkTestController::BlinkTestController() |
| 249 : main_window_(NULL), | 249 : main_window_(NULL), |
| 250 devtools_window_(nullptr), |
| 250 test_phase_(BETWEEN_TESTS), | 251 test_phase_(BETWEEN_TESTS), |
| 251 is_leak_detection_enabled_( | 252 is_leak_detection_enabled_( |
| 252 base::CommandLine::ForCurrentProcess()->HasSwitch( | 253 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 253 switches::kEnableLeakDetection)), | 254 switches::kEnableLeakDetection)), |
| 254 crash_when_leak_found_(false), | 255 crash_when_leak_found_(false), |
| 255 render_process_host_observer_(this) { | 256 render_process_host_observer_(this) { |
| 256 CHECK(!instance_); | 257 CHECK(!instance_); |
| 257 instance_ = this; | 258 instance_ = this; |
| 258 | 259 |
| 259 if (is_leak_detection_enabled_) { | 260 if (is_leak_detection_enabled_) { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 void BlinkTestController::RenderFrameCreated( | 508 void BlinkTestController::RenderFrameCreated( |
| 508 RenderFrameHost* render_frame_host) { | 509 RenderFrameHost* render_frame_host) { |
| 509 DCHECK(CalledOnValidThread()); | 510 DCHECK(CalledOnValidThread()); |
| 510 HandleNewRenderFrameHost(render_frame_host); | 511 HandleNewRenderFrameHost(render_frame_host); |
| 511 } | 512 } |
| 512 | 513 |
| 513 void BlinkTestController::DevToolsProcessCrashed() { | 514 void BlinkTestController::DevToolsProcessCrashed() { |
| 514 DCHECK(CalledOnValidThread()); | 515 DCHECK(CalledOnValidThread()); |
| 515 printer_->AddErrorMessage("#CRASHED - devtools"); | 516 printer_->AddErrorMessage("#CRASHED - devtools"); |
| 516 devtools_bindings_.reset(); | 517 devtools_bindings_.reset(); |
| 517 devtools_window_.reset(); | 518 if (devtools_window_) |
| 519 devtools_window_->Close(); |
| 520 devtools_window_ = nullptr; |
| 518 } | 521 } |
| 519 | 522 |
| 520 void BlinkTestController::WebContentsDestroyed() { | 523 void BlinkTestController::WebContentsDestroyed() { |
| 521 DCHECK(CalledOnValidThread()); | 524 DCHECK(CalledOnValidThread()); |
| 522 printer_->AddErrorMessage("FAIL: main window was destroyed"); | 525 printer_->AddErrorMessage("FAIL: main window was destroyed"); |
| 523 DiscardMainWindow(); | 526 DiscardMainWindow(); |
| 524 } | 527 } |
| 525 | 528 |
| 526 void BlinkTestController::RenderProcessHostDestroyed( | 529 void BlinkTestController::RenderProcessHostDestroyed( |
| 527 RenderProcessHost* render_process_host) { | 530 RenderProcessHost* render_process_host) { |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( | 830 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( |
| 828 content::LayoutTestDevToolsBindings::GetDevToolsPathAsURL("") | 831 content::LayoutTestDevToolsBindings::GetDevToolsPathAsURL("") |
| 829 .GetOrigin()); | 832 .GetOrigin()); |
| 830 } | 833 } |
| 831 | 834 |
| 832 void BlinkTestController::OnShowDevTools(const std::string& settings, | 835 void BlinkTestController::OnShowDevTools(const std::string& settings, |
| 833 const std::string& frontend_url) { | 836 const std::string& frontend_url) { |
| 834 if (!devtools_window_) { | 837 if (!devtools_window_) { |
| 835 ShellBrowserContext* browser_context = | 838 ShellBrowserContext* browser_context = |
| 836 ShellContentBrowserClient::Get()->browser_context(); | 839 ShellContentBrowserClient::Get()->browser_context(); |
| 837 devtools_window_.reset(content::Shell::CreateNewWindow( | 840 devtools_window_ = content::Shell::CreateNewWindow(browser_context, GURL(), |
| 838 browser_context, GURL(), nullptr, initial_size_)); | 841 nullptr, initial_size_); |
| 839 } | 842 } |
| 840 | 843 |
| 841 devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools( | 844 devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools( |
| 842 devtools_window_->web_contents(), main_window_->web_contents(), settings, | 845 devtools_window_->web_contents(), main_window_->web_contents(), settings, |
| 843 frontend_url)); | 846 frontend_url)); |
| 844 devtools_window_->web_contents()->GetRenderViewHost()->GetWidget()->Focus(); | 847 devtools_window_->web_contents()->GetRenderViewHost()->GetWidget()->Focus(); |
| 845 devtools_window_->web_contents()->Focus(); | 848 devtools_window_->web_contents()->Focus(); |
| 846 } | 849 } |
| 847 | 850 |
| 848 void BlinkTestController::OnEvaluateInDevTools( | 851 void BlinkTestController::OnEvaluateInDevTools( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), | 910 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), |
| 908 routing_ids, | 911 routing_ids, |
| 909 session_histories, | 912 session_histories, |
| 910 current_entry_indexes)); | 913 current_entry_indexes)); |
| 911 } | 914 } |
| 912 | 915 |
| 913 void BlinkTestController::OnCloseRemainingWindows() { | 916 void BlinkTestController::OnCloseRemainingWindows() { |
| 914 DevToolsAgentHost::DetachAllClients(); | 917 DevToolsAgentHost::DetachAllClients(); |
| 915 std::vector<Shell*> open_windows(Shell::windows()); | 918 std::vector<Shell*> open_windows(Shell::windows()); |
| 916 for (size_t i = 0; i < open_windows.size(); ++i) { | 919 for (size_t i = 0; i < open_windows.size(); ++i) { |
| 917 if (open_windows[i] != main_window_ && | 920 if (open_windows[i] != main_window_ && open_windows[i] != devtools_window_) |
| 918 open_windows[i] != devtools_window_.get()) | |
| 919 open_windows[i]->Close(); | 921 open_windows[i]->Close(); |
| 920 } | 922 } |
| 921 base::RunLoop().RunUntilIdle(); | 923 base::RunLoop().RunUntilIdle(); |
| 922 } | 924 } |
| 923 | 925 |
| 924 void BlinkTestController::OnResetDone() { | 926 void BlinkTestController::OnResetDone() { |
| 925 if (is_leak_detection_enabled_) { | 927 if (is_leak_detection_enabled_) { |
| 926 if (main_window_ && main_window_->web_contents()) { | 928 if (main_window_ && main_window_->web_contents()) { |
| 927 RenderViewHost* render_view_host = | 929 RenderViewHost* render_view_host = |
| 928 main_window_->web_contents()->GetRenderViewHost(); | 930 main_window_->web_contents()->GetRenderViewHost(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 } | 1009 } |
| 1008 DCHECK(layout_test_control_map_[frame].get()); | 1010 DCHECK(layout_test_control_map_[frame].get()); |
| 1009 return layout_test_control_map_[frame].get(); | 1011 return layout_test_control_map_[frame].get(); |
| 1010 } | 1012 } |
| 1011 | 1013 |
| 1012 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { | 1014 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { |
| 1013 layout_test_control_map_.erase(frame); | 1015 layout_test_control_map_.erase(frame); |
| 1014 } | 1016 } |
| 1015 | 1017 |
| 1016 } // namespace content | 1018 } // namespace content |
| OLD | NEW |