Commit 4d27fa47 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Introduce WebTestClient interface to convert WebTestHostMsg to Mojo

As a second step to convert the content shell test harness, this CL
converts the below messages to Mojo by using WebTestClient interface.

 - WebTestHostMsg_SimulateWebNotificationClose
 - WebTestHostMsg_SimulateWebContentIndexDelete
 - WebTestHostMsg_InspectSecondaryWindow
 - WebTestHostMsg_TestFinishedInSecondaryRenderer

WebTestClientImpl class implements the methods of
WebTestClient interface.

Other WebTestHostMsg conversions will be prepared after this
initial CL.

Bug: 1039247
Change-Id: I3f021e7c17a5239c4eb1467d464a312411347b12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032697Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#738797}
parent c4030712
...@@ -184,6 +184,8 @@ jumbo_static_library("content_shell_lib") { ...@@ -184,6 +184,8 @@ jumbo_static_library("content_shell_lib") {
"browser/web_test/web_test_browser_main.h", "browser/web_test/web_test_browser_main.h",
"browser/web_test/web_test_browser_main_parts.cc", "browser/web_test/web_test_browser_main_parts.cc",
"browser/web_test/web_test_browser_main_parts.h", "browser/web_test/web_test_browser_main_parts.h",
"browser/web_test/web_test_client_impl.cc",
"browser/web_test/web_test_client_impl.h",
"browser/web_test/web_test_content_browser_client.cc", "browser/web_test/web_test_content_browser_client.cc",
"browser/web_test/web_test_content_browser_client.h", "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.cc",
...@@ -889,6 +891,7 @@ mojom("mojo_bindings") { ...@@ -889,6 +891,7 @@ mojom("mojo_bindings") {
sources = [ sources = [
"common/blink_test.mojom", "common/blink_test.mojom",
"common/power_monitor_test.mojom", "common/power_monitor_test.mojom",
"common/web_test.mojom",
"common/web_test/fake_bluetooth_chooser.mojom", "common/web_test/fake_bluetooth_chooser.mojom",
"common/web_test/web_test_bluetooth_fake_adapter_setter.mojom", "common/web_test/web_test_bluetooth_fake_adapter_setter.mojom",
] ]
......
// Copyright 2020 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_client_impl.h"
#include <memory>
#include <string>
#include <utility>
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_index_context.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_permission_manager.h"
#include "content/shell/test_runner/web_test_delegate.h"
#include "content/test/mock_platform_notification_service.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace content {
namespace {
MockPlatformNotificationService* GetMockPlatformNotificationService() {
auto* client = WebTestContentBrowserClient::Get();
auto* context = client->GetWebTestBrowserContext();
auto* service = client->GetPlatformNotificationService(context);
return static_cast<MockPlatformNotificationService*>(service);
}
WebTestContentIndexProvider* GetWebTestContentIndexProvider() {
auto* client = WebTestContentBrowserClient::Get();
auto* context = client->GetWebTestBrowserContext();
return static_cast<WebTestContentIndexProvider*>(
context->GetContentIndexProvider());
}
ContentIndexContext* GetContentIndexContext(const url::Origin& origin) {
auto* client = WebTestContentBrowserClient::Get();
auto* context = client->GetWebTestBrowserContext();
auto* storage_partition = BrowserContext::GetStoragePartitionForSite(
context, origin.GetURL(), /* can_create= */ false);
return storage_partition->GetContentIndexContext();
}
} // namespace
// static
void WebTestClientImpl::Create(
mojo::PendingReceiver<mojom::WebTestClient> receiver) {
mojo::MakeSelfOwnedReceiver(std::make_unique<WebTestClientImpl>(),
std::move(receiver));
}
void WebTestClientImpl::InspectSecondaryWindow() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (BlinkTestController::Get())
BlinkTestController::Get()->OnInspectSecondaryWindow();
}
void WebTestClientImpl::TestFinishedInSecondaryRenderer() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (BlinkTestController::Get())
BlinkTestController::Get()->OnTestFinishedInSecondaryRenderer();
}
void WebTestClientImpl::SimulateWebNotificationClose(const std::string& title,
bool by_user) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
GetMockPlatformNotificationService()->SimulateClose(title, by_user);
}
void WebTestClientImpl::SimulateWebContentIndexDelete(const std::string& id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* provider = GetWebTestContentIndexProvider();
std::pair<int64_t, url::Origin> registration_data =
provider->GetRegistrationDataFromId(id);
auto* context = GetContentIndexContext(registration_data.second);
context->OnUserDeletedItem(registration_data.first, registration_data.second,
id);
}
} // namespace content
// Copyright 2020 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_CLIENT_IMPL_H_
#define CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_CLIENT_IMPL_H_
#include "base/macros.h"
#include "content/shell/common/web_test.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
namespace content {
// WebTestClientImpl is an implementation of WebTestClient mojo interface that
// handles the communication from the renderer process to the browser process
// using the legacy IPC. This class is bound to a RenderProcessHost when it's
// initialized and is managed by the registry of the RenderProcessHost.
class WebTestClientImpl : public mojom::WebTestClient {
public:
WebTestClientImpl() = default;
~WebTestClientImpl() override = default;
WebTestClientImpl(const WebTestClientImpl&) = delete;
WebTestClientImpl& operator=(const WebTestClientImpl&) = delete;
static void Create(mojo::PendingReceiver<mojom::WebTestClient> receiver);
private:
// WebTestClient implementation.
void InspectSecondaryWindow() override;
void TestFinishedInSecondaryRenderer() override;
void SimulateWebNotificationClose(const std::string& title,
bool by_user) override;
void SimulateWebContentIndexDelete(const std::string& id) override;
};
} // namespace content
#endif // CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_CLIENT_IMPL_H_
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "content/shell/browser/web_test/web_test_bluetooth_fake_adapter_setter_impl.h" #include "content/shell/browser/web_test/web_test_bluetooth_fake_adapter_setter_impl.h"
#include "content/shell/browser/web_test/web_test_browser_context.h" #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_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_message_filter.h"
#include "content/shell/browser/web_test/web_test_permission_manager.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_controller_delegate.h"
...@@ -160,6 +161,9 @@ void WebTestContentBrowserClient::ExposeInterfacesToRenderer( ...@@ -160,6 +161,9 @@ void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
registry->AddInterface(base::BindRepeating(&BlinkTestClientImpl::Create), registry->AddInterface(base::BindRepeating(&BlinkTestClientImpl::Create),
ui_task_runner); ui_task_runner);
registry->AddInterface(base::BindRepeating(&WebTestClientImpl::Create),
ui_task_runner);
registry->AddInterface(base::BindRepeating(&bluetooth::FakeBluetooth::Create), registry->AddInterface(base::BindRepeating(&bluetooth::FakeBluetooth::Create),
ui_task_runner); ui_task_runner);
// This class outlives |render_process_host|, which owns |registry|. Since // This class outlives |render_process_host|, which owns |registry|. Since
......
...@@ -47,21 +47,6 @@ MockPlatformNotificationService* GetMockPlatformNotificationService() { ...@@ -47,21 +47,6 @@ MockPlatformNotificationService* GetMockPlatformNotificationService() {
return static_cast<MockPlatformNotificationService*>(service); return static_cast<MockPlatformNotificationService*>(service);
} }
WebTestContentIndexProvider* GetWebTestContentIndexProvider() {
auto* client = WebTestContentBrowserClient::Get();
auto* context = client->GetWebTestBrowserContext();
return static_cast<WebTestContentIndexProvider*>(
context->GetContentIndexProvider());
}
ContentIndexContext* GetContentIndexContext(const url::Origin& origin) {
auto* client = WebTestContentBrowserClient::Get();
auto* context = client->GetWebTestBrowserContext();
auto* storage_partition = BrowserContext::GetStoragePartitionForSite(
context, origin.GetURL(), /* can_create= */ false);
return storage_partition->GetContentIndexContext();
}
} // namespace } // namespace
WebTestMessageFilter::WebTestMessageFilter( WebTestMessageFilter::WebTestMessageFilter(
...@@ -91,14 +76,10 @@ WebTestMessageFilter::OverrideTaskRunnerForMessage( ...@@ -91,14 +76,10 @@ WebTestMessageFilter::OverrideTaskRunnerForMessage(
case WebTestHostMsg_ClearAllDatabases::ID: case WebTestHostMsg_ClearAllDatabases::ID:
return database_tracker_->task_runner(); return database_tracker_->task_runner();
case WebTestHostMsg_SimulateWebNotificationClick::ID: case WebTestHostMsg_SimulateWebNotificationClick::ID:
case WebTestHostMsg_SimulateWebNotificationClose::ID:
case WebTestHostMsg_SimulateWebContentIndexDelete::ID:
case WebTestHostMsg_SetPermission::ID: case WebTestHostMsg_SetPermission::ID:
case WebTestHostMsg_ResetPermissions::ID: case WebTestHostMsg_ResetPermissions::ID:
case WebTestHostMsg_WebTestRuntimeFlagsChanged::ID: case WebTestHostMsg_WebTestRuntimeFlagsChanged::ID:
case WebTestHostMsg_TestFinishedInSecondaryRenderer::ID:
case WebTestHostMsg_InitiateCaptureDump::ID: case WebTestHostMsg_InitiateCaptureDump::ID:
case WebTestHostMsg_InspectSecondaryWindow::ID:
case WebTestHostMsg_DeleteAllCookies::ID: case WebTestHostMsg_DeleteAllCookies::ID:
case WebTestHostMsg_GetWritableDirectory::ID: case WebTestHostMsg_GetWritableDirectory::ID:
case WebTestHostMsg_SetFilePathForMockFileDialog::ID: case WebTestHostMsg_SetFilePathForMockFileDialog::ID:
...@@ -117,21 +98,13 @@ bool WebTestMessageFilter::OnMessageReceived(const IPC::Message& message) { ...@@ -117,21 +98,13 @@ bool WebTestMessageFilter::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(WebTestHostMsg_SetDatabaseQuota, OnSetDatabaseQuota) IPC_MESSAGE_HANDLER(WebTestHostMsg_SetDatabaseQuota, OnSetDatabaseQuota)
IPC_MESSAGE_HANDLER(WebTestHostMsg_SimulateWebNotificationClick, IPC_MESSAGE_HANDLER(WebTestHostMsg_SimulateWebNotificationClick,
OnSimulateWebNotificationClick) OnSimulateWebNotificationClick)
IPC_MESSAGE_HANDLER(WebTestHostMsg_SimulateWebNotificationClose,
OnSimulateWebNotificationClose)
IPC_MESSAGE_HANDLER(WebTestHostMsg_SimulateWebContentIndexDelete,
OnSimulateWebContentIndexDelete)
IPC_MESSAGE_HANDLER(WebTestHostMsg_DeleteAllCookies, OnDeleteAllCookies) IPC_MESSAGE_HANDLER(WebTestHostMsg_DeleteAllCookies, OnDeleteAllCookies)
IPC_MESSAGE_HANDLER(WebTestHostMsg_SetPermission, OnSetPermission) IPC_MESSAGE_HANDLER(WebTestHostMsg_SetPermission, OnSetPermission)
IPC_MESSAGE_HANDLER(WebTestHostMsg_ResetPermissions, OnResetPermissions) IPC_MESSAGE_HANDLER(WebTestHostMsg_ResetPermissions, OnResetPermissions)
IPC_MESSAGE_HANDLER(WebTestHostMsg_WebTestRuntimeFlagsChanged, IPC_MESSAGE_HANDLER(WebTestHostMsg_WebTestRuntimeFlagsChanged,
OnWebTestRuntimeFlagsChanged) OnWebTestRuntimeFlagsChanged)
IPC_MESSAGE_HANDLER(WebTestHostMsg_TestFinishedInSecondaryRenderer,
OnTestFinishedInSecondaryRenderer)
IPC_MESSAGE_HANDLER(WebTestHostMsg_InitiateCaptureDump, IPC_MESSAGE_HANDLER(WebTestHostMsg_InitiateCaptureDump,
OnInitiateCaptureDump); OnInitiateCaptureDump)
IPC_MESSAGE_HANDLER(WebTestHostMsg_InspectSecondaryWindow,
OnInspectSecondaryWindow)
IPC_MESSAGE_HANDLER(WebTestHostMsg_GetWritableDirectory, IPC_MESSAGE_HANDLER(WebTestHostMsg_GetWritableDirectory,
OnGetWritableDirectory) OnGetWritableDirectory)
IPC_MESSAGE_HANDLER(WebTestHostMsg_SetFilePathForMockFileDialog, IPC_MESSAGE_HANDLER(WebTestHostMsg_SetFilePathForMockFileDialog,
...@@ -192,27 +165,6 @@ void WebTestMessageFilter::OnSimulateWebNotificationClick( ...@@ -192,27 +165,6 @@ void WebTestMessageFilter::OnSimulateWebNotificationClick(
reply); reply);
} }
void WebTestMessageFilter::OnSimulateWebNotificationClose(
const std::string& title,
bool by_user) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
GetMockPlatformNotificationService()->SimulateClose(title, by_user);
}
void WebTestMessageFilter::OnSimulateWebContentIndexDelete(
const std::string& id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto* provider = GetWebTestContentIndexProvider();
std::pair<int64_t, url::Origin> registration_data =
provider->GetRegistrationDataFromId(id);
auto* context = GetContentIndexContext(registration_data.second);
context->OnUserDeletedItem(registration_data.first, registration_data.second,
id);
}
void WebTestMessageFilter::OnDeleteAllCookies() { void WebTestMessageFilter::OnDeleteAllCookies() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
cookie_manager_->DeleteCookies(network::mojom::CookieDeletionFilter::New(), cookie_manager_->DeleteCookies(network::mojom::CookieDeletionFilter::New(),
...@@ -289,12 +241,6 @@ void WebTestMessageFilter::OnWebTestRuntimeFlagsChanged( ...@@ -289,12 +241,6 @@ void WebTestMessageFilter::OnWebTestRuntimeFlagsChanged(
} }
} }
void WebTestMessageFilter::OnTestFinishedInSecondaryRenderer() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (BlinkTestController::Get())
BlinkTestController::Get()->OnTestFinishedInSecondaryRenderer();
}
void WebTestMessageFilter::OnInitiateCaptureDump( void WebTestMessageFilter::OnInitiateCaptureDump(
bool capture_navigation_history, bool capture_navigation_history,
bool capture_pixels) { bool capture_pixels) {
...@@ -305,12 +251,6 @@ void WebTestMessageFilter::OnInitiateCaptureDump( ...@@ -305,12 +251,6 @@ void WebTestMessageFilter::OnInitiateCaptureDump(
} }
} }
void WebTestMessageFilter::OnInspectSecondaryWindow() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (BlinkTestController::Get())
BlinkTestController::Get()->OnInspectSecondaryWindow();
}
void WebTestMessageFilter::OnGetWritableDirectory(base::FilePath* path) { void WebTestMessageFilter::OnGetWritableDirectory(base::FilePath* path) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (BlinkTestController::Get()) if (BlinkTestController::Get())
......
...@@ -68,8 +68,6 @@ class WebTestMessageFilter : public BrowserMessageFilter { ...@@ -68,8 +68,6 @@ class WebTestMessageFilter : public BrowserMessageFilter {
const std::string& title, const std::string& title,
const base::Optional<int>& action_index, const base::Optional<int>& action_index,
const base::Optional<base::string16>& reply); const base::Optional<base::string16>& reply);
void OnSimulateWebNotificationClose(const std::string& title, bool by_user);
void OnSimulateWebContentIndexDelete(const std::string& id);
void OnDeleteAllCookies(); void OnDeleteAllCookies();
void OnSetPermission(const std::string& name, void OnSetPermission(const std::string& name,
blink::mojom::PermissionStatus status, blink::mojom::PermissionStatus status,
...@@ -78,10 +76,8 @@ class WebTestMessageFilter : public BrowserMessageFilter { ...@@ -78,10 +76,8 @@ class WebTestMessageFilter : public BrowserMessageFilter {
void OnResetPermissions(); void OnResetPermissions();
void OnWebTestRuntimeFlagsChanged( void OnWebTestRuntimeFlagsChanged(
const base::DictionaryValue& changed_web_test_runtime_flags); const base::DictionaryValue& changed_web_test_runtime_flags);
void OnTestFinishedInSecondaryRenderer();
void OnInitiateCaptureDump(bool capture_navigation_history, void OnInitiateCaptureDump(bool capture_navigation_history,
bool capture_pixels); bool capture_pixels);
void OnInspectSecondaryWindow();
void OnGetWritableDirectory(base::FilePath* path); void OnGetWritableDirectory(base::FilePath* path);
void OnSetFilePathForMockFileDialog(const base::FilePath& path); void OnSetFilePathForMockFileDialog(const base::FilePath& path);
......
// Copyright 2020 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;
// Web test messages sent from the renderer process to the browser.
interface WebTestClient {
// Start to inspect a secondary window.
InspectSecondaryWindow();
// Sent by secondary test window to notify the test has finished.
TestFinishedInSecondaryRenderer();
// Simulates a user deleting a content index entry.
SimulateWebContentIndexDelete(string id);
// Simulates closing a titled web notification depending on the user
// click.
// - |title|: the title of the notification.
// - |by_user|: whether the user clicks the notification.
SimulateWebNotificationClose(string title, bool by_user);
};
\ No newline at end of file
...@@ -32,11 +32,6 @@ IPC_MESSAGE_ROUTED3(WebTestHostMsg_SimulateWebNotificationClick, ...@@ -32,11 +32,6 @@ IPC_MESSAGE_ROUTED3(WebTestHostMsg_SimulateWebNotificationClick,
std::string /* title */, std::string /* title */,
base::Optional<int> /* action_index */, base::Optional<int> /* action_index */,
base::Optional<base::string16> /* reply */) base::Optional<base::string16> /* reply */)
IPC_MESSAGE_ROUTED2(WebTestHostMsg_SimulateWebNotificationClose,
std::string /* title */,
bool /* by_user */)
IPC_MESSAGE_ROUTED1(WebTestHostMsg_SimulateWebContentIndexDelete,
std::string /* id */)
IPC_MESSAGE_ROUTED1(WebTestHostMsg_BlockThirdPartyCookies, bool /* block */) IPC_MESSAGE_ROUTED1(WebTestHostMsg_BlockThirdPartyCookies, bool /* block */)
IPC_MESSAGE_ROUTED0(WebTestHostMsg_DeleteAllCookies) IPC_MESSAGE_ROUTED0(WebTestHostMsg_DeleteAllCookies)
IPC_MESSAGE_ROUTED4(WebTestHostMsg_SetPermission, IPC_MESSAGE_ROUTED4(WebTestHostMsg_SetPermission,
...@@ -45,7 +40,6 @@ IPC_MESSAGE_ROUTED4(WebTestHostMsg_SetPermission, ...@@ -45,7 +40,6 @@ IPC_MESSAGE_ROUTED4(WebTestHostMsg_SetPermission,
GURL /* origin */, GURL /* origin */,
GURL /* embedding_origin */) GURL /* embedding_origin */)
IPC_MESSAGE_ROUTED0(WebTestHostMsg_ResetPermissions) IPC_MESSAGE_ROUTED0(WebTestHostMsg_ResetPermissions)
IPC_MESSAGE_ROUTED0(WebTestHostMsg_InspectSecondaryWindow)
IPC_MESSAGE_ROUTED2(WebTestHostMsg_InitiateCaptureDump, IPC_MESSAGE_ROUTED2(WebTestHostMsg_InitiateCaptureDump,
bool /* should dump navigation history */, bool /* should dump navigation history */,
bool /* should dump pixels */) bool /* should dump pixels */)
...@@ -66,7 +60,4 @@ IPC_MESSAGE_CONTROL1(WebTestHostMsg_WebTestRuntimeFlagsChanged, ...@@ -66,7 +60,4 @@ IPC_MESSAGE_CONTROL1(WebTestHostMsg_WebTestRuntimeFlagsChanged,
IPC_MESSAGE_CONTROL1(WebTestMsg_ReplicateWebTestRuntimeFlagsChanges, IPC_MESSAGE_CONTROL1(WebTestMsg_ReplicateWebTestRuntimeFlagsChanges,
base::DictionaryValue /* changed_web_test_runtime_flags */) base::DictionaryValue /* changed_web_test_runtime_flags */)
// Sent by secondary test window to notify the test has finished.
IPC_MESSAGE_CONTROL0(WebTestHostMsg_TestFinishedInSecondaryRenderer)
#endif // CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_ #endif // CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_MESSAGES_H_
...@@ -292,7 +292,7 @@ void BlinkTestRunner::NavigateSecondaryWindow(const GURL& url) { ...@@ -292,7 +292,7 @@ void BlinkTestRunner::NavigateSecondaryWindow(const GURL& url) {
} }
void BlinkTestRunner::InspectSecondaryWindow() { void BlinkTestRunner::InspectSecondaryWindow() {
Send(new WebTestHostMsg_InspectSecondaryWindow(routing_id())); GetWebTestClientRemote().InspectSecondaryWindow();
} }
void BlinkTestRunner::ClearAllDatabases() { void BlinkTestRunner::ClearAllDatabases() {
...@@ -313,12 +313,11 @@ void BlinkTestRunner::SimulateWebNotificationClick( ...@@ -313,12 +313,11 @@ void BlinkTestRunner::SimulateWebNotificationClick(
void BlinkTestRunner::SimulateWebNotificationClose(const std::string& title, void BlinkTestRunner::SimulateWebNotificationClose(const std::string& title,
bool by_user) { bool by_user) {
Send(new WebTestHostMsg_SimulateWebNotificationClose(routing_id(), title, GetWebTestClientRemote().SimulateWebNotificationClose(title, by_user);
by_user));
} }
void BlinkTestRunner::SimulateWebContentIndexDelete(const std::string& id) { void BlinkTestRunner::SimulateWebContentIndexDelete(const std::string& id) {
Send(new WebTestHostMsg_SimulateWebContentIndexDelete(routing_id(), id)); GetWebTestClientRemote().SimulateWebContentIndexDelete(id);
} }
void BlinkTestRunner::SetDeviceScaleFactor(float factor) { void BlinkTestRunner::SetDeviceScaleFactor(float factor) {
...@@ -444,7 +443,7 @@ void BlinkTestRunner::TestFinished() { ...@@ -444,7 +443,7 @@ void BlinkTestRunner::TestFinished() {
// If we're not in the main frame, then ask the browser to redirect the call // If we're not in the main frame, then ask the browser to redirect the call
// to the main frame instead. // to the main frame instead.
if (!is_main_window_ || !render_view()->GetMainRenderFrame()) { if (!is_main_window_ || !render_view()->GetMainRenderFrame()) {
Send(new WebTestHostMsg_TestFinishedInSecondaryRenderer()); GetWebTestClientRemote().TestFinishedInSecondaryRenderer();
return; return;
} }
...@@ -746,6 +745,14 @@ BlinkTestRunner::GetBluetoothFakeAdapterSetter() { ...@@ -746,6 +745,14 @@ BlinkTestRunner::GetBluetoothFakeAdapterSetter() {
} }
mojom::BlinkTestClient& BlinkTestRunner::GetBlinkTestClientRemote() { mojom::BlinkTestClient& BlinkTestRunner::GetBlinkTestClientRemote() {
if (!blink_test_client_remote_) {
RenderThread::Get()->BindHostReceiver(
blink_test_client_remote_.BindNewPipeAndPassReceiver());
}
return *blink_test_client_remote_;
}
mojom::WebTestClient& BlinkTestRunner::GetWebTestClientRemote() {
if (!web_test_client_remote_) { if (!web_test_client_remote_) {
RenderThread::Get()->BindHostReceiver( RenderThread::Get()->BindHostReceiver(
web_test_client_remote_.BindNewPipeAndPassReceiver()); web_test_client_remote_.BindNewPipeAndPassReceiver());
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "content/public/renderer/render_view_observer.h" #include "content/public/renderer/render_view_observer.h"
#include "content/public/renderer/render_view_observer_tracker.h" #include "content/public/renderer/render_view_observer_tracker.h"
#include "content/shell/common/blink_test.mojom.h" #include "content/shell/common/blink_test.mojom.h"
#include "content/shell/common/web_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_bluetooth_fake_adapter_setter.mojom.h"
#include "content/shell/test_runner/test_preferences.h" #include "content/shell/test_runner/test_preferences.h"
#include "content/shell/test_runner/web_test_delegate.h" #include "content/shell/test_runner/web_test_delegate.h"
...@@ -181,7 +182,10 @@ class BlinkTestRunner : public RenderViewObserver, ...@@ -181,7 +182,10 @@ class BlinkTestRunner : public RenderViewObserver,
bluetooth_fake_adapter_setter_; bluetooth_fake_adapter_setter_;
mojom::BlinkTestClient& GetBlinkTestClientRemote(); mojom::BlinkTestClient& GetBlinkTestClientRemote();
mojo::Remote<mojom::BlinkTestClient> web_test_client_remote_; mojo::Remote<mojom::BlinkTestClient> blink_test_client_remote_;
mojom::WebTestClient& GetWebTestClientRemote();
mojo::Remote<mojom::WebTestClient> web_test_client_remote_;
test_runner::TestPreferences prefs_; test_runner::TestPreferences prefs_;
......
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