Chromium Code Reviews| 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(); | |
|
dgozman
2017/04/12 16:59:25
devtools_window_ = nullptr;
| |
| 518 } | 520 } |
| 519 | 521 |
| 520 void BlinkTestController::WebContentsDestroyed() { | 522 void BlinkTestController::WebContentsDestroyed() { |
| 521 DCHECK(CalledOnValidThread()); | 523 DCHECK(CalledOnValidThread()); |
| 522 printer_->AddErrorMessage("FAIL: main window was destroyed"); | 524 printer_->AddErrorMessage("FAIL: main window was destroyed"); |
| 523 DiscardMainWindow(); | 525 DiscardMainWindow(); |
| 524 } | 526 } |
| 525 | 527 |
| 526 void BlinkTestController::RenderProcessHostDestroyed( | 528 void BlinkTestController::RenderProcessHostDestroyed( |
| 527 RenderProcessHost* render_process_host) { | 529 RenderProcessHost* render_process_host) { |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( | 829 storage_partition->GetDOMStorageContext()->DeleteLocalStorage( |
| 828 content::LayoutTestDevToolsBindings::GetDevToolsPathAsURL("") | 830 content::LayoutTestDevToolsBindings::GetDevToolsPathAsURL("") |
| 829 .GetOrigin()); | 831 .GetOrigin()); |
| 830 } | 832 } |
| 831 | 833 |
| 832 void BlinkTestController::OnShowDevTools(const std::string& settings, | 834 void BlinkTestController::OnShowDevTools(const std::string& settings, |
| 833 const std::string& frontend_url) { | 835 const std::string& frontend_url) { |
| 834 if (!devtools_window_) { | 836 if (!devtools_window_) { |
| 835 ShellBrowserContext* browser_context = | 837 ShellBrowserContext* browser_context = |
| 836 ShellContentBrowserClient::Get()->browser_context(); | 838 ShellContentBrowserClient::Get()->browser_context(); |
| 837 devtools_window_.reset(content::Shell::CreateNewWindow( | 839 devtools_window_ = content::Shell::CreateNewWindow(browser_context, GURL(), |
| 838 browser_context, GURL(), nullptr, initial_size_)); | 840 nullptr, initial_size_); |
| 839 } | 841 } |
| 840 | 842 |
| 841 devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools( | 843 devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools( |
| 842 devtools_window_->web_contents(), main_window_->web_contents(), settings, | 844 devtools_window_->web_contents(), main_window_->web_contents(), settings, |
| 843 frontend_url)); | 845 frontend_url)); |
| 844 devtools_window_->web_contents()->GetRenderViewHost()->GetWidget()->Focus(); | 846 devtools_window_->web_contents()->GetRenderViewHost()->GetWidget()->Focus(); |
| 845 devtools_window_->web_contents()->Focus(); | 847 devtools_window_->web_contents()->Focus(); |
| 846 } | 848 } |
| 847 | 849 |
| 848 void BlinkTestController::OnEvaluateInDevTools( | 850 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(), | 909 Send(new ShellViewMsg_SessionHistory(render_view_host->GetRoutingID(), |
| 908 routing_ids, | 910 routing_ids, |
| 909 session_histories, | 911 session_histories, |
| 910 current_entry_indexes)); | 912 current_entry_indexes)); |
| 911 } | 913 } |
| 912 | 914 |
| 913 void BlinkTestController::OnCloseRemainingWindows() { | 915 void BlinkTestController::OnCloseRemainingWindows() { |
| 914 DevToolsAgentHost::DetachAllClients(); | 916 DevToolsAgentHost::DetachAllClients(); |
| 915 std::vector<Shell*> open_windows(Shell::windows()); | 917 std::vector<Shell*> open_windows(Shell::windows()); |
| 916 for (size_t i = 0; i < open_windows.size(); ++i) { | 918 for (size_t i = 0; i < open_windows.size(); ++i) { |
| 917 if (open_windows[i] != main_window_ && | 919 if (open_windows[i] != main_window_ && open_windows[i] != devtools_window_) |
| 918 open_windows[i] != devtools_window_.get()) | |
| 919 open_windows[i]->Close(); | 920 open_windows[i]->Close(); |
| 920 } | 921 } |
| 921 base::RunLoop().RunUntilIdle(); | 922 base::RunLoop().RunUntilIdle(); |
| 922 } | 923 } |
| 923 | 924 |
| 924 void BlinkTestController::OnResetDone() { | 925 void BlinkTestController::OnResetDone() { |
| 925 if (is_leak_detection_enabled_) { | 926 if (is_leak_detection_enabled_) { |
| 926 if (main_window_ && main_window_->web_contents()) { | 927 if (main_window_ && main_window_->web_contents()) { |
| 927 RenderViewHost* render_view_host = | 928 RenderViewHost* render_view_host = |
| 928 main_window_->web_contents()->GetRenderViewHost(); | 929 main_window_->web_contents()->GetRenderViewHost(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 } | 1008 } |
| 1008 DCHECK(layout_test_control_map_[frame].get()); | 1009 DCHECK(layout_test_control_map_[frame].get()); |
| 1009 return layout_test_control_map_[frame].get(); | 1010 return layout_test_control_map_[frame].get(); |
| 1010 } | 1011 } |
| 1011 | 1012 |
| 1012 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { | 1013 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { |
| 1013 layout_test_control_map_.erase(frame); | 1014 layout_test_control_map_.erase(frame); |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1016 } // namespace content | 1017 } // namespace content |
| OLD | NEW |