0

Rename [Blink|Web]TestController interfaces to better name

BlinkTestControl and WebTestControl names were originated
by the legacy IPC name. But, the meaning of between them is
ambiguous. So it may cause us a confusion. So, this CL
suggests to rename the interface name as below,

In .mojom files,
 - Rename WebTestControl to WebTestRenderThread interface
 - Rename BlinkTestControl to WebTestRenderFrame interface
 - Rename WebTestClient to WebTestControlHost interface
 - Rename BlinkTestDump to WebTestDump struct

In c++ files,
 - Rename BlinkTestController class to WebTestControlHost class
 - Rename BlinkTestResultPrinter class to WebTestResultPrinter class

Lastly, this CL moves BlinkTestControl, BlinkTestClient, and
BlinkTestDump mojo stuff from blink_test.mojom to web_test.mojom
after renaming. Then, this CL removes blink_test.mojom file and
all includes.

Bug: 866140, 1039247
Change-Id: I3c839dbb452a50a6c8287f93965417d9fa8659c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2113393
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763640}
This commit is contained in:
Gyuyoung Kim
2020-04-29 00:53:00 +00:00
committed by Commit Bot
parent 568d04f2fb
commit 26c7bc9921
24 changed files with 519 additions and 521 deletions

@ -5192,7 +5192,7 @@ void WebContentsImpl::OnPluginCrashed(RenderFrameHostImpl* source,
const base::FilePath& plugin_path,
base::ProcessId plugin_pid) {
// TODO(nick): Eliminate the |plugin_pid| parameter, which can't be trusted,
// and is only used by BlinkTestController.
// and is only used by WebTestControlHost.
for (auto& observer : observers_)
observer.PluginCrashed(plugin_path, plugin_pid);
}

@ -47,7 +47,6 @@ source_set("android_shell_descriptors") {
mojom("web_test_common_mojom") {
sources = [
"common/web_test/blink_test.mojom",
"common/web_test/fake_bluetooth_chooser.mojom",
"common/web_test/web_test.mojom",
"common/web_test/web_test_bluetooth_fake_adapter_setter.mojom",
@ -292,8 +291,6 @@ static_library("content_shell_lib") {
"browser/shell_web_contents_view_delegate_android.cc",
"browser/shell_web_contents_view_delegate_creator.h",
"browser/shell_web_contents_view_delegate_mac.mm",
"browser/web_test/blink_test_controller.cc",
"browser/web_test/blink_test_controller.h",
"browser/web_test/devtools_protocol_test_bindings.cc",
"browser/web_test/devtools_protocol_test_bindings.h",
"browser/web_test/fake_bluetooth_chooser.cc",
@ -338,6 +335,8 @@ static_library("content_shell_lib") {
"browser/web_test/web_test_content_browser_client.h",
"browser/web_test/web_test_content_index_provider.cc",
"browser/web_test/web_test_content_index_provider.h",
"browser/web_test/web_test_control_host.cc",
"browser/web_test/web_test_control_host.h",
"browser/web_test/web_test_devtools_bindings.cc",
"browser/web_test/web_test_devtools_bindings.h",
"browser/web_test/web_test_download_manager_delegate.cc",

@ -36,10 +36,10 @@
#include "content/shell/browser/shell_content_browser_client.h"
#include "content/shell/browser/shell_devtools_frontend.h"
#include "content/shell/browser/shell_javascript_dialog_manager.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/fake_bluetooth_scanning_prompt.h"
#include "content/shell/browser/web_test/secondary_test_window_observer.h"
#include "content/shell/browser/web_test/web_test_bluetooth_chooser_factory.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include "content/shell/browser/web_test/web_test_devtools_bindings.h"
#include "content/shell/browser/web_test/web_test_javascript_dialog_manager.h"
#include "content/shell/common/shell_switches.h"
@ -427,7 +427,7 @@ WebContents* Shell::OpenURLFromTab(WebContents* source,
case WindowOpenDisposition::OFF_THE_RECORD:
// TODO(lukasza): Investigate if some web tests might need support for
// SAVE_TO_DISK disposition. This would probably require that
// BlinkTestController always sets up and cleans up a temporary directory
// WebTestControlHost always sets up and cleans up a temporary directory
// as the default downloads destinations for the duration of a test.
case WindowOpenDisposition::SAVE_TO_DISK:
// Ignoring requests with disposition == IGNORE_ACTION...
@ -528,9 +528,9 @@ JavaScriptDialogManager* Shell::GetJavaScriptDialogManager(
std::unique_ptr<BluetoothChooser> Shell::RunBluetoothChooser(
RenderFrameHost* frame,
const BluetoothChooser::EventHandler& event_handler) {
BlinkTestController* blink_test_controller = BlinkTestController::Get();
if (blink_test_controller && switches::IsRunWebTestsSwitchPresent())
return blink_test_controller->RunBluetoothChooser(frame, event_handler);
WebTestControlHost* web_test_control_host = WebTestControlHost::Get();
if (web_test_control_host && switches::IsRunWebTestsSwitchPresent())
return web_test_control_host->RunBluetoothChooser(frame, event_handler);
return nullptr;
}
@ -557,9 +557,9 @@ void Shell::RendererUnresponsive(
WebContents* source,
RenderWidgetHost* render_widget_host,
base::RepeatingClosure hang_monitor_restarter) {
BlinkTestController* blink_test_controller = BlinkTestController::Get();
if (blink_test_controller && switches::IsRunWebTestsSwitchPresent())
blink_test_controller->RendererUnresponsive();
WebTestControlHost* web_test_control_host = WebTestControlHost::Get();
if (web_test_control_host && switches::IsRunWebTestsSwitchPresent())
web_test_control_host->RendererUnresponsive();
}
void Shell::ActivateContents(WebContents* contents) {
@ -589,10 +589,10 @@ bool Shell::ShouldAllowRunningInsecureContent(WebContents* web_contents,
const url::Origin& origin,
const GURL& resource_url) {
bool allowed_by_test = false;
BlinkTestController* blink_test_controller = BlinkTestController::Get();
if (blink_test_controller && switches::IsRunWebTestsSwitchPresent()) {
WebTestControlHost* web_test_control_host = WebTestControlHost::Get();
if (web_test_control_host && switches::IsRunWebTestsSwitchPresent()) {
const base::DictionaryValue& test_flags =
blink_test_controller->accumulated_web_test_runtime_flags_changes();
web_test_control_host->accumulated_web_test_runtime_flags_changes();
test_flags.GetBoolean("running_insecure_content_allowed", &allowed_by_test);
}

@ -117,7 +117,7 @@ class Shell : public WebContentsDelegate,
// is destroyed.
static void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure);
// Used by the BlinkTestController to stop the message loop before closing all
// Used by the WebTestControlHost to stop the message loop before closing all
// windows, for specific tests. Has no effect if the loop is already quitting.
static void QuitMainMessageLoopForTesting();

@ -5,23 +5,23 @@
#include "content/shell/browser/web_test/secondary_test_window_observer.h"
#include "content/public/browser/render_frame_host.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
namespace content {
SecondaryTestWindowObserver::SecondaryTestWindowObserver(
WebContents* web_contents)
: WebContentsObserver(web_contents) {
BlinkTestController* blink_test_controller = BlinkTestController::Get();
if (!blink_test_controller)
WebTestControlHost* web_test_control_host = WebTestControlHost::Get();
if (!web_test_control_host)
return;
DCHECK(!blink_test_controller->IsMainWindow(web_contents));
DCHECK(!web_test_control_host->IsMainWindow(web_contents));
// Ensure that any preexisting frames (likely just the main frame) are handled
// as well.
for (RenderFrameHost* frame : web_contents->GetAllFrames()) {
if (frame->IsRenderFrameLive())
blink_test_controller->HandleNewRenderFrameHost(frame);
web_test_control_host->HandleNewRenderFrameHost(frame);
}
}
@ -29,12 +29,12 @@ SecondaryTestWindowObserver::~SecondaryTestWindowObserver() {}
void SecondaryTestWindowObserver::RenderFrameCreated(
RenderFrameHost* render_frame_host) {
BlinkTestController* blink_test_controller = BlinkTestController::Get();
if (!blink_test_controller)
WebTestControlHost* web_test_control_host = WebTestControlHost::Get();
if (!web_test_control_host)
return;
DCHECK(!blink_test_controller->IsMainWindow(
DCHECK(!web_test_control_host->IsMainWindow(
WebContents::FromRenderFrameHost(render_frame_host)));
blink_test_controller->HandleNewRenderFrameHost(render_frame_host);
web_test_control_host->HandleNewRenderFrameHost(render_frame_host);
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(SecondaryTestWindowObserver)

@ -30,9 +30,9 @@
#include "content/public/test/ppapi_test_utils.h"
#include "content/public/test/web_test_support_browser.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/test_info_extractor.h"
#include "content/shell/browser/web_test/web_test_browser_main_platform_support.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include "content/shell/common/shell_switches.h"
#include "content/shell/common/web_test/web_test_switches.h"
#include "gpu/config/gpu_switches.h"
@ -50,20 +50,20 @@ namespace content {
namespace {
bool RunOneTest(const content::TestInfo& test_info,
content::BlinkTestController* blink_test_controller,
content::WebTestControlHost* web_test_control_host,
content::BrowserMainRunner* main_runner) {
DCHECK(blink_test_controller);
DCHECK(web_test_control_host);
if (!blink_test_controller->PrepareForWebTest(test_info))
if (!web_test_control_host->PrepareForWebTest(test_info))
return false;
main_runner->Run();
return blink_test_controller->ResetBrowserAfterWebTest();
return web_test_control_host->ResetBrowserAfterWebTest();
}
void RunTests(content::BrowserMainRunner* main_runner) {
content::BlinkTestController test_controller;
content::WebTestControlHost test_controller;
{
// We're outside of the message loop here, and this is a test.
base::ScopedAllowBlockingForTesting allow_blocking;

@ -21,10 +21,10 @@
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/storage_partition.h"
#include "content/shell/browser/shell_content_browser_client.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/web_test_browser_context.h"
#include "content/shell/browser/web_test/web_test_content_browser_client.h"
#include "content/shell/browser/web_test/web_test_content_index_provider.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include "content/shell/browser/web_test/web_test_permission_manager.h"
#include "content/shell/common/web_test/web_test_constants.h"
#include "content/test/mock_platform_notification_service.h"
@ -206,7 +206,7 @@ void WebTestClientImpl::SetPermission(const std::string& name,
void WebTestClientImpl::WebTestRuntimeFlagsChanged(
base::Value changed_web_test_runtime_flags) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!BlinkTestController::Get())
if (!WebTestControlHost::Get())
return;
base::DictionaryValue* changed_web_test_runtime_flags_dictionary = nullptr;
@ -214,7 +214,7 @@ void WebTestClientImpl::WebTestRuntimeFlagsChanged(
&changed_web_test_runtime_flags_dictionary);
DCHECK(ok);
BlinkTestController::Get()->OnWebTestRuntimeFlagsChanged(
WebTestControlHost::Get()->OnWebTestRuntimeFlagsChanged(
render_process_id_, *changed_web_test_runtime_flags_dictionary);
}

@ -30,7 +30,6 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/service_names.mojom.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/fake_bluetooth_chooser.h"
#include "content/shell/browser/web_test/fake_bluetooth_chooser_factory.h"
#include "content/shell/browser/web_test/fake_bluetooth_delegate.h"
@ -39,10 +38,10 @@
#include "content/shell/browser/web_test/web_test_browser_context.h"
#include "content/shell/browser/web_test/web_test_browser_main_parts.h"
#include "content/shell/browser/web_test/web_test_client_impl.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include "content/shell/browser/web_test/web_test_permission_manager.h"
#include "content/shell/browser/web_test/web_test_tts_controller_delegate.h"
#include "content/shell/browser/web_test/web_test_tts_platform.h"
#include "content/shell/common/web_test/blink_test.mojom.h"
#include "content/shell/common/web_test/web_test_bluetooth_fake_adapter_setter.mojom.h"
#include "content/shell/common/web_test/web_test_switches.h"
#include "content/test/data/mojo_web_test_helper_test.mojom.h"
@ -243,10 +242,10 @@ void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
ui_task_runner);
associated_registry->AddInterface(
base::BindRepeating(&WebTestContentBrowserClient::BindBlinkTestController,
base::BindRepeating(&WebTestContentBrowserClient::BindWebTestControlHost,
base::Unretained(this)));
associated_registry->AddInterface(base::BindRepeating(
&WebTestContentBrowserClient::BindWebTestController,
&WebTestContentBrowserClient::BindWebTestClient,
render_process_host->GetID(),
BrowserContext::GetDefaultStoragePartition(browser_context())));
}
@ -276,8 +275,8 @@ void WebTestContentBrowserClient::BindPermissionAutomation(
void WebTestContentBrowserClient::OverrideWebkitPrefs(
RenderViewHost* render_view_host,
WebPreferences* prefs) {
if (BlinkTestController::Get())
BlinkTestController::Get()->OverrideWebkitPrefs(prefs);
if (WebTestControlHost::Get())
WebTestControlHost::Get()->OverrideWebkitPrefs(prefs);
}
void WebTestContentBrowserClient::AppendExtraCommandLineSwitches(
@ -497,14 +496,15 @@ void WebTestContentBrowserClient::CreateFakeBluetoothChooserFactory(
FakeBluetoothChooserFactory::Create(std::move(receiver));
}
void WebTestContentBrowserClient::BindBlinkTestController(
mojo::PendingAssociatedReceiver<mojom::BlinkTestClient> receiver) {
if (BlinkTestController::Get())
BlinkTestController::Get()->AddBlinkTestClientReceiver(std::move(receiver));
void WebTestContentBrowserClient::BindWebTestControlHost(
mojo::PendingAssociatedReceiver<mojom::WebTestControlHost> receiver) {
if (WebTestControlHost::Get())
WebTestControlHost::Get()->AddWebTestControlHostReceiver(
std::move(receiver));
}
// static
void WebTestContentBrowserClient::BindWebTestController(
void WebTestContentBrowserClient::BindWebTestClient(
int render_process_id,
StoragePartition* partition,
mojo::PendingAssociatedReceiver<mojom::WebTestClient> receiver) {

@ -12,7 +12,6 @@
#include "build/build_config.h"
#include "content/public/common/client_hints.mojom.h"
#include "content/shell/browser/shell_content_browser_client.h"
#include "content/shell/common/web_test/blink_test.mojom-forward.h"
#include "content/shell/common/web_test/fake_bluetooth_chooser.mojom-forward.h"
#include "content/shell/common/web_test/web_test.mojom-forward.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
@ -127,10 +126,10 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
void BindPermissionAutomation(
mojo::PendingReceiver<blink::test::mojom::PermissionAutomation> receiver);
void BindBlinkTestController(
mojo::PendingAssociatedReceiver<mojom::BlinkTestClient> receiver);
void BindWebTestControlHost(
mojo::PendingAssociatedReceiver<mojom::WebTestControlHost> receiver);
static void BindWebTestController(
static void BindWebTestClient(
int render_process_id,
StoragePartition* partition,
mojo::PendingAssociatedReceiver<mojom::WebTestClient> receiver);

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include <stddef.h>
#include <string.h>
@ -159,12 +159,12 @@ std::string DumpHistoryForWebContents(WebContents* web_contents) {
}
std::vector<std::string> DumpTitleWasSet(WebContents* web_contents) {
base::Optional<bool> load = BlinkTestController::Get()
base::Optional<bool> load = WebTestControlHost::Get()
->accumulated_web_test_runtime_flags_changes()
.FindBoolPath("dump_frame_load_callbacks");
base::Optional<bool> title_changed =
BlinkTestController::Get()
WebTestControlHost::Get()
->accumulated_web_test_runtime_flags_changes()
.FindBoolPath("dump_title_changes");
@ -187,7 +187,7 @@ std::vector<std::string> DumpTitleWasSet(WebContents* web_contents) {
std::string DumpFailLoad(WebContents* web_contents,
RenderFrameHost* render_frame_host) {
base::Optional<bool> result =
BlinkTestController::Get()
WebTestControlHost::Get()
->accumulated_web_test_runtime_flags_changes()
.FindBoolPath("dump_frame_load_callbacks");
@ -276,23 +276,21 @@ void ApplyWebTestDefaultPreferences(WebPreferences* prefs) {
} // namespace
// BlinkTestResultPrinter ----------------------------------------------------
// WebTestResultPrinter ----------------------------------------------------
BlinkTestResultPrinter::BlinkTestResultPrinter(std::ostream* output,
std::ostream* error)
WebTestResultPrinter::WebTestResultPrinter(std::ostream* output,
std::ostream* error)
: state_(DURING_TEST),
capture_text_only_(false),
encode_binary_data_(false),
output_(output),
error_(error) {}
BlinkTestResultPrinter::~BlinkTestResultPrinter() {}
void BlinkTestResultPrinter::StartStateDump() {
void WebTestResultPrinter::StartStateDump() {
state_ = DURING_STATE_DUMP;
}
void BlinkTestResultPrinter::PrintTextHeader() {
void WebTestResultPrinter::PrintTextHeader() {
if (state_ != DURING_STATE_DUMP)
return;
if (!capture_text_only_)
@ -300,13 +298,13 @@ void BlinkTestResultPrinter::PrintTextHeader() {
state_ = IN_TEXT_BLOCK;
}
void BlinkTestResultPrinter::PrintTextBlock(const std::string& block) {
void WebTestResultPrinter::PrintTextBlock(const std::string& block) {
if (state_ != IN_TEXT_BLOCK)
return;
*output_ << block;
}
void BlinkTestResultPrinter::PrintTextFooter() {
void WebTestResultPrinter::PrintTextFooter() {
if (state_ != IN_TEXT_BLOCK)
return;
if (!capture_text_only_) {
@ -316,9 +314,8 @@ void BlinkTestResultPrinter::PrintTextFooter() {
state_ = IN_IMAGE_BLOCK;
}
void BlinkTestResultPrinter::PrintImageHeader(
const std::string& actual_hash,
const std::string& expected_hash) {
void WebTestResultPrinter::PrintImageHeader(const std::string& actual_hash,
const std::string& expected_hash) {
if (state_ != IN_IMAGE_BLOCK || capture_text_only_)
return;
*output_ << "\nActualHash: " << actual_hash << "\n";
@ -326,7 +323,7 @@ void BlinkTestResultPrinter::PrintImageHeader(
*output_ << "\nExpectedHash: " << expected_hash << "\n";
}
void BlinkTestResultPrinter::PrintImageBlock(
void WebTestResultPrinter::PrintImageBlock(
const std::vector<unsigned char>& png_image) {
if (state_ != IN_IMAGE_BLOCK || capture_text_only_)
return;
@ -341,7 +338,7 @@ void BlinkTestResultPrinter::PrintImageBlock(
png_image.size());
}
void BlinkTestResultPrinter::PrintImageFooter() {
void WebTestResultPrinter::PrintImageFooter() {
if (state_ != IN_IMAGE_BLOCK)
return;
if (!capture_text_only_) {
@ -351,14 +348,14 @@ void BlinkTestResultPrinter::PrintImageFooter() {
state_ = AFTER_TEST;
}
void BlinkTestResultPrinter::PrintAudioHeader() {
void WebTestResultPrinter::PrintAudioHeader() {
DCHECK_EQ(state_, DURING_STATE_DUMP);
if (!capture_text_only_)
*output_ << "Content-Type: audio/wav\n";
state_ = IN_AUDIO_BLOCK;
}
void BlinkTestResultPrinter::PrintAudioBlock(
void WebTestResultPrinter::PrintAudioBlock(
const std::vector<unsigned char>& audio_data) {
if (state_ != IN_AUDIO_BLOCK || capture_text_only_)
return;
@ -372,7 +369,7 @@ void BlinkTestResultPrinter::PrintAudioBlock(
audio_data.size());
}
void BlinkTestResultPrinter::PrintAudioFooter() {
void WebTestResultPrinter::PrintAudioFooter() {
if (state_ != IN_AUDIO_BLOCK)
return;
if (!capture_text_only_) {
@ -382,21 +379,21 @@ void BlinkTestResultPrinter::PrintAudioFooter() {
state_ = IN_IMAGE_BLOCK;
}
void BlinkTestResultPrinter::AddMessageToStderr(const std::string& message) {
void WebTestResultPrinter::AddMessageToStderr(const std::string& message) {
*error_ << message;
}
void BlinkTestResultPrinter::AddMessage(const std::string& message) {
void WebTestResultPrinter::AddMessage(const std::string& message) {
AddMessageRaw(message + "\n");
}
void BlinkTestResultPrinter::AddMessageRaw(const std::string& message) {
void WebTestResultPrinter::AddMessageRaw(const std::string& message) {
if (state_ != DURING_TEST)
return;
*output_ << message;
}
void BlinkTestResultPrinter::AddErrorMessage(const std::string& message) {
void WebTestResultPrinter::AddErrorMessage(const std::string& message) {
if (!capture_text_only_)
*error_ << message << "\n";
if (state_ != DURING_TEST && state_ != DURING_STATE_DUMP)
@ -407,7 +404,7 @@ void BlinkTestResultPrinter::AddErrorMessage(const std::string& message) {
PrintImageFooter();
}
void BlinkTestResultPrinter::PrintEncodedBinaryData(
void WebTestResultPrinter::PrintEncodedBinaryData(
const std::vector<unsigned char>& data) {
*output_ << "Content-Transfer-Encoding: base64\n";
@ -420,7 +417,7 @@ void BlinkTestResultPrinter::PrintEncodedBinaryData(
output_->write(data_base64.c_str(), data_base64.length());
}
void BlinkTestResultPrinter::CloseStderr() {
void WebTestResultPrinter::CloseStderr() {
if (state_ != AFTER_TEST)
return;
if (!capture_text_only_) {
@ -429,16 +426,16 @@ void BlinkTestResultPrinter::CloseStderr() {
}
}
// BlinkTestController -------------------------------------------------------
// WebTestControlHost -------------------------------------------------------
BlinkTestController* BlinkTestController::instance_ = nullptr;
WebTestControlHost* WebTestControlHost::instance_ = nullptr;
// static
BlinkTestController* BlinkTestController::Get() {
WebTestControlHost* WebTestControlHost::Get() {
return instance_;
}
BlinkTestController::BlinkTestController()
WebTestControlHost::WebTestControlHost()
: main_window_(nullptr),
secondary_window_(nullptr),
test_phase_(BETWEEN_TESTS),
@ -456,7 +453,7 @@ BlinkTestController::BlinkTestController()
crash_when_leak_found_ = switchValue == switches::kCrashOnFailure;
}
printer_.reset(new BlinkTestResultPrinter(&std::cout, &std::cerr));
printer_ = std::make_unique<WebTestResultPrinter>(&std::cout, &std::cerr);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEncodeBinary))
printer_->set_encode_binary_data(true);
@ -474,7 +471,7 @@ BlinkTestController::BlinkTestController()
ResetBrowserAfterWebTest();
}
BlinkTestController::~BlinkTestController() {
WebTestControlHost::~WebTestControlHost() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
CHECK(instance_ == this);
CHECK(test_phase_ == BETWEEN_TESTS);
@ -483,7 +480,7 @@ BlinkTestController::~BlinkTestController() {
instance_ = nullptr;
}
bool BlinkTestController::PrepareForWebTest(const TestInfo& test_info) {
bool WebTestControlHost::PrepareForWebTest(const TestInfo& test_info) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
test_phase_ = DURING_TEST;
current_working_directory_ = test_info.current_working_directory;
@ -501,14 +498,14 @@ bool BlinkTestController::PrepareForWebTest(const TestInfo& test_info) {
printer_->set_capture_text_only(false);
printer_->reset();
frame_to_layout_dump_map_.clear();
render_process_host_observer_.RemoveAll();
all_observed_render_process_hosts_.clear();
main_window_render_process_hosts_.clear();
main_window_render_view_hosts_.clear();
web_test_render_frame_map_.clear();
web_test_render_thread_map_.clear();
accumulated_web_test_runtime_flags_changes_.Clear();
blink_test_control_map_.clear();
web_test_control_map_.clear();
main_window_render_view_hosts_.clear();
main_window_render_process_hosts_.clear();
all_observed_render_process_hosts_.clear();
render_process_host_observer_.RemoveAll();
frame_to_layout_dump_map_.clear();
ShellBrowserContext* browser_context =
ShellContentBrowserClient::Get()->browser_context();
@ -575,7 +572,7 @@ bool BlinkTestController::PrepareForWebTest(const TestInfo& test_info) {
->GetRenderViewHost()
->GetWidget()
->FlushForTesting();
GetBlinkTestControlRemote(
GetWebTestRenderFrameRemote(
main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
.FlushForTesting();
@ -605,7 +602,7 @@ bool BlinkTestController::PrepareForWebTest(const TestInfo& test_info) {
return true;
}
bool BlinkTestController::ResetBrowserAfterWebTest() {
bool WebTestControlHost::ResetBrowserAfterWebTest() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
printer_->PrintTextFooter();
printer_->PrintImageFooter();
@ -642,11 +639,11 @@ bool BlinkTestController::ResetBrowserAfterWebTest() {
return true;
}
void BlinkTestController::SetTempPath(const base::FilePath& temp_path) {
void WebTestControlHost::SetTempPath(const base::FilePath& temp_path) {
temp_path_ = temp_path;
}
void BlinkTestController::RendererUnresponsive() {
void WebTestControlHost::RendererUnresponsive() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableHangMonitor)) {
@ -654,7 +651,7 @@ void BlinkTestController::RendererUnresponsive() {
}
}
void BlinkTestController::OverrideWebkitPrefs(WebPreferences* prefs) {
void WebTestControlHost::OverrideWebkitPrefs(WebPreferences* prefs) {
if (should_override_prefs_) {
*prefs = prefs_;
} else {
@ -668,7 +665,7 @@ void BlinkTestController::OverrideWebkitPrefs(WebPreferences* prefs) {
}
}
void BlinkTestController::OpenURL(const GURL& url) {
void WebTestControlHost::OpenURL(const GURL& url) {
if (test_phase_ != DURING_TEST)
return;
@ -677,7 +674,7 @@ void BlinkTestController::OpenURL(const GURL& url) {
gfx::Size());
}
void BlinkTestController::InitiateLayoutDump() {
void WebTestControlHost::InitiateLayoutDump() {
// There should be at most 1 layout dump in progress at any given time.
DCHECK_EQ(0, pending_layout_dumps_);
@ -687,16 +684,16 @@ void BlinkTestController::InitiateLayoutDump() {
continue;
++number_of_messages;
GetBlinkTestControlRemote(rfh)->DumpFrameLayout(
base::BindOnce(&BlinkTestController::OnDumpFrameLayoutResponse,
GetWebTestRenderFrameRemote(rfh)->DumpFrameLayout(
base::BindOnce(&WebTestControlHost::OnDumpFrameLayoutResponse,
weak_factory_.GetWeakPtr(), rfh->GetFrameTreeNodeId()));
}
pending_layout_dumps_ = number_of_messages;
}
void BlinkTestController::InitiateCaptureDump(bool capture_navigation_history,
bool capture_pixels) {
void WebTestControlHost::InitiateCaptureDump(bool capture_navigation_history,
bool capture_pixels) {
if (test_phase_ != DURING_TEST)
return;
@ -739,34 +736,32 @@ void BlinkTestController::InitiateCaptureDump(bool capture_navigation_history,
EnqueueSurfaceCopyRequest();
} else {
CompositeAllFramesThen(
base::BindOnce(&BlinkTestController::EnqueueSurfaceCopyRequest,
base::BindOnce(&WebTestControlHost::EnqueueSurfaceCopyRequest,
weak_factory_.GetWeakPtr()));
}
}
RenderFrameHost* rfh = main_window_->web_contents()->GetMainFrame();
printer_->StartStateDump();
GetBlinkTestControlRemote(rfh)->CaptureDump(
base::BindOnce(&BlinkTestController::OnCaptureDumpCompleted,
weak_factory_.GetWeakPtr()));
GetWebTestRenderFrameRemote(rfh)->CaptureDump(base::BindOnce(
&WebTestControlHost::OnCaptureDumpCompleted, weak_factory_.GetWeakPtr()));
}
void BlinkTestController::TestFinishedInSecondaryRenderer() {
GetBlinkTestControlRemote(
void WebTestControlHost::TestFinishedInSecondaryRenderer() {
GetWebTestRenderFrameRemote(
main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->FinishTestInMainWindow();
}
// Enqueue an image copy output request.
void BlinkTestController::EnqueueSurfaceCopyRequest() {
void WebTestControlHost::EnqueueSurfaceCopyRequest() {
auto* rwhv = main_window_->web_contents()->GetRenderWidgetHostView();
rwhv->CopyFromSurface(
gfx::Rect(), gfx::Size(),
base::BindOnce(&BlinkTestController::OnPixelDumpCaptured,
weak_factory_.GetWeakPtr()));
rwhv->CopyFromSurface(gfx::Rect(), gfx::Size(),
base::BindOnce(&WebTestControlHost::OnPixelDumpCaptured,
weak_factory_.GetWeakPtr()));
}
void BlinkTestController::CompositeAllFramesThen(
void WebTestControlHost::CompositeAllFramesThen(
base::OnceCallback<void()> callback) {
// Only allow a single call to CompositeAllFramesThen(), without a call to
// ResetBrowserAfterWebTest() in between. More than once risks overlapping
@ -788,7 +783,7 @@ void BlinkTestController::CompositeAllFramesThen(
CompositeNodeQueueThen(std::move(callback));
}
void BlinkTestController::CompositeNodeQueueThen(
void WebTestControlHost::CompositeNodeQueueThen(
base::OnceCallback<void()> callback) {
// Frames can get freed somewhere else while a CompositeWithRaster is taking
// place. Therefore, we need to double-check that this frame pointer is
@ -813,19 +808,19 @@ void BlinkTestController::CompositeNodeQueueThen(
next_node_host = nullptr; // This one is now gone
}
} while (!next_node_host || !next_node_host->IsRenderFrameLive());
GetBlinkTestControlRemote(next_node_host)
GetWebTestRenderFrameRemote(next_node_host)
->CompositeWithRaster(
base::BindOnce(&BlinkTestController::CompositeNodeQueueThen,
base::BindOnce(&WebTestControlHost::CompositeNodeQueueThen,
weak_factory_.GetWeakPtr(), std::move(callback)));
}
void BlinkTestController::BuildDepthFirstQueue(Node* node) {
void WebTestControlHost::BuildDepthFirstQueue(Node* node) {
for (auto* child : node->children)
BuildDepthFirstQueue(child);
composite_all_frames_node_queue_.push(node);
}
BlinkTestController::Node* BlinkTestController::BuildFrameTree(
WebTestControlHost::Node* WebTestControlHost::BuildFrameTree(
WebContents* web_contents) {
// Returns a Node for a given RenderFrameHost, or nullptr if doesn't exist.
auto node_for_frame = [this](RenderFrameHost* rfh) {
@ -890,11 +885,11 @@ BlinkTestController::Node* BlinkTestController::BuildFrameTree(
return outer_root;
}
bool BlinkTestController::IsMainWindow(WebContents* web_contents) const {
bool WebTestControlHost::IsMainWindow(WebContents* web_contents) const {
return main_window_ && web_contents == main_window_->web_contents();
}
std::unique_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser(
std::unique_ptr<BluetoothChooser> WebTestControlHost::RunBluetoothChooser(
RenderFrameHost* frame,
const BluetoothChooser::EventHandler& event_handler) {
// TODO(https://crbug.com/509038): Remove |bluetooth_chooser_factory_| once
@ -916,24 +911,24 @@ std::unique_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser(
return std::make_unique<WebTestFirstDeviceBluetoothChooser>(event_handler);
}
void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) {
void WebTestControlHost::PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
printer_->AddErrorMessage(
base::StringPrintf("#CRASHED - plugin (pid %" CrPRIdPid ")", plugin_pid));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(base::IgnoreResult(
&BlinkTestController::DiscardMainWindow),
weak_factory_.GetWeakPtr()));
FROM_HERE,
base::BindOnce(base::IgnoreResult(&WebTestControlHost::DiscardMainWindow),
weak_factory_.GetWeakPtr()));
}
void BlinkTestController::RenderFrameCreated(
void WebTestControlHost::RenderFrameCreated(
RenderFrameHost* render_frame_host) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
HandleNewRenderFrameHost(render_frame_host);
}
void BlinkTestController::TitleWasSet(NavigationEntry* entry) {
void WebTestControlHost::TitleWasSet(NavigationEntry* entry) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::vector<std::string> logs = DumpTitleWasSet(main_window_->web_contents());
if (logs.empty())
@ -942,9 +937,9 @@ void BlinkTestController::TitleWasSet(NavigationEntry* entry) {
printer_->AddMessage(log);
}
void BlinkTestController::DidFailLoad(RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) {
void WebTestControlHost::DidFailLoad(RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
std::string log =
DumpFailLoad(main_window_->web_contents(), render_frame_host);
@ -953,13 +948,13 @@ void BlinkTestController::DidFailLoad(RenderFrameHost* render_frame_host,
printer_->AddMessage(log);
}
void BlinkTestController::WebContentsDestroyed() {
void WebTestControlHost::WebContentsDestroyed() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
printer_->AddErrorMessage("FAIL: main window was destroyed");
DiscardMainWindow();
}
void BlinkTestController::DidUpdateFaviconURL(
void WebTestControlHost::DidUpdateFaviconURL(
const std::vector<blink::mojom::FaviconURLPtr>& candidates) {
bool should_dump_icon_changes = false;
accumulated_web_test_runtime_flags_changes_.GetBoolean(
@ -970,15 +965,15 @@ void BlinkTestController::DidUpdateFaviconURL(
}
}
void BlinkTestController::RenderProcessHostDestroyed(
void WebTestControlHost::RenderProcessHostDestroyed(
RenderProcessHost* render_process_host) {
render_process_host_observer_.Remove(render_process_host);
all_observed_render_process_hosts_.erase(render_process_host);
web_test_control_map_.erase(render_process_host);
web_test_render_thread_map_.erase(render_process_host);
main_window_render_process_hosts_.erase(render_process_host);
}
void BlinkTestController::RenderProcessExited(
void WebTestControlHost::RenderProcessExited(
RenderProcessHost* render_process_host,
const ChildProcessTerminationInfo& info) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
@ -1006,9 +1001,9 @@ void BlinkTestController::RenderProcessExited(
}
}
void BlinkTestController::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
void WebTestControlHost::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
switch (type) {
case NOTIFICATION_RENDERER_PROCESS_CREATED: {
@ -1030,14 +1025,14 @@ void BlinkTestController::Observe(int type,
}
}
void BlinkTestController::OnGpuProcessCrashed(
void WebTestControlHost::OnGpuProcessCrashed(
base::TerminationStatus exit_code) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
printer_->AddErrorMessage("#CRASHED - gpu");
DiscardMainWindow();
}
void BlinkTestController::DiscardMainWindow() {
void WebTestControlHost::DiscardMainWindow() {
// If we're running a test, we need to close all windows and exit the message
// loop. Otherwise, we're already outside of the message loop, and we just
// discard the main window.
@ -1055,7 +1050,7 @@ void BlinkTestController::DiscardMainWindow() {
current_pid_ = base::kNullProcessId;
}
void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) {
void WebTestControlHost::HandleNewRenderFrameHost(RenderFrameHost* frame) {
RenderProcessHost* process_host = frame->GetProcess();
RenderViewHost* view_host = frame->GetRenderViewHost();
bool main_window =
@ -1085,8 +1080,8 @@ void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) {
// Make sure the new renderer process_host has a test configuration shared
// with other renderers.
mojom::ShellTestConfigurationPtr params =
mojom::ShellTestConfiguration::New();
mojom::WebTestRunTestConfigurationPtr params =
mojom::WebTestRunTestConfiguration::New();
params->allow_external_pages = false;
params->current_working_directory = current_working_directory_;
params->temp_path = temp_path_;
@ -1099,11 +1094,12 @@ void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) {
params->protocol_mode = protocol_mode_;
if (did_send_initial_test_configuration_) {
GetBlinkTestControlRemote(frame)->ReplicateTestConfiguration(
GetWebTestRenderFrameRemote(frame)->ReplicateTestConfiguration(
std::move(params));
} else {
did_send_initial_test_configuration_ = true;
GetBlinkTestControlRemote(frame)->SetTestConfiguration(std::move(params));
GetWebTestRenderFrameRemote(frame)->SetTestConfiguration(
std::move(params));
// Tests should always start with the browser controls hidden.
frame->UpdateBrowserControlsState(BROWSER_CONTROLS_STATE_BOTH,
BROWSER_CONTROLS_STATE_HIDDEN, false);
@ -1116,15 +1112,16 @@ void BlinkTestController::HandleNewRenderFrameHost(RenderFrameHost* frame) {
all_observed_render_process_hosts_.insert(process_host);
if (!main_window)
GetBlinkTestControlRemote(frame)->SetupRendererProcessForNonTestWindow();
GetWebTestRenderFrameRemote(frame)
->SetupRendererProcessForNonTestWindow();
GetWebTestControlRemote(process_host)
GetWebTestRenderThreadRemote(process_host)
->ReplicateWebTestRuntimeFlagsChanges(
accumulated_web_test_runtime_flags_changes_.Clone());
}
}
void BlinkTestController::OnTestFinished() {
void WebTestControlHost::OnTestFinished() {
test_phase_ = CLEAN_UP;
if (!printer_->output_finished())
printer_->PrintImageFooter();
@ -1138,7 +1135,7 @@ void BlinkTestController::OnTestFinished() {
ShellContentBrowserClient::Get()->browser_context();
base::RepeatingClosure barrier_closure = base::BarrierClosure(
2, base::BindOnce(&BlinkTestController::OnCleanupFinished,
2, base::BindOnce(&WebTestControlHost::OnCleanupFinished,
weak_factory_.GetWeakPtr()));
StoragePartition* storage_partition =
@ -1155,38 +1152,38 @@ void BlinkTestController::OnTestFinished() {
barrier_closure);
}
void BlinkTestController::OnCleanupFinished() {
void WebTestControlHost::OnCleanupFinished() {
if (secondary_window_) {
secondary_window_->web_contents()->Stop();
GetBlinkTestControlRemote(
GetWebTestRenderFrameRemote(
secondary_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->ResetRendererAfterWebTest();
++waiting_for_reset_done_;
}
if (main_window_) {
main_window_->web_contents()->Stop();
GetBlinkTestControlRemote(
GetWebTestRenderFrameRemote(
main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->ResetRendererAfterWebTest();
++waiting_for_reset_done_;
}
}
void BlinkTestController::OnCaptureDumpCompleted(mojom::BlinkTestDumpPtr dump) {
void WebTestControlHost::OnCaptureDumpCompleted(mojom::WebTestDumpPtr dump) {
main_frame_dump_ = std::move(dump);
waiting_for_main_frame_dump_ = false;
ReportResults();
}
void BlinkTestController::OnPixelDumpCaptured(const SkBitmap& snapshot) {
void WebTestControlHost::OnPixelDumpCaptured(const SkBitmap& snapshot) {
DCHECK(!snapshot.drawsNothing());
pixel_dump_ = snapshot;
waiting_for_pixel_results_ = false;
ReportResults();
}
void BlinkTestController::ReportResults() {
void WebTestControlHost::ReportResults() {
if (waiting_for_pixel_results_ || waiting_for_main_frame_dump_)
return;
if (main_frame_dump_->audio)
@ -1215,8 +1212,8 @@ void BlinkTestController::ReportResults() {
OnTestFinished();
}
void BlinkTestController::OnImageDump(const std::string& actual_pixel_hash,
const SkBitmap& image) {
void WebTestControlHost::OnImageDump(const std::string& actual_pixel_hash,
const SkBitmap& image) {
printer_->PrintImageHeader(actual_pixel_hash, expected_pixel_hash_);
// Only encode and dump the png if the hashes don't match. Encoding the
@ -1256,13 +1253,13 @@ void BlinkTestController::OnImageDump(const std::string& actual_pixel_hash,
printer_->PrintImageFooter();
}
void BlinkTestController::OnAudioDump(const std::vector<unsigned char>& dump) {
void WebTestControlHost::OnAudioDump(const std::vector<unsigned char>& dump) {
printer_->PrintAudioHeader();
printer_->PrintAudioBlock(dump);
printer_->PrintAudioFooter();
}
void BlinkTestController::OnTextDump(const std::string& dump) {
void WebTestControlHost::OnTextDump(const std::string& dump) {
printer_->PrintTextHeader();
printer_->PrintTextBlock(dump);
if (!navigation_history_dump_.empty())
@ -1270,7 +1267,7 @@ void BlinkTestController::OnTextDump(const std::string& dump) {
printer_->PrintTextFooter();
}
void BlinkTestController::OnWebTestRuntimeFlagsChanged(
void WebTestControlHost::OnWebTestRuntimeFlagsChanged(
int sender_process_host_id,
const base::DictionaryValue& changed_web_test_runtime_flags) {
// Stash the accumulated changes for future, not-yet-created renderers.
@ -1285,13 +1282,13 @@ void BlinkTestController::OnWebTestRuntimeFlagsChanged(
if (process->GetID() == sender_process_host_id)
continue;
GetWebTestControlRemote(process)->ReplicateWebTestRuntimeFlagsChanges(
GetWebTestRenderThreadRemote(process)->ReplicateWebTestRuntimeFlagsChanges(
changed_web_test_runtime_flags.Clone());
}
}
void BlinkTestController::OnDumpFrameLayoutResponse(int frame_tree_node_id,
const std::string& dump) {
void WebTestControlHost::OnDumpFrameLayoutResponse(int frame_tree_node_id,
const std::string& dump) {
// Store the result.
auto pair = frame_to_layout_dump_map_.insert(
std::make_pair(frame_tree_node_id, dump));
@ -1323,20 +1320,20 @@ void BlinkTestController::OnDumpFrameLayoutResponse(int frame_tree_node_id,
}
// Continue finishing the test.
GetBlinkTestControlRemote(
GetWebTestRenderFrameRemote(
main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->LayoutDumpCompleted(stitched_layout_dump);
}
void BlinkTestController::PrintMessageToStderr(const std::string& message) {
void WebTestControlHost::PrintMessageToStderr(const std::string& message) {
printer_->AddMessageToStderr(message);
}
void BlinkTestController::PrintMessage(const std::string& message) {
void WebTestControlHost::PrintMessage(const std::string& message) {
printer_->AddMessageRaw(message);
}
void BlinkTestController::OverridePreferences(const WebPreferences& prefs) {
void WebTestControlHost::OverridePreferences(const WebPreferences& prefs) {
should_override_prefs_ = true;
prefs_ = prefs;
@ -1350,15 +1347,15 @@ void BlinkTestController::OverridePreferences(const WebPreferences& prefs) {
main_render_view_host->OnWebkitPreferencesChanged();
}
void BlinkTestController::SetPopupBlockingEnabled(bool block_popups) {
void WebTestControlHost::SetPopupBlockingEnabled(bool block_popups) {
WebTestContentBrowserClient::Get()->SetPopupBlockingEnabled(block_popups);
}
void BlinkTestController::SetScreenOrientationChanged() {
void WebTestControlHost::SetScreenOrientationChanged() {
WebTestContentBrowserClient::Get()->SetScreenOrientationChanged(true);
}
void BlinkTestController::GetWritableDirectory(
void WebTestControlHost::GetWritableDirectory(
GetWritableDirectoryCallback reply_callback) {
base::ScopedAllowBlockingForTesting allow_blocking;
if (!writable_directory_for_tests_.IsValid()) {
@ -1423,25 +1420,25 @@ class FakeSelectFileDialogFactory : public ui::SelectFileDialogFactory {
} // namespace
void BlinkTestController::SetFilePathForMockFileDialog(
void WebTestControlHost::SetFilePathForMockFileDialog(
const base::FilePath& path) {
ui::SelectFileDialog::SetFactory(new FakeSelectFileDialogFactory(path));
}
void BlinkTestController::GoToOffset(int offset) {
void WebTestControlHost::GoToOffset(int offset) {
main_window_->GoBackOrForward(offset);
}
void BlinkTestController::Reload() {
void WebTestControlHost::Reload() {
main_window_->Reload();
}
void BlinkTestController::LoadURLForFrame(const GURL& url,
const std::string& frame_name) {
void WebTestControlHost::LoadURLForFrame(const GURL& url,
const std::string& frame_name) {
main_window_->LoadURLForFrame(url, frame_name, ui::PAGE_TRANSITION_LINK);
}
void BlinkTestController::CloseRemainingWindows() {
void WebTestControlHost::CloseRemainingWindows() {
DevToolsAgentHost::DetachAllClients();
std::vector<Shell*> open_windows(Shell::windows());
for (auto* shell : open_windows) {
@ -1451,7 +1448,7 @@ void BlinkTestController::CloseRemainingWindows() {
base::RunLoop().RunUntilIdle();
}
void BlinkTestController::ResetRendererAfterWebTestDone() {
void WebTestControlHost::ResetRendererAfterWebTestDone() {
if (--waiting_for_reset_done_ > 0)
return;
@ -1460,7 +1457,7 @@ void BlinkTestController::ResetRendererAfterWebTestDone() {
RenderViewHost* rvh = main_window_->web_contents()->GetRenderViewHost();
leak_detector_->TryLeakDetection(
rvh->GetProcess(),
base::BindOnce(&BlinkTestController::OnLeakDetectionDone,
base::BindOnce(&WebTestControlHost::OnLeakDetectionDone,
weak_factory_.GetWeakPtr()));
}
return;
@ -1469,7 +1466,7 @@ void BlinkTestController::ResetRendererAfterWebTestDone() {
Shell::QuitMainMessageLoopForTesting();
}
void BlinkTestController::OnLeakDetectionDone(
void WebTestControlHost::OnLeakDetectionDone(
const LeakDetector::LeakDetectionReport& report) {
if (!report.leaked) {
Shell::QuitMainMessageLoopForTesting();
@ -1483,27 +1480,27 @@ void BlinkTestController::OnLeakDetectionDone(
DiscardMainWindow();
}
void BlinkTestController::SetBluetoothManualChooser(bool enable) {
void WebTestControlHost::SetBluetoothManualChooser(bool enable) {
bluetooth_chooser_factory_.reset();
if (enable) {
bluetooth_chooser_factory_.reset(new WebTestBluetoothChooserFactory());
}
}
void BlinkTestController::GetBluetoothManualChooserEvents() {
void WebTestControlHost::GetBluetoothManualChooserEvents() {
if (!bluetooth_chooser_factory_) {
printer_->AddErrorMessage(
"FAIL: Must call setBluetoothManualChooser before "
"getBluetoothManualChooserEvents.");
return;
}
GetBlinkTestControlRemote(
GetWebTestRenderFrameRemote(
main_window_->web_contents()->GetRenderViewHost()->GetMainFrame())
->ReplyBluetoothManualChooserEvents(
bluetooth_chooser_factory_->GetAndResetEvents());
}
void BlinkTestController::SendBluetoothManualChooserEvent(
void WebTestControlHost::SendBluetoothManualChooserEvent(
const std::string& event_name,
const std::string& argument) {
if (!bluetooth_chooser_factory_) {
@ -1528,7 +1525,7 @@ void BlinkTestController::SendBluetoothManualChooserEvent(
bluetooth_chooser_factory_->SendEvent(event, argument);
}
void BlinkTestController::BlockThirdPartyCookies(bool block) {
void WebTestControlHost::BlockThirdPartyCookies(bool block) {
ShellBrowserContext* browser_context =
ShellContentBrowserClient::Get()->browser_context();
browser_context->GetDefaultStoragePartition(browser_context)
@ -1536,58 +1533,61 @@ void BlinkTestController::BlockThirdPartyCookies(bool block) {
->BlockThirdPartyCookies(block);
}
void BlinkTestController::AddBlinkTestClientReceiver(
mojo::PendingAssociatedReceiver<mojom::BlinkTestClient> receiver) {
void WebTestControlHost::AddWebTestControlHostReceiver(
mojo::PendingAssociatedReceiver<mojom::WebTestControlHost> receiver) {
blink_test_client_receivers_.Add(this, std::move(receiver));
}
mojo::AssociatedRemote<mojom::BlinkTestControl>&
BlinkTestController::GetBlinkTestControlRemote(RenderFrameHost* frame) {
mojo::AssociatedRemote<mojom::WebTestRenderFrame>&
WebTestControlHost::GetWebTestRenderFrameRemote(RenderFrameHost* frame) {
GlobalFrameRoutingId key(frame->GetProcess()->GetID(), frame->GetRoutingID());
if (blink_test_control_map_.find(key) == blink_test_control_map_.end()) {
mojo::AssociatedRemote<mojom::BlinkTestControl>& new_ptr =
blink_test_control_map_[key];
if (web_test_render_frame_map_.find(key) ==
web_test_render_frame_map_.end()) {
mojo::AssociatedRemote<mojom::WebTestRenderFrame>& new_ptr =
web_test_render_frame_map_[key];
frame->GetRemoteAssociatedInterfaces()->GetInterface(&new_ptr);
new_ptr.set_disconnect_handler(
base::BindOnce(&BlinkTestController::HandleBlinkTestControlError,
base::BindOnce(&WebTestControlHost::HandleWebTestRenderFrameRemoteError,
weak_factory_.GetWeakPtr(), key));
}
DCHECK(blink_test_control_map_[key].get());
return blink_test_control_map_[key];
DCHECK(web_test_render_frame_map_[key].get());
return web_test_render_frame_map_[key];
}
mojo::AssociatedRemote<mojom::WebTestControl>&
BlinkTestController::GetWebTestControlRemote(RenderProcessHost* process) {
if (web_test_control_map_.find(process) == web_test_control_map_.end()) {
mojo::AssociatedRemote<mojom::WebTestRenderThread>&
WebTestControlHost::GetWebTestRenderThreadRemote(RenderProcessHost* process) {
if (web_test_render_thread_map_.find(process) ==
web_test_render_thread_map_.end()) {
IPC::ChannelProxy* channel = process->GetChannel();
// channel might be null in tests.
if (process->IsInitializedAndNotDead() && channel) {
mojo::AssociatedRemote<mojom::WebTestControl>& new_ptr =
web_test_control_map_[process];
mojo::AssociatedRemote<mojom::WebTestRenderThread>& new_ptr =
web_test_render_thread_map_[process];
channel->GetRemoteAssociatedInterface(&new_ptr);
new_ptr.set_disconnect_handler(
base::BindOnce(&BlinkTestController::HandleWebTestControlError,
weak_factory_.GetWeakPtr(), process));
new_ptr.set_disconnect_handler(base::BindOnce(
&WebTestControlHost::HandleWebTestRenderThreadRemoteError,
weak_factory_.GetWeakPtr(), process));
}
}
DCHECK(web_test_control_map_[process].get());
return web_test_control_map_[process];
DCHECK(web_test_render_thread_map_[process].get());
return web_test_render_thread_map_[process];
}
void BlinkTestController::HandleBlinkTestControlError(
void WebTestControlHost::HandleWebTestRenderFrameRemoteError(
const GlobalFrameRoutingId& key) {
blink_test_control_map_.erase(key);
web_test_render_frame_map_.erase(key);
}
void BlinkTestController::HandleWebTestControlError(RenderProcessHost* key) {
web_test_control_map_.erase(key);
void WebTestControlHost::HandleWebTestRenderThreadRemoteError(
RenderProcessHost* key) {
web_test_render_thread_map_.erase(key);
}
BlinkTestController::Node::Node() = default;
BlinkTestController::Node::Node(RenderFrameHost* host)
WebTestControlHost::Node::Node() = default;
WebTestControlHost::Node::Node(RenderFrameHost* host)
: render_frame_host(host),
render_frame_host_id(host->GetProcess()->GetID(), host->GetRoutingID()) {}
BlinkTestController::Node::Node(Node&& other) = default;
BlinkTestController::Node::~Node() = default;
WebTestControlHost::Node::Node(Node&& other) = default;
WebTestControlHost::Node::~Node() = default;
} // namespace content

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_BROWSER_WEB_TEST_BLINK_TEST_CONTROLLER_H_
#define CONTENT_SHELL_BROWSER_WEB_TEST_BLINK_TEST_CONTROLLER_H_
#ifndef CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_CONTROL_HOST_H_
#define CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_CONTROL_HOST_H_
#include <map>
#include <memory>
@ -33,7 +33,6 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/web_preferences.h"
#include "content/shell/browser/web_test/leak_detector.h"
#include "content/shell/common/web_test/blink_test.mojom.h"
#include "content/shell/common/web_test/web_test.mojom.h"
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
@ -50,10 +49,10 @@ class WebTestBluetoothChooserFactory;
class WebTestDevToolsBindings;
struct TestInfo;
class BlinkTestResultPrinter {
class WebTestResultPrinter {
public:
BlinkTestResultPrinter(std::ostream* output, std::ostream* error);
~BlinkTestResultPrinter();
WebTestResultPrinter(std::ostream* output, std::ostream* error);
~WebTestResultPrinter() = default;
void reset() { state_ = DURING_TEST; }
bool output_finished() const { return state_ == AFTER_TEST; }
@ -105,19 +104,19 @@ class BlinkTestResultPrinter {
std::ostream* output_;
std::ostream* error_;
DISALLOW_COPY_AND_ASSIGN(BlinkTestResultPrinter);
DISALLOW_COPY_AND_ASSIGN(WebTestResultPrinter);
};
class BlinkTestController : public WebContentsObserver,
public RenderProcessHostObserver,
public NotificationObserver,
public GpuDataManagerObserver,
public mojom::BlinkTestClient {
class WebTestControlHost : public WebContentsObserver,
public RenderProcessHostObserver,
public NotificationObserver,
public GpuDataManagerObserver,
public mojom::WebTestControlHost {
public:
static BlinkTestController* Get();
static WebTestControlHost* Get();
BlinkTestController();
~BlinkTestController() override;
WebTestControlHost();
~WebTestControlHost() override;
// True if the controller is ready for testing.
bool PrepareForWebTest(const TestInfo& test_info);
@ -143,13 +142,13 @@ class BlinkTestController : public WebContentsObserver,
RenderFrameHost* frame,
const BluetoothChooser::EventHandler& event_handler);
BlinkTestResultPrinter* printer() { return printer_.get(); }
void set_printer(BlinkTestResultPrinter* printer) { printer_.reset(printer); }
WebTestResultPrinter* printer() { return printer_.get(); }
void set_printer(WebTestResultPrinter* printer) { printer_.reset(printer); }
void DevToolsProcessCrashed();
void AddBlinkTestClientReceiver(
mojo::PendingAssociatedReceiver<mojom::BlinkTestClient> receiver);
void AddWebTestControlHostReceiver(
mojo::PendingAssociatedReceiver<mojom::WebTestControlHost> receiver);
// WebContentsObserver implementation.
void PluginCrashed(const base::FilePath& plugin_path,
@ -182,7 +181,7 @@ class BlinkTestController : public WebContentsObserver,
return accumulated_web_test_runtime_flags_changes_;
}
// BlinkTestClient implementation.
// WebTestControlHost implementation.
void InitiateLayoutDump() override;
void InitiateCaptureDump(bool capture_navigation_history,
bool capture_pixels) override;
@ -223,7 +222,7 @@ class BlinkTestController : public WebContentsObserver,
DISALLOW_COPY_AND_ASSIGN(Node);
};
static BlinkTestController* instance_;
static WebTestControlHost* instance_;
void DiscardMainWindow();
@ -238,17 +237,17 @@ class BlinkTestController : public WebContentsObserver,
void OnLeakDetectionDone(const LeakDetector::LeakDetectionReport& report);
void OnCleanupFinished();
void OnCaptureDumpCompleted(mojom::BlinkTestDumpPtr dump);
void OnCaptureDumpCompleted(mojom::WebTestDumpPtr dump);
void OnPixelDumpCaptured(const SkBitmap& snapshot);
void ReportResults();
void EnqueueSurfaceCopyRequest();
mojo::AssociatedRemote<mojom::BlinkTestControl>& GetBlinkTestControlRemote(
RenderFrameHost* frame);
mojo::AssociatedRemote<mojom::WebTestControl>& GetWebTestControlRemote(
RenderProcessHost* process);
void HandleBlinkTestControlError(const GlobalFrameRoutingId& key);
void HandleWebTestControlError(RenderProcessHost* key);
mojo::AssociatedRemote<mojom::WebTestRenderFrame>&
GetWebTestRenderFrameRemote(RenderFrameHost* frame);
mojo::AssociatedRemote<mojom::WebTestRenderThread>&
GetWebTestRenderThreadRemote(RenderProcessHost* process);
void HandleWebTestRenderFrameRemoteError(const GlobalFrameRoutingId& key);
void HandleWebTestRenderThreadRemoteError(RenderProcessHost* key);
// CompositeAllFramesThen() first builds a frame tree based on
// frame->GetParent(). Then, it builds a queue of frames in depth-first order,
@ -266,7 +265,7 @@ class BlinkTestController : public WebContentsObserver,
void BuildDepthFirstQueue(Node* node);
public:
std::unique_ptr<BlinkTestResultPrinter> printer_;
std::unique_ptr<WebTestResultPrinter> printer_;
base::FilePath current_working_directory_;
base::FilePath temp_path_;
@ -314,7 +313,7 @@ class BlinkTestController : public WebContentsObserver,
// Map from frame_tree_node_id into frame-specific dumps.
std::map<int, std::string> frame_to_layout_dump_map_;
// Number of BlinkTestControl.DumpFrameLayout responses we are waiting for.
// Number of WebTestRenderFrame.DumpFrameLayout responses we are waiting for.
int pending_layout_dumps_;
// Renderer processes are observed to detect crashes.
@ -332,7 +331,7 @@ class BlinkTestController : public WebContentsObserver,
std::string navigation_history_dump_;
base::Optional<SkBitmap> pixel_dump_;
std::string actual_pixel_hash_;
mojom::BlinkTestDumpPtr main_frame_dump_;
mojom::WebTestDumpPtr main_frame_dump_;
bool waiting_for_pixel_results_ = false;
bool waiting_for_main_frame_dump_ = false;
int waiting_for_reset_done_ = 0;
@ -342,24 +341,25 @@ class BlinkTestController : public WebContentsObserver,
// Map from one frame to one mojo pipe.
std::map<GlobalFrameRoutingId,
mojo::AssociatedRemote<mojom::BlinkTestControl>>
blink_test_control_map_;
mojo::AssociatedRemote<mojom::WebTestRenderFrame>>
web_test_render_frame_map_;
std::map<RenderProcessHost*, mojo::AssociatedRemote<mojom::WebTestControl>>
web_test_control_map_;
std::map<RenderProcessHost*,
mojo::AssociatedRemote<mojom::WebTestRenderThread>>
web_test_render_thread_map_;
mojo::AssociatedReceiverSet<mojom::BlinkTestClient>
mojo::AssociatedReceiverSet<mojom::WebTestControlHost>
blink_test_client_receivers_;
base::ScopedTempDir writable_directory_for_tests_;
SEQUENCE_CHECKER(sequence_checker_);
base::WeakPtrFactory<BlinkTestController> weak_factory_{this};
base::WeakPtrFactory<WebTestControlHost> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(BlinkTestController);
DISALLOW_COPY_AND_ASSIGN(WebTestControlHost);
};
} // namespace content
#endif // CONTENT_SHELL_BROWSER_WEB_TEST_BLINK_TEST_CONTROLLER_H_
#endif // CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_CONTROL_HOST_H_

@ -16,7 +16,7 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include "content/shell/common/web_test/web_test_switches.h"
#include "net/base/filename_util.h"
@ -52,8 +52,8 @@ class WebTestDevToolsBindings::SecondaryObserver : public WebContentsObserver {
// WebContentsObserver implementation.
void RenderFrameCreated(RenderFrameHost* render_frame_host) override {
if (BlinkTestController::Get())
BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host);
if (WebTestControlHost::Get())
WebTestControlHost::Get()->HandleNewRenderFrameHost(render_frame_host);
}
private:

@ -16,7 +16,7 @@
#include "components/download/public/common/download_item.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/browser/download_manager.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include "net/base/filename_util.h"
#if defined(OS_WIN)
@ -34,11 +34,11 @@ WebTestDownloadManagerDelegate::~WebTestDownloadManagerDelegate() {}
bool WebTestDownloadManagerDelegate::ShouldOpenDownload(
download::DownloadItem* item,
DownloadOpenDelayedCallback callback) {
if (BlinkTestController::Get() &&
BlinkTestController::Get()->IsMainWindow(
if (WebTestControlHost::Get() &&
WebTestControlHost::Get()->IsMainWindow(
DownloadItemUtils::GetWebContents(item)) &&
item->GetMimeType() == "text/html") {
BlinkTestController::Get()->OpenURL(
WebTestControlHost::Get()->OpenURL(
net::FilePathToFileURL(item->GetFullPath()));
}
return true;
@ -52,7 +52,7 @@ void WebTestDownloadManagerDelegate::CheckDownloadAllowed(
bool from_download_cross_origin_redirect,
bool content_initiated,
content::CheckDownloadAllowedCallback check_download_allowed_cb) {
auto* test_controller = BlinkTestController::Get();
auto* test_controller = WebTestControlHost::Get();
base::Optional<bool> should_wait_until_external_url_load =
test_controller->accumulated_web_test_runtime_flags_changes()
.FindBoolPath("wait_until_external_url_load");
@ -70,7 +70,7 @@ void WebTestDownloadManagerDelegate::CheckDownloadAllowed(
}
test_controller->printer()->AddMessageRaw("Download started\n");
static_cast<mojom::BlinkTestClient*>(test_controller)
static_cast<mojom::WebTestControlHost*>(test_controller)
->TestFinishedInSecondaryRenderer();
std::move(check_download_allowed_cb).Run(false);
}

@ -12,7 +12,7 @@
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/web_contents.h"
#include "content/shell/browser/shell_javascript_dialog.h"
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include "content/shell/common/shell_switches.h"
namespace content {
@ -20,7 +20,7 @@ namespace content {
namespace {
bool DumpJavascriptDialog() {
base::Optional<bool> result =
BlinkTestController::Get()
WebTestControlHost::Get()
->accumulated_web_test_runtime_flags_changes()
.FindBoolPath("dump_javascript_dialogs");
if (!result.has_value())
@ -30,7 +30,7 @@ bool DumpJavascriptDialog() {
bool ShouldStayOnPageAfterHandlingBeforeUnload() {
base::Optional<bool> result =
BlinkTestController::Get()
WebTestControlHost::Get()
->accumulated_web_test_runtime_flags_changes()
.FindBoolPath("stay_on_page_after_handling_before_unload");
if (!result.has_value())
@ -69,7 +69,7 @@ void WebTestJavaScriptDialogManager::RunJavaScriptDialog(
", default text: ", base::UTF16ToUTF8(default_prompt_text), "\n"});
break;
}
BlinkTestController::Get()->printer()->AddMessageRaw(message);
WebTestControlHost::Get()->printer()->AddMessageRaw(message);
}
std::move(callback).Run(true, base::string16());
}
@ -80,8 +80,7 @@ void WebTestJavaScriptDialogManager::RunBeforeUnloadDialog(
bool is_reload,
DialogClosedCallback callback) {
if (DumpJavascriptDialog())
BlinkTestController::Get()->printer()->AddMessageRaw(
"CONFIRM NAVIGATION\n");
WebTestControlHost::Get()->printer()->AddMessageRaw("CONFIRM NAVIGATION\n");
std::move(callback).Run(!ShouldStayOnPageAfterHandlingBeforeUnload(),
base::string16());
}

@ -1,176 +0,0 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module content.mojom;
import "content/public/common/web_preferences.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "skia/public/mojom/bitmap.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/url.mojom";
struct ShellTestConfiguration {
// The current working directory.
mojo_base.mojom.FilePath current_working_directory;
// The temporary directory of the system.
mojo_base.mojom.FilePath temp_path;
// The URL of the current web test.
url.mojom.Url test_url;
// True if tests can open external URLs.
bool allow_external_pages;
// The expected MD5 hash of the pixel results.
string expected_pixel_hash;
// The initial size of the test window.
gfx.mojom.Size initial_size;
// Whether the test is running in protocol mode.
// See TestInfo::protocol_mode in browser/web_test/test_info_extractor.h.
bool protocol_mode;
};
// Results of a CaptureDump call.
struct BlinkTestDump {
// Audio dump.
array<uint8>? audio;
// Layout dump.
string? layout;
// Image dump.
skia.mojom.Bitmap? pixels;
string actual_pixel_hash;
// Selection rect dump.
gfx.mojom.Rect selection_rect;
};
// Blink test messages sent from the browser process to the renderer.
interface BlinkTestControl {
// Sets up a renderer in a window other than the main test window. This may
// be for a window opened by javascript (window.open()) or by the test harness
// (devtools inspector). This should be called as early as possible (as soon
// as a RenderFrame has been created for this interface to be available) after
// the renderer process is created, for each process not tied to the main
// window.
SetupRendererProcessForNonTestWindow();
CaptureDump() => (BlinkTestDump result);
CompositeWithRaster() => ();
// Dumps the frame's contents into a string.
DumpFrameLayout() => (string frame_layout_dump);
// Replicates test config (for an already started test) to a new renderer
// that hosts parts of the main test window.
ReplicateTestConfiguration(ShellTestConfiguration config);
// Sets the test config for a web test that is being started. This message
// is sent only to a renderer that hosts parts of the main test window.
SetTestConfiguration(ShellTestConfiguration config);
// Tells the renderer to navigate to about:blank and reset all state
// in preparation for the next test. This happens before leak detection
// in order for the test harness to drop anything that tests passed in
// and which could cause a leak otherwise.
ResetRendererAfterWebTest();
// Tells the main window that a secondary renderer in a different process
// asked to finish the test.
FinishTestInMainWindow();
// Notifies BlinkTestRunner that the layout dump has completed (and that it
// can proceed with finishing up the test).
// TODO(crbug.com/1039247): This message should be removed and the callback
// should happen part of LayoutDump call on the host interface.
LayoutDumpCompleted(string completed_layout_dump);
// Reply Bluetooth manual events to BlinkTestRunner.
ReplyBluetoothManualChooserEvents(array<string> events);
};
// Blink test messages sent from the renderer process to the browser.
interface BlinkTestClient {
// Asks the browser process to perform a layout dump spanning all the
// (potentially cross-process) frames. This goes through multiple
// BlinkTestControl.DumpFrameLayout calls and ends with sending of
// LayoutDumpCompleted of BlinkTestControl interface.
InitiateLayoutDump();
// Initialize to dump the main window's navigation history to text, and/or
// capture a pixel dump of the main window's content.
InitiateCaptureDump(bool capture_navigation_history, bool capture_pixels);
// Sent by secondary test window to notify the test has finished.
TestFinishedInSecondaryRenderer();
// An ACK to notify the browser process that ResetRendererAfterWebTest() has
// completed.
ResetRendererAfterWebTestDone();
// Add a message to stderr (not saved to expected output files, for debugging
// only).
PrintMessageToStderr(string message);
// Add a message.
PrintMessage(string message);
// Update changed WebKit preferences.
OverridePreferences(WebPreferences web_preferences);
// Trigger a reload navigation on the main WebView.
Reload();
// Invoked when the embedder should close all but the main WebView.
CloseRemainingWindows();
// Trigger a GoToOffset navigation on the main WebView.
GoToOffset(int32 offset);
// Calls the BluetoothChooser::EventHandler with the arguments here. Valid
// event strings are:
// * "cancel" - simulates the user canceling the chooser.
// * "select" - simulates the user selecting a device whose device ID is in
// |argument|.
SendBluetoothManualChooserEvent(string event, string argument);
// If |enable| is true makes the Bluetooth chooser record its input and wait
// for instructions from the test program on how to proceed. Otherwise
// fall backs to the browser's default chooser.
SetBluetoothManualChooser(bool enable);
// Returns the events recorded since the last call to this function.
GetBluetoothManualChooserEvents();
// Manages the popup blocking setting to used for web tests.
SetPopupBlockingEnabled(bool block_popups);
// Trigger a loadURL navigation on the main WebView.
LoadURLForFrame(url.mojom.Url url, string frame_name);
// Mark the orientation changed in the browser process for the layout tests
// that request fullscreen on screen orientation change.
SetScreenOrientationChanged();
// Sets the cookie policy to:
// - allow all cookies when |block| is false
// - block only third-party cookies when |block| is true
BlockThirdPartyCookies(bool block);
// Returns the absolute path to a directory this test can write data in. This
// returns the path to a fresh empty directory for each test that calls this
// method, but repeatedly calling this from the same test will return the same
// directory.
[Sync]
GetWritableDirectory() => (mojo_base.mojom.FilePath path);
// For the duration of the current test this causes all file choosers to
// return the passed in |path|.
SetFilePathForMockFileDialog(mojo_base.mojom.FilePath path);
};

@ -4,15 +4,107 @@
module content.mojom;
import "content/public/common/web_preferences.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/values.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "skia/public/mojom/bitmap.mojom";
import "third_party/blink/public/mojom/permissions/permission_status.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/url.mojom";
import "url/mojom/origin.mojom";
// Web test messages sent from the browser process to the renderer.
interface WebTestControl {
struct WebTestRunTestConfiguration {
// The current working directory.
mojo_base.mojom.FilePath current_working_directory;
// The temporary directory of the system.
mojo_base.mojom.FilePath temp_path;
// The URL of the current web test.
url.mojom.Url test_url;
// True if tests can open external URLs.
bool allow_external_pages;
// The expected MD5 hash of the pixel results.
string expected_pixel_hash;
// The initial size of the test window.
gfx.mojom.Size initial_size;
// Whether the test is running in protocol mode.
// See TestInfo::protocol_mode in browser/web_test/test_info_extractor.h.
bool protocol_mode;
};
// Results of a CaptureDump call.
struct WebTestDump {
// Audio dump.
array<uint8>? audio;
// Layout dump.
string? layout;
// Image dump.
skia.mojom.Bitmap? pixels;
string actual_pixel_hash;
// Selection rect dump.
gfx.mojom.Rect selection_rect;
};
// Web test messages sent from the browser process to the renderer. This
// interface is associated with RenderFrameHost.
interface WebTestRenderFrame {
// Sets up a renderer in a window other than the main test window. This may
// be for a window opened by javascript (window.open()) or by the test harness
// (devtools inspector). This should be called as early as possible (as soon
// as a RenderFrame has been created for this interface to be available) after
// the renderer process is created, for each process not tied to the main
// window.
SetupRendererProcessForNonTestWindow();
// Dump the main frame with, and calls the given callback when it's finished.
CaptureDump() => (WebTestDump result);
// Performs the complete set of document lifecycle phases, including updates
// to the compositor state and rasterization, then calling the given callback.
CompositeWithRaster() => ();
// Dumps the frame's contents into a string.
DumpFrameLayout() => (string frame_layout_dump);
// Replicates test config (for an already started test) to a new renderer
// that hosts parts of the main test window.
ReplicateTestConfiguration(WebTestRunTestConfiguration config);
// Sets the test config for a web test that is being started. This message
// is sent only to a renderer that hosts parts of the main test window.
SetTestConfiguration(WebTestRunTestConfiguration config);
// Tells the renderer to navigate to about:blank and reset all state
// in preparation for the next test. This happens before leak detection
// in order for the test harness to drop anything that tests passed in
// and which could cause a leak otherwise.
ResetRendererAfterWebTest();
// Tells the main window that a secondary renderer in a different process
// asked to finish the test.
FinishTestInMainWindow();
// Notifies BlinkTestRunner that the layout dump has completed (and that it
// can proceed with finishing up the test).
// TODO(crbug.com/1039247): This message should be removed and the callback
// should happen part of LayoutDump call on the host interface.
LayoutDumpCompleted(string completed_layout_dump);
// Reply Bluetooth manual events to BlinkTestRunner.
ReplyBluetoothManualChooserEvents(array<string> events);
};
// Web test messages related runtime flags sent from the browser process to the
// renderer. This interface is associated with RenderProcessHost.
interface WebTestRenderThread {
// Used send flag changes to renderers - either when
// 1) broadcasting change happening in one renderer to all other renderers, or
// 2) sending accumulated changes to a single new renderer.
@ -20,6 +112,88 @@ interface WebTestControl {
mojo_base.mojom.DictionaryValue changed_layout_test_runtime_flags);
};
// Web test messages sent from the renderer process to the browser. This
// provides a message pipe from each renderer to the global WebTestControlHost
// in the browser.
interface WebTestControlHost {
// Asks the browser process to perform a layout dump spanning all the
// (potentially cross-process) frames. This goes through multiple
// WebTestRenderFrame.DumpFrameLayout calls and ends with sending of
// LayoutDumpCompleted of WebTestRenderFrame interface.
InitiateLayoutDump();
// Initialize to dump the main window's navigation history to text, and/or
// capture a pixel dump of the main window's content.
InitiateCaptureDump(bool capture_navigation_history, bool capture_pixels);
// Sent by secondary test window to notify the test has finished.
TestFinishedInSecondaryRenderer();
// An ACK to notify the browser process that ResetRendererAfterWebTest() has
// completed.
ResetRendererAfterWebTestDone();
// Add a message to stderr (not saved to expected output files, for debugging
// only).
PrintMessageToStderr(string message);
// Add a message.
PrintMessage(string message);
// Update changed WebKit preferences.
OverridePreferences(WebPreferences web_preferences);
// Trigger a reload navigation on the main WebView.
Reload();
// Invoked when the embedder should close all but the main WebView.
CloseRemainingWindows();
// Trigger a GoToOffset navigation on the main WebView.
GoToOffset(int32 offset);
// Calls the BluetoothChooser::EventHandler with the arguments here. Valid
// event strings are:
// * "cancel" - simulates the user canceling the chooser.
// * "select" - simulates the user selecting a device whose device ID is in
// |argument|.
SendBluetoothManualChooserEvent(string event, string argument);
// If |enable| is true makes the Bluetooth chooser record its input and wait
// for instructions from the test program on how to proceed. Otherwise
// fall backs to the browser's default chooser.
SetBluetoothManualChooser(bool enable);
// Returns the events recorded since the last call to this function.
GetBluetoothManualChooserEvents();
// Manages the popup blocking setting to used for web tests.
SetPopupBlockingEnabled(bool block_popups);
// Trigger a loadURL navigation on the main WebView.
LoadURLForFrame(url.mojom.Url url, string frame_name);
// Mark the orientation changed in the browser process for the layout tests
// that request fullscreen on screen orientation change.
SetScreenOrientationChanged();
// Sets the cookie policy to:
// - allow all cookies when |block| is false
// - block only third-party cookies when |block| is true
BlockThirdPartyCookies(bool block);
// Returns the absolute path to a directory this test can write data in. This
// returns the path to a fresh empty directory for each test that calls this
// method, but repeatedly calling this from the same test will return the same
// directory.
[Sync]
GetWritableDirectory() => (mojo_base.mojom.FilePath path);
// For the duration of the current test this causes all file choosers to
// return the passed in |path|.
SetFilePathForMockFileDialog(mojo_base.mojom.FilePath path);
};
// Web test messages sent from the renderer process to the browser.
interface WebTestClient {
// Simulates a click on the notification.

@ -148,18 +148,18 @@ class MockAudioCapturerSource : public media::AudioCapturerSource {
BlinkTestRunner::BlinkTestRunner(WebViewTestProxy* web_view_test_proxy)
: web_view_test_proxy_(web_view_test_proxy),
test_config_(mojom::ShellTestConfiguration::New()) {}
test_config_(mojom::WebTestRunTestConfiguration::New()) {}
BlinkTestRunner::~BlinkTestRunner() = default;
// WebTestDelegate -----------------------------------------------------------
void BlinkTestRunner::PrintMessageToStderr(const std::string& message) {
GetBlinkTestClientRemote()->PrintMessageToStderr(message);
GetWebTestControlHostRemote()->PrintMessageToStderr(message);
}
void BlinkTestRunner::PrintMessage(const std::string& message) {
GetBlinkTestClientRemote()->PrintMessage(message);
GetWebTestControlHostRemote()->PrintMessage(message);
}
WebString BlinkTestRunner::RegisterIsolatedFileSystem(
@ -192,11 +192,11 @@ void BlinkTestRunner::ApplyPreferences() {
WebPreferences prefs = web_view_test_proxy_->GetWebkitPreferences();
ExportWebTestSpecificPreferences(prefs_, &prefs);
web_view_test_proxy_->SetWebkitPreferences(prefs);
GetBlinkTestClientRemote()->OverridePreferences(prefs);
GetWebTestControlHostRemote()->OverridePreferences(prefs);
}
void BlinkTestRunner::SetPopupBlockingEnabled(bool block_popups) {
GetBlinkTestClientRemote()->SetPopupBlockingEnabled(block_popups);
GetWebTestControlHostRemote()->SetPopupBlockingEnabled(block_popups);
}
void BlinkTestRunner::EnableAutoResizeMode(const WebSize& min_size,
@ -264,19 +264,20 @@ void BlinkTestRunner::SetBluetoothFakeAdapter(const std::string& adapter_name,
}
void BlinkTestRunner::SetBluetoothManualChooser(bool enable) {
GetBlinkTestClientRemote()->SetBluetoothManualChooser(enable);
GetWebTestControlHostRemote()->SetBluetoothManualChooser(enable);
}
void BlinkTestRunner::GetBluetoothManualChooserEvents(
base::OnceCallback<void(const std::vector<std::string>&)> callback) {
get_bluetooth_events_callbacks_.push_back(std::move(callback));
GetBlinkTestClientRemote()->GetBluetoothManualChooserEvents();
GetWebTestControlHostRemote()->GetBluetoothManualChooserEvents();
}
void BlinkTestRunner::SendBluetoothManualChooserEvent(
const std::string& event,
const std::string& argument) {
GetBlinkTestClientRemote()->SendBluetoothManualChooserEvent(event, argument);
GetWebTestControlHostRemote()->SendBluetoothManualChooserEvent(event,
argument);
}
void BlinkTestRunner::SetFocus(blink::WebView* web_view, bool focus) {
@ -286,7 +287,7 @@ void BlinkTestRunner::SetFocus(blink::WebView* web_view, bool focus) {
}
void BlinkTestRunner::SetBlockThirdPartyCookies(bool block) {
GetBlinkTestClientRemote()->BlockThirdPartyCookies(block);
GetWebTestControlHostRemote()->BlockThirdPartyCookies(block);
}
void BlinkTestRunner::SetLocale(const std::string& locale) {
@ -298,12 +299,12 @@ void BlinkTestRunner::SetLocale(const std::string& locale) {
base::FilePath BlinkTestRunner::GetWritableDirectory() {
base::FilePath result;
GetBlinkTestClientRemote()->GetWritableDirectory(&result);
GetWebTestControlHostRemote()->GetWritableDirectory(&result);
return result;
}
void BlinkTestRunner::SetFilePathForMockFileDialog(const base::FilePath& path) {
GetBlinkTestClientRemote()->SetFilePathForMockFileDialog(path);
GetWebTestControlHostRemote()->SetFilePathForMockFileDialog(path);
}
void BlinkTestRunner::OnWebTestRuntimeFlagsChanged(
@ -331,7 +332,7 @@ void BlinkTestRunner::TestFinished() {
// If we're not in the main frame, then ask the browser to redirect the call
// to the main frame instead.
if (!is_main_window_ || !web_view_test_proxy_->GetMainRenderFrame()) {
GetBlinkTestClientRemote()->TestFinishedInSecondaryRenderer();
GetWebTestControlHostRemote()->TestFinishedInSecondaryRenderer();
return;
}
@ -345,7 +346,7 @@ void BlinkTestRunner::TestFinished() {
// Initialize a new dump results object which we will populate in the calls
// below.
dump_result_ = mojom::BlinkTestDump::New();
dump_result_ = mojom::WebTestDump::New();
bool browser_should_dump_back_forward_list =
test_runner->ShouldDumpBackForwardList();
@ -353,7 +354,7 @@ void BlinkTestRunner::TestFinished() {
if (test_runner->ShouldDumpAsAudio()) {
CaptureLocalAudioDump();
GetBlinkTestClientRemote()->InitiateCaptureDump(
GetWebTestControlHostRemote()->InitiateCaptureDump(
browser_should_dump_back_forward_list,
/*browser_should_capture_pixels=*/false);
return;
@ -366,7 +367,7 @@ void BlinkTestRunner::TestFinished() {
CaptureLocalLayoutDump();
if (!test_runner->ShouldGeneratePixelResults()) {
GetBlinkTestClientRemote()->InitiateCaptureDump(
GetWebTestControlHostRemote()->InitiateCaptureDump(
browser_should_dump_back_forward_list,
/*browser_should_capture_pixels=*/false);
return;
@ -386,7 +387,7 @@ void BlinkTestRunner::TestFinished() {
web_frame->GetSelectionBoundsRectForTesting();
}
}
GetBlinkTestClientRemote()->InitiateCaptureDump(
GetWebTestControlHostRemote()->InitiateCaptureDump(
browser_should_dump_back_forward_list,
!test_runner->CanDumpPixelsFromRenderer());
}
@ -412,7 +413,7 @@ void BlinkTestRunner::CaptureLocalLayoutDump() {
// TODO(vmpstr): Since CaptureDump is called from the browser, we can be
// smart and move this logic directly to the browser.
waiting_for_layout_dump_results_ = true;
GetBlinkTestClientRemote()->InitiateLayoutDump();
GetWebTestControlHostRemote()->InitiateLayoutDump();
}
}
@ -473,7 +474,7 @@ void BlinkTestRunner::CaptureDumpComplete() {
}
void BlinkTestRunner::CloseRemainingWindows() {
GetBlinkTestClientRemote()->CloseRemainingWindows();
GetWebTestControlHostRemote()->CloseRemainingWindows();
}
void BlinkTestRunner::DeleteAllCookies() {
@ -485,16 +486,16 @@ int BlinkTestRunner::NavigationEntryCount() {
}
void BlinkTestRunner::GoToOffset(int offset) {
GetBlinkTestClientRemote()->GoToOffset(offset);
GetWebTestControlHostRemote()->GoToOffset(offset);
}
void BlinkTestRunner::Reload() {
GetBlinkTestClientRemote()->Reload();
GetWebTestControlHostRemote()->Reload();
}
void BlinkTestRunner::LoadURLForFrame(const WebURL& url,
const std::string& frame_name) {
GetBlinkTestClientRemote()->LoadURLForFrame(url, frame_name);
GetWebTestControlHostRemote()->LoadURLForFrame(url, frame_name);
}
bool BlinkTestRunner::AllowExternalPages() {
@ -554,7 +555,7 @@ void BlinkTestRunner::ForceTextInputStateUpdate(WebLocalFrame* frame) {
}
void BlinkTestRunner::SetScreenOrientationChanged() {
GetBlinkTestClientRemote()->SetScreenOrientationChanged();
GetWebTestControlHostRemote()->SetScreenOrientationChanged();
}
void BlinkTestRunner::SetTrustTokenKeyCommitments(
@ -571,7 +572,7 @@ void BlinkTestRunner::ClearTrustTokenState(base::OnceClosure callback) {
// Public methods - -----------------------------------------------------------
void BlinkTestRunner::CaptureDump(
mojom::BlinkTestControl::CaptureDumpCallback callback) {
mojom::WebTestRenderFrame::CaptureDumpCallback callback) {
// TODO(vmpstr): This is only called on the main frame. One suggestion is to
// split the interface on which this call lives so that it is only accessible
// to the main frame (as opposed to all frames).
@ -597,7 +598,7 @@ void BlinkTestRunner::DidCommitNavigationInMainFrame() {
return;
waiting_for_reset_navigation_to_about_blank_ = false;
GetBlinkTestClientRemote()->ResetRendererAfterWebTestDone();
GetWebTestControlHostRemote()->ResetRendererAfterWebTestDone();
}
// Private methods -----------------------------------------------------------
@ -611,20 +612,20 @@ BlinkTestRunner::GetBluetoothFakeAdapterSetter() {
return *bluetooth_fake_adapter_setter_;
}
mojo::AssociatedRemote<mojom::BlinkTestClient>&
BlinkTestRunner::GetBlinkTestClientRemote() {
if (!blink_test_client_remote_) {
mojo::AssociatedRemote<mojom::WebTestControlHost>&
BlinkTestRunner::GetWebTestControlHostRemote() {
if (!web_test_control_host_remote_) {
RenderThread::Get()->GetChannel()->GetRemoteAssociatedInterface(
&blink_test_client_remote_);
blink_test_client_remote_.set_disconnect_handler(
base::BindOnce(&BlinkTestRunner::HandleBlinkTestClientDisconnected,
&web_test_control_host_remote_);
web_test_control_host_remote_.set_disconnect_handler(
base::BindOnce(&BlinkTestRunner::HandleWebTestControlHostDisconnected,
base::Unretained(this)));
}
return blink_test_client_remote_;
return web_test_control_host_remote_;
}
void BlinkTestRunner::HandleBlinkTestClientDisconnected() {
blink_test_client_remote_.reset();
void BlinkTestRunner::HandleWebTestControlHostDisconnected() {
web_test_control_host_remote_.reset();
}
mojo::AssociatedRemote<mojom::WebTestClient>&
@ -664,7 +665,7 @@ void BlinkTestRunner::OnSetupRendererProcessForNonTestWindow() {
}
void BlinkTestRunner::ApplyTestConfiguration(
mojom::ShellTestConfigurationPtr params) {
mojom::WebTestRunTestConfigurationPtr params) {
TestInterfaces* interfaces = web_view_test_proxy_->test_interfaces();
test_config_ = params.Clone();
@ -677,12 +678,12 @@ void BlinkTestRunner::ApplyTestConfiguration(
}
void BlinkTestRunner::OnReplicateTestConfiguration(
mojom::ShellTestConfigurationPtr params) {
mojom::WebTestRunTestConfigurationPtr params) {
ApplyTestConfiguration(std::move(params));
}
void BlinkTestRunner::OnSetTestConfiguration(
mojom::ShellTestConfigurationPtr params) {
mojom::WebTestRunTestConfigurationPtr params) {
DCHECK(web_view_test_proxy_->GetMainRenderFrame());
gfx::Size window_size = params->initial_size;

@ -18,7 +18,6 @@
#include "base/optional.h"
#include "base/strings/string16.h"
#include "content/public/common/page_state.h"
#include "content/shell/common/web_test/blink_test.mojom.h"
#include "content/shell/common/web_test/web_test.mojom.h"
#include "content/shell/common/web_test/web_test_bluetooth_fake_adapter_setter.mojom.h"
#include "content/shell/test_runner/test_preferences.h"
@ -212,10 +211,11 @@ class BlinkTestRunner {
void ClearTrustTokenState(base::OnceClosure callback);
// Message handlers forwarded by WebTestRenderFrameObserver.
void OnSetTestConfiguration(mojom::ShellTestConfigurationPtr params);
void OnReplicateTestConfiguration(mojom::ShellTestConfigurationPtr params);
void OnSetTestConfiguration(mojom::WebTestRunTestConfigurationPtr params);
void OnReplicateTestConfiguration(
mojom::WebTestRunTestConfigurationPtr params);
void OnSetupRendererProcessForNonTestWindow();
void CaptureDump(mojom::BlinkTestControl::CaptureDumpCallback callback);
void CaptureDump(mojom::WebTestRenderFrame::CaptureDumpCallback callback);
void DidCommitNavigationInMainFrame();
void OnResetRendererAfterWebTest();
void OnFinishTestInMainWindow();
@ -225,7 +225,7 @@ class BlinkTestRunner {
private:
// Helper reused by OnSetTestConfiguration and OnReplicateTestConfiguration.
void ApplyTestConfiguration(mojom::ShellTestConfigurationPtr params);
void ApplyTestConfiguration(mojom::WebTestRunTestConfigurationPtr params);
// After finishing the test, retrieves the audio, text, and pixel dumps from
// the TestRunner library and sends them to the browser process.
@ -239,9 +239,11 @@ class BlinkTestRunner {
mojo::Remote<mojom::WebTestBluetoothFakeAdapterSetter>
bluetooth_fake_adapter_setter_;
void HandleBlinkTestClientDisconnected();
mojo::AssociatedRemote<mojom::BlinkTestClient>& GetBlinkTestClientRemote();
mojo::AssociatedRemote<mojom::BlinkTestClient> blink_test_client_remote_;
void HandleWebTestControlHostDisconnected();
mojo::AssociatedRemote<mojom::WebTestControlHost>&
GetWebTestControlHostRemote();
mojo::AssociatedRemote<mojom::WebTestControlHost>
web_test_control_host_remote_;
void HandleWebTestClientDisconnected();
mojo::AssociatedRemote<mojom::WebTestClient>& GetWebTestClientRemote();
@ -251,7 +253,7 @@ class BlinkTestRunner {
TestPreferences prefs_;
mojom::ShellTestConfigurationPtr test_config_;
mojom::WebTestRunTestConfigurationPtr test_config_;
base::circular_deque<
base::OnceCallback<void(const std::vector<std::string>&)>>
@ -262,8 +264,8 @@ class BlinkTestRunner {
std::unique_ptr<AppBannerService> app_banner_service_;
mojom::BlinkTestControl::CaptureDumpCallback dump_callback_;
mojom::BlinkTestDumpPtr dump_result_;
mojom::WebTestRenderFrame::CaptureDumpCallback dump_callback_;
mojom::WebTestDumpPtr dump_result_;
bool waiting_for_layout_dump_results_ = false;
bool waiting_for_pixels_dump_result_ = false;

@ -44,17 +44,17 @@ WebTestRenderThreadObserver::~WebTestRenderThreadObserver() {
void WebTestRenderThreadObserver::RegisterMojoInterfaces(
blink::AssociatedInterfaceRegistry* associated_interfaces) {
associated_interfaces->AddInterface(base::BindRepeating(
&WebTestRenderThreadObserver::OnWebTestControlAssociatedRequest,
&WebTestRenderThreadObserver::OnWebTestRenderThreadAssociatedRequest,
base::Unretained(this)));
}
void WebTestRenderThreadObserver::UnregisterMojoInterfaces(
blink::AssociatedInterfaceRegistry* associated_interfaces) {
associated_interfaces->RemoveInterface(mojom::WebTestControl::Name_);
associated_interfaces->RemoveInterface(mojom::WebTestRenderThread::Name_);
}
void WebTestRenderThreadObserver::OnWebTestControlAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::WebTestControl> receiver) {
void WebTestRenderThreadObserver::OnWebTestRenderThreadAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::WebTestRenderThread> receiver) {
receiver_.reset();
receiver_.Bind(std::move(receiver));
}

@ -17,7 +17,7 @@ namespace content {
class TestInterfaces;
class WebTestRenderThreadObserver : public RenderThreadObserver,
public mojom::WebTestControl {
public mojom::WebTestRenderThread {
public:
static WebTestRenderThreadObserver* GetInstance();
@ -33,17 +33,17 @@ class WebTestRenderThreadObserver : public RenderThreadObserver,
blink::AssociatedInterfaceRegistry* associated_interfaces) override;
private:
// mojom::WebTestControl implementation.
// mojom::WebTestRenderThread implementation.
void ReplicateWebTestRuntimeFlagsChanges(
base::Value changed_layout_test_runtime_flags) override;
// Helper to bind this class as the mojom::WebTestControl.
void OnWebTestControlAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::WebTestControl> receiver);
// Helper to bind this class as the mojom::WebTestRenderThread.
void OnWebTestRenderThreadAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::WebTestRenderThread> receiver);
std::unique_ptr<TestInterfaces> test_interfaces_;
mojo::AssociatedReceiver<mojom::WebTestControl> receiver_{this};
mojo::AssociatedReceiver<mojom::WebTestRenderThread> receiver_{this};
DISALLOW_COPY_AND_ASSIGN(WebTestRenderThreadObserver);
};

@ -315,12 +315,12 @@ void WebFrameTestProxy::DumpFrameLayout(DumpFrameLayoutCallback callback) {
}
void WebFrameTestProxy::ReplicateTestConfiguration(
mojom::ShellTestConfigurationPtr config) {
mojom::WebTestRunTestConfigurationPtr config) {
blink_test_runner()->OnReplicateTestConfiguration(std::move(config));
}
void WebFrameTestProxy::SetTestConfiguration(
mojom::ShellTestConfigurationPtr config) {
mojom::WebTestRunTestConfigurationPtr config) {
blink_test_runner()->OnSetTestConfiguration(std::move(config));
}
@ -347,8 +347,8 @@ void WebFrameTestProxy::ReplyBluetoothManualChooserEvents(
}
void WebFrameTestProxy::BindReceiver(
mojo::PendingAssociatedReceiver<mojom::BlinkTestControl> receiver) {
blink_test_control_receiver_.Bind(
mojo::PendingAssociatedReceiver<mojom::WebTestRenderFrame> receiver) {
web_test_render_frame_receiver_.Bind(
std::move(receiver),
GetWebFrame()->GetTaskRunner(blink::TaskType::kInternalTest));
}

@ -11,7 +11,7 @@
#include "base/macros.h"
#include "content/renderer/render_frame_impl.h"
#include "content/shell/common/web_test/blink_test.mojom.h"
#include "content/shell/common/web_test/web_test.mojom.h"
#include "content/shell/test_runner/web_frame_test_client.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
@ -30,7 +30,7 @@ class WebWidgetTestProxy;
// RenderFrameImpl to inject test-only behaviour by overriding methods in the
// base class.
class WebFrameTestProxy : public RenderFrameImpl,
public mojom::BlinkTestControl {
public mojom::WebTestRenderFrame {
public:
explicit WebFrameTestProxy(RenderFrameImpl::CreateParams params);
~WebFrameTestProxy() override;
@ -74,13 +74,14 @@ class WebFrameTestProxy : public RenderFrameImpl,
void DidClearWindowObject() override;
private:
// mojom::BlinkTestControl implementation.
// mojom::WebTestRenderFrame implementation.
void CaptureDump(CaptureDumpCallback callback) override;
void CompositeWithRaster(CompositeWithRasterCallback callback) override;
void DumpFrameLayout(DumpFrameLayoutCallback callback) override;
void SetTestConfiguration(mojom::ShellTestConfigurationPtr config) override;
void SetTestConfiguration(
mojom::WebTestRunTestConfigurationPtr config) override;
void ReplicateTestConfiguration(
mojom::ShellTestConfigurationPtr config) override;
mojom::WebTestRunTestConfigurationPtr config) override;
void SetupRendererProcessForNonTestWindow() override;
void ResetRendererAfterWebTest() override;
void FinishTestInMainWindow() override;
@ -89,15 +90,15 @@ class WebFrameTestProxy : public RenderFrameImpl,
const std::vector<std::string>& events) override;
void BindReceiver(
mojo::PendingAssociatedReceiver<mojom::BlinkTestControl> receiver);
mojo::PendingAssociatedReceiver<mojom::WebTestRenderFrame> receiver);
BlinkTestRunner* blink_test_runner();
WebViewTestProxy* const web_view_test_proxy_;
WebFrameTestClient test_client_;
mojo::AssociatedReceiver<mojom::BlinkTestControl>
blink_test_control_receiver_{this};
mojo::AssociatedReceiver<mojom::WebTestRenderFrame>
web_test_render_frame_receiver_{this};
DISALLOW_COPY_AND_ASSIGN(WebFrameTestProxy);
};

@ -783,13 +783,12 @@ static_library("web_test_support_renderer") {
"//ui/events/blink",
"//ui/gfx/geometry",
# This is required to ensure
# content/shell/common/web_test/blink_test.mojom.h
# is generated before attempting to build this target. The file is included
# through content/shell/renderer/web_test/blink_test_runner.h. However
# This needs content/shell/common/web_test/web_test.mojom.h, and the file is
# included through
# content/shell/renderer/web_test/web_test_render_thread_observer.h. However
# adding a dependency on //content/shell:content_shell_lib as that would
# cause a circular dependency. Instead add this dependency directly to
# fix a flaky build (see https://crbug.com/971978 for more details).
# cause a circular dependency. Instead add this dependency directly to fix a
# flaky build (see https://crbug.com/971978 for more details).
"//content/shell:web_test_common_mojom",
]
}

@ -589,7 +589,7 @@ class SingleTestRunner(object):
if not expected_driver_output.image or not expected_driver_output.image_hash:
return []
# The presence of an expected image, but a lack of an outputted image
# does not signify an error. content::BlinkTestController checks the
# does not signify an error. content::WebTestControlHost checks the
# image_hash, and upon a match simply skips recording the outputted
# image. This even occurs when results_directory is set.
if not driver_output.image or not driver_output.image_hash: