| 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 20 matching lines...) Expand all Loading... |
| 31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/notification_types.h" | 32 #include "content/public/browser/notification_types.h" |
| 33 #include "content/public/browser/render_frame_host.h" | 33 #include "content/public/browser/render_frame_host.h" |
| 34 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
| 35 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
| 36 #include "content/public/browser/render_widget_host.h" | 36 #include "content/public/browser/render_widget_host.h" |
| 37 #include "content/public/browser/render_widget_host_view.h" | 37 #include "content/public/browser/render_widget_host_view.h" |
| 38 #include "content/public/browser/service_worker_context.h" | 38 #include "content/public/browser/service_worker_context.h" |
| 39 #include "content/public/browser/storage_partition.h" | 39 #include "content/public/browser/storage_partition.h" |
| 40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 41 #include "content/public/common/associated_interface_provider.h" | |
| 42 #include "content/public/common/bindings_policy.h" | 41 #include "content/public/common/bindings_policy.h" |
| 43 #include "content/public/common/content_switches.h" | 42 #include "content/public/common/content_switches.h" |
| 44 #include "content/public/common/url_constants.h" | 43 #include "content/public/common/url_constants.h" |
| 45 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor
y.h" | 44 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor
y.h" |
| 46 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" | 45 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" |
| 47 #include "content/shell/browser/layout_test/layout_test_first_device_bluetooth_c
hooser.h" | 46 #include "content/shell/browser/layout_test/layout_test_first_device_bluetooth_c
hooser.h" |
| 48 #include "content/shell/browser/shell.h" | 47 #include "content/shell/browser/shell.h" |
| 49 #include "content/shell/browser/shell_browser_context.h" | 48 #include "content/shell/browser/shell_browser_context.h" |
| 50 #include "content/shell/browser/shell_content_browser_client.h" | 49 #include "content/shell/browser/shell_content_browser_client.h" |
| 51 #include "content/shell/browser/shell_devtools_frontend.h" | 50 #include "content/shell/browser/shell_devtools_frontend.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 test_url_ = test_url; | 273 test_url_ = test_url; |
| 275 else | 274 else |
| 276 test_url_ = LayoutTestDevToolsFrontend::MapJSTestURL(test_url); | 275 test_url_ = LayoutTestDevToolsFrontend::MapJSTestURL(test_url); |
| 277 did_send_initial_test_configuration_ = false; | 276 did_send_initial_test_configuration_ = false; |
| 278 printer_->reset(); | 277 printer_->reset(); |
| 279 frame_to_layout_dump_map_.clear(); | 278 frame_to_layout_dump_map_.clear(); |
| 280 render_process_host_observer_.RemoveAll(); | 279 render_process_host_observer_.RemoveAll(); |
| 281 all_observed_render_process_hosts_.clear(); | 280 all_observed_render_process_hosts_.clear(); |
| 282 main_window_render_process_hosts_.clear(); | 281 main_window_render_process_hosts_.clear(); |
| 283 accumulated_layout_test_runtime_flags_changes_.Clear(); | 282 accumulated_layout_test_runtime_flags_changes_.Clear(); |
| 284 layout_test_control_map_.clear(); | |
| 285 ShellBrowserContext* browser_context = | 283 ShellBrowserContext* browser_context = |
| 286 ShellContentBrowserClient::Get()->browser_context(); | 284 ShellContentBrowserClient::Get()->browser_context(); |
| 287 is_compositing_test_ = | 285 is_compositing_test_ = |
| 288 test_url_.spec().find("compositing/") != std::string::npos; | 286 test_url_.spec().find("compositing/") != std::string::npos; |
| 289 initial_size_ = Shell::GetShellDefaultSize(); | 287 initial_size_ = Shell::GetShellDefaultSize(); |
| 290 // The W3C SVG layout tests use a different size than the other layout tests. | 288 // The W3C SVG layout tests use a different size than the other layout tests. |
| 291 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos) | 289 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos) |
| 292 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); | 290 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); |
| 293 if (!main_window_) { | 291 if (!main_window_) { |
| 294 main_window_ = content::Shell::CreateNewWindow( | 292 main_window_ = content::Shell::CreateNewWindow( |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 current_pid_ = base::GetProcId(process_handle); | 599 current_pid_ = base::GetProcId(process_handle); |
| 602 } | 600 } |
| 603 | 601 |
| 604 // Is this the 1st time this renderer contains parts of the main test window? | 602 // Is this the 1st time this renderer contains parts of the main test window? |
| 605 if (main_window && | 603 if (main_window && |
| 606 !base::ContainsKey(main_window_render_process_hosts_, process)) { | 604 !base::ContainsKey(main_window_render_process_hosts_, process)) { |
| 607 main_window_render_process_hosts_.insert(process); | 605 main_window_render_process_hosts_.insert(process); |
| 608 | 606 |
| 609 // Make sure the new renderer process has a test configuration shared with | 607 // Make sure the new renderer process has a test configuration shared with |
| 610 // other renderers. | 608 // other renderers. |
| 611 mojom::ShellTestConfigurationPtr params = | 609 ShellTestConfiguration params; |
| 612 mojom::ShellTestConfiguration::New(); | 610 params.current_working_directory = current_working_directory_; |
| 613 params->enable_pixel_dumping = true; | 611 params.temp_path = temp_path_; |
| 614 params->allow_external_pages = false; | 612 params.test_url = test_url_; |
| 615 params->current_working_directory = current_working_directory_; | 613 params.enable_pixel_dumping = enable_pixel_dumping_; |
| 616 params->temp_path = temp_path_; | 614 params.allow_external_pages = |
| 617 params->test_url = test_url_; | |
| 618 params->enable_pixel_dumping = enable_pixel_dumping_; | |
| 619 params->allow_external_pages = | |
| 620 base::CommandLine::ForCurrentProcess()->HasSwitch( | 615 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 621 switches::kAllowExternalPages); | 616 switches::kAllowExternalPages); |
| 622 params->expected_pixel_hash = expected_pixel_hash_; | 617 params.expected_pixel_hash = expected_pixel_hash_; |
| 623 params->initial_size = initial_size_; | 618 params.initial_size = initial_size_; |
| 624 | 619 |
| 625 if (did_send_initial_test_configuration_) { | 620 if (did_send_initial_test_configuration_) { |
| 626 GetLayoutTestControlPtr(frame)->ReplicateTestConfiguration( | 621 frame->Send(new ShellViewMsg_ReplicateTestConfiguration( |
| 627 std::move(params)); | 622 frame->GetRoutingID(), params)); |
| 628 } else { | 623 } else { |
| 629 did_send_initial_test_configuration_ = true; | 624 did_send_initial_test_configuration_ = true; |
| 630 GetLayoutTestControlPtr(frame)->SetTestConfiguration(std::move(params)); | 625 frame->Send( |
| 626 new ShellViewMsg_SetTestConfiguration(frame->GetRoutingID(), params)); |
| 631 } | 627 } |
| 632 } | 628 } |
| 633 | 629 |
| 634 // Is this a previously unknown renderer process? | 630 // Is this a previously unknown renderer process? |
| 635 if (!render_process_host_observer_.IsObserving(process)) { | 631 if (!render_process_host_observer_.IsObserving(process)) { |
| 636 render_process_host_observer_.Add(process); | 632 render_process_host_observer_.Add(process); |
| 637 all_observed_render_process_hosts_.insert(process); | 633 all_observed_render_process_hosts_.insert(process); |
| 638 | 634 |
| 639 if (!main_window) { | 635 if (!main_window) { |
| 640 GetLayoutTestControlPtr(frame)->SetupSecondaryRenderer(); | 636 frame->Send( |
| 637 new ShellViewMsg_SetupSecondaryRenderer(frame->GetRoutingID())); |
| 641 } | 638 } |
| 642 | 639 |
| 643 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges( | 640 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges( |
| 644 accumulated_layout_test_runtime_flags_changes_)); | 641 accumulated_layout_test_runtime_flags_changes_)); |
| 645 } | 642 } |
| 646 } | 643 } |
| 647 | 644 |
| 648 void BlinkTestController::OnTestFinished() { | 645 void BlinkTestController::OnTestFinished() { |
| 649 test_phase_ = CLEAN_UP; | 646 test_phase_ = CLEAN_UP; |
| 650 if (!printer_->output_finished()) | 647 if (!printer_->output_finished()) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 printer_->PrintAudioFooter(); | 698 printer_->PrintAudioFooter(); |
| 702 } | 699 } |
| 703 | 700 |
| 704 void BlinkTestController::OnTextDump(const std::string& dump) { | 701 void BlinkTestController::OnTextDump(const std::string& dump) { |
| 705 printer_->PrintTextHeader(); | 702 printer_->PrintTextHeader(); |
| 706 printer_->PrintTextBlock(dump); | 703 printer_->PrintTextBlock(dump); |
| 707 printer_->PrintTextFooter(); | 704 printer_->PrintTextFooter(); |
| 708 } | 705 } |
| 709 | 706 |
| 710 void BlinkTestController::OnInitiateLayoutDump() { | 707 void BlinkTestController::OnInitiateLayoutDump() { |
| 711 int number_of_messages = 0; | 708 pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames( |
| 712 for (RenderFrameHost* rfh : main_window_->web_contents()->GetAllFrames()) { | 709 new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE)); |
| 713 if (!rfh->IsRenderFrameLive()) | |
| 714 continue; | |
| 715 | |
| 716 ++number_of_messages; | |
| 717 GetLayoutTestControlPtr(rfh)->LayoutDumpRequest(); | |
| 718 } | |
| 719 | |
| 720 pending_layout_dumps_ = number_of_messages; | |
| 721 } | 710 } |
| 722 | 711 |
| 723 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged( | 712 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged( |
| 724 int sender_process_host_id, | 713 int sender_process_host_id, |
| 725 const base::DictionaryValue& changed_layout_test_runtime_flags) { | 714 const base::DictionaryValue& changed_layout_test_runtime_flags) { |
| 726 // Stash the accumulated changes for future, not-yet-created renderers. | 715 // Stash the accumulated changes for future, not-yet-created renderers. |
| 727 accumulated_layout_test_runtime_flags_changes_.MergeDictionary( | 716 accumulated_layout_test_runtime_flags_changes_.MergeDictionary( |
| 728 &changed_layout_test_runtime_flags); | 717 &changed_layout_test_runtime_flags); |
| 729 | 718 |
| 730 // Propagate the changes to all the tracked renderer processes. | 719 // Propagate the changes to all the tracked renderer processes. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 event = BluetoothChooser::Event::RESCAN; | 947 event = BluetoothChooser::Event::RESCAN; |
| 959 } else { | 948 } else { |
| 960 printer_->AddErrorMessage(base::StringPrintf( | 949 printer_->AddErrorMessage(base::StringPrintf( |
| 961 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", | 950 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", |
| 962 event_name.c_str())); | 951 event_name.c_str())); |
| 963 return; | 952 return; |
| 964 } | 953 } |
| 965 bluetooth_chooser_factory_->SendEvent(event, argument); | 954 bluetooth_chooser_factory_->SendEvent(event, argument); |
| 966 } | 955 } |
| 967 | 956 |
| 968 mojom::LayoutTestControl* BlinkTestController::GetLayoutTestControlPtr( | |
| 969 RenderFrameHost* frame) { | |
| 970 if (layout_test_control_map_.find(frame) == layout_test_control_map_.end()) { | |
| 971 frame->GetRemoteAssociatedInterfaces()->GetInterface( | |
| 972 &layout_test_control_map_[frame]); | |
| 973 } | |
| 974 DCHECK(layout_test_control_map_[frame].get()); | |
| 975 return layout_test_control_map_[frame].get(); | |
| 976 } | |
| 977 | |
| 978 } // namespace content | 957 } // namespace content |
| OLD | NEW |