Commit 1af0cc65 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Reland "Convert WebTestHostMsg_InitiateCaptureDump to Mojo"

This is a re-land of ec6127ba.

The flakiness caused by the original CL doesn't happen after converting
WebTestHostMsg_WebTestRuntimeFlagsChanged.

Additionally, this CL removes unused WebTestMessageFilter classes.

Original change's description:
> Convert WebTestHostMsg_InitiateCaptureDump to Mojo
>
> This CL migrates the legacy InitiateCaptureDump IPC message
> to the new Mojo defined in WebTestClient interface.
>
> Bug: 1039247
> Change-Id: Idd38ecf67d10593f3bfc6f3c48d9832514cec595
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032634
> Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
> Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
> Reviewed-by: Mike West <mkwst@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#739222}

Bug: 1039247, 1049919
Change-Id: Ie58a28d6e6dddd26f59849da24579251ad7a970d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2043612
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747116}
parent b0b7ab71
......@@ -56,8 +56,6 @@ source_set("web_test_messages") {
# the message headers.
"common/web_test/blink_test_messages.cc",
"common/web_test/blink_test_messages.h",
"common/web_test/web_test_messages.cc",
"common/web_test/web_test_messages.h",
]
deps = [
......@@ -198,8 +196,6 @@ jumbo_static_library("content_shell_lib") {
"browser/web_test/web_test_first_device_bluetooth_chooser.h",
"browser/web_test/web_test_javascript_dialog_manager.cc",
"browser/web_test/web_test_javascript_dialog_manager.h",
"browser/web_test/web_test_message_filter.cc",
"browser/web_test/web_test_message_filter.h",
"browser/web_test/web_test_permission_manager.cc",
"browser/web_test/web_test_permission_manager.h",
"browser/web_test/web_test_push_messaging_service.cc",
......
......@@ -70,7 +70,6 @@
#include "content/shell/browser/web_test/web_test_devtools_bindings.h"
#include "content/shell/browser/web_test/web_test_first_device_bluetooth_chooser.h"
#include "content/shell/common/web_test/blink_test_messages.h"
#include "content/shell/common/web_test/web_test_messages.h"
#include "content/shell/common/web_test/web_test_switches.h"
#include "content/shell/common/web_test/web_test_utils.h"
#include "content/shell/renderer/web_test/blink_test_helpers.h"
......
......@@ -288,4 +288,13 @@ void WebTestClientImpl::SetDatabaseQuota(int32_t quota) {
base::BindOnce(&SetDatabaseQuotaOnIOThread, quota_manager_, quota));
}
void WebTestClientImpl::InitiateCaptureDump(bool capture_navigation_history,
bool capture_pixels) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (BlinkTestController::Get()) {
BlinkTestController::Get()->OnInitiateCaptureDump(
capture_navigation_history, capture_pixels);
}
}
} // namespace content
......@@ -69,6 +69,8 @@ class WebTestClientImpl : public mojom::WebTestClient {
void DeleteAllCookies() override;
void ClearAllDatabases() override;
void SetDatabaseQuota(int32_t quota) override;
void InitiateCaptureDump(bool capture_navigation_history,
bool capture_pixels) override;
void GetWritableDirectory(GetWritableDirectoryCallback callback) override;
void RegisterIsolatedFileSystem(
const std::vector<base::FilePath>& absolute_filenames,
......
......@@ -35,7 +35,6 @@
#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_message_filter.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"
......@@ -145,8 +144,6 @@ WebTestContentBrowserClient::GetNextFakeBluetoothChooser() {
void WebTestContentBrowserClient::RenderProcessWillLaunch(
RenderProcessHost* host) {
ShellContentBrowserClient::RenderProcessWillLaunch(host);
host->AddFilter(new WebTestMessageFilter(host->GetID()));
}
void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
......
// Copyright 2013 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.
#include "content/shell/browser/web_test/web_test_message_filter.h"
#include <stddef.h>
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/content_index_context.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/permission_type.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/web_test_support.h"
#include "content/shell/browser/shell_browser_context.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_permission_manager.h"
#include "content/shell/common/web_test/web_test_messages.h"
#include "content/shell/test_runner/web_test_delegate.h"
#include "content/test/mock_platform_notification_service.h"
#include "net/base/completion_once_callback.h"
#include "net/base/net_errors.h"
#include "services/network/public/mojom/network_service.mojom.h"
#include "url/origin.h"
namespace content {
WebTestMessageFilter::WebTestMessageFilter(int render_process_id)
: BrowserMessageFilter(WebTestMsgStart),
render_process_id_(render_process_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
WebTestMessageFilter::~WebTestMessageFilter() {}
void WebTestMessageFilter::OnDestruct() const {
BrowserThread::DeleteOnUIThread::Destruct(this);
}
scoped_refptr<base::SequencedTaskRunner>
WebTestMessageFilter::OverrideTaskRunnerForMessage(
const IPC::Message& message) {
switch (message.type()) {
case WebTestHostMsg_InitiateCaptureDump::ID:
return base::CreateSingleThreadTaskRunner({BrowserThread::UI});
}
return nullptr;
}
bool WebTestMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebTestMessageFilter, message)
IPC_MESSAGE_HANDLER(WebTestHostMsg_InitiateCaptureDump,
OnInitiateCaptureDump)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void WebTestMessageFilter::OnInitiateCaptureDump(
bool capture_navigation_history,
bool capture_pixels) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (BlinkTestController::Get()) {
BlinkTestController::Get()->OnInitiateCaptureDump(
capture_navigation_history, capture_pixels);
}
}
void WebTestMessageFilter::OnSetFilePathForMockFileDialog(
const base::FilePath& path) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (BlinkTestController::Get())
BlinkTestController::Get()->SetFilePathForMockFileDialog(path);
}
} // namespace content
// Copyright 2013 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.
#ifndef CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_MESSAGE_FILTER_H_
#define CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_MESSAGE_FILTER_H_
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/macros.h"
#include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace content {
class WebTestMessageFilter : public BrowserMessageFilter {
public:
explicit WebTestMessageFilter(int render_process_id);
private:
friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::UI>;
friend class base::DeleteHelper<WebTestMessageFilter>;
~WebTestMessageFilter() override;
// BrowserMessageFilter implementation.
void OnDestruct() const override;
scoped_refptr<base::SequencedTaskRunner> OverrideTaskRunnerForMessage(
const IPC::Message& message) override;
bool OnMessageReceived(const IPC::Message& message) override;
void OnInitiateCaptureDump(bool capture_navigation_history,
bool capture_pixels);
void OnSetFilePathForMockFileDialog(const base::FilePath& path);
int render_process_id_;
DISALLOW_COPY_AND_ASSIGN(WebTestMessageFilter);
};
} // namespace content
#endif // CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_MESSAGE_FILTER_H_
......@@ -91,4 +91,7 @@ interface WebTestClient {
// For the duration of the current test this causes all file choosers to
// return the passed in |path|.
SetFilePathForMockFileDialog(mojo_base.mojom.FilePath path);
// Initialize to dump the main frame with a navigation history or pixels.
InitiateCaptureDump(bool capture_navigation_history, bool capture_pixels);
};
// Copyright 2014 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.
// Get basic type definitions.
#define IPC_MESSAGE_IMPL
#undef CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
#include "content/shell/common/web_test/web_test_messages.h"
// Generate constructors.
#include "ipc/struct_constructor_macros.h"
#undef CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
#include "content/shell/common/web_test/web_test_messages.h"
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
#undef CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
#include "content/shell/common/web_test/web_test_messages.h"
} // namespace IPC
// Generate param traits read methods.
#include "ipc/param_traits_read_macros.h"
namespace IPC {
#undef CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
#include "content/shell/common/web_test/web_test_messages.h"
} // namespace IPC
// Generate param traits log methods.
#include "ipc/param_traits_log_macros.h"
namespace IPC {
#undef CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
#include "content/shell/common/web_test/web_test_messages.h"
} // namespace IPC
// Copyright 2014 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.
#ifndef CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
#define CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
#include <string>
#include <vector>
#include "content/public/common/common_param_traits_macros.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h"
#include "third_party/blink/public/mojom/permissions/permission_status.mojom-forward.h"
#include "url/gurl.h"
#include "url/ipc/url_param_traits.h"
#define IPC_MESSAGE_START WebTestMsgStart
IPC_MESSAGE_ROUTED2(WebTestHostMsg_InitiateCaptureDump,
bool /* should dump navigation history */,
bool /* should dump pixels */)
#endif // CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
......@@ -43,7 +43,6 @@
#include "content/public/test/web_test_support.h"
#include "content/shell/common/shell_switches.h"
#include "content/shell/common/web_test/blink_test_messages.h"
#include "content/shell/common/web_test/web_test_messages.h"
#include "content/shell/renderer/web_test/blink_test_helpers.h"
#include "content/shell/renderer/web_test/web_test_render_thread_observer.h"
#include "content/shell/test_runner/app_banner_service.h"
......@@ -447,9 +446,9 @@ void BlinkTestRunner::TestFinished() {
if (interfaces->TestRunner()->ShouldDumpAsAudio()) {
CaptureLocalAudioDump();
Send(new WebTestHostMsg_InitiateCaptureDump(
routing_id(), browser_should_dump_back_forward_list,
/*browser_should_capture_pixels=*/false));
GetWebTestClientRemote().InitiateCaptureDump(
browser_should_dump_back_forward_list,
/*browser_should_capture_pixels=*/false);
return;
}
......@@ -460,9 +459,9 @@ void BlinkTestRunner::TestFinished() {
CaptureLocalLayoutDump();
if (!interfaces->TestRunner()->ShouldGeneratePixelResults()) {
Send(new WebTestHostMsg_InitiateCaptureDump(
routing_id(), browser_should_dump_back_forward_list,
/*browser_should_capture_pixels=*/false));
GetWebTestClientRemote().InitiateCaptureDump(
browser_should_dump_back_forward_list,
/*browser_should_capture_pixels=*/false);
return;
}
......@@ -480,9 +479,9 @@ void BlinkTestRunner::TestFinished() {
web_frame->GetSelectionBoundsRectForTesting();
}
}
Send(new WebTestHostMsg_InitiateCaptureDump(
routing_id(), browser_should_dump_back_forward_list,
!interfaces->TestRunner()->CanDumpPixelsFromRenderer()));
GetWebTestClientRemote().InitiateCaptureDump(
browser_should_dump_back_forward_list,
!interfaces->TestRunner()->CanDumpPixelsFromRenderer());
}
void BlinkTestRunner::CaptureLocalAudioDump() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment