Commit dd0400c5 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Fix flakiness tests and null crashes caused by the wrong mojo conversion

Null crashes and flakiness test failures have taken place after
converting WebTestHostMsg_InitiateCaptureDump and BlinkTestHostMsg_PrintMessage.

The flakiness happened when a message came from different frames
almost simultaneously. But, existing implementation was implemented by
using Remote instead of AssociatedRemote. So, a race condition happened.

Clusterfuzz has reported crashes that happened in BlinkTestController.
The crashes happened in case of when BlinkTestClientImpl called
functions of BlinkTestController even after BlinkTestController
was destroyed. So, this CL makes BlinkTestController inherit
BlinkTestClient interface directly in order to completely eliminate
the possibility of the crash.

Bug: 1059322, 1059474, 1061180, 1061328, 1061441
Change-Id: Icd499c76e812565e24afd1d7ebf54b82202cf88d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2104567
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@{#751622}
parent 960585d2
......@@ -124,8 +124,6 @@ jumbo_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_client_impl.cc",
"browser/web_test/blink_test_client_impl.h",
"browser/web_test/blink_test_controller.cc",
"browser/web_test/blink_test_controller.h",
"browser/web_test/devtools_protocol_test_bindings.cc",
......
// 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/blink_test_client_impl.h"
#include <memory>
#include <string>
#include <utility>
#include "content/shell/browser/web_test/blink_test_controller.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace content {
// static
void BlinkTestClientImpl::Create(
mojo::PendingReceiver<mojom::BlinkTestClient> receiver) {
mojo::MakeSelfOwnedReceiver(std::make_unique<BlinkTestClientImpl>(),
std::move(receiver));
}
void BlinkTestClientImpl::InitiateLayoutDump() {
BlinkTestController::Get()->OnInitiateLayoutDump();
}
void BlinkTestClientImpl::ResetDone() {
BlinkTestController::Get()->OnResetDone();
}
void BlinkTestClientImpl::PrintMessageToStderr(const std::string& message) {
BlinkTestController::Get()->OnPrintMessageToStderr(message);
}
void BlinkTestClientImpl::PrintMessage(const std::string& message) {
BlinkTestController::Get()->OnPrintMessage(message);
}
void BlinkTestClientImpl::Reload() {
BlinkTestController::Get()->OnReload();
}
void BlinkTestClientImpl::OverridePreferences(
const content::WebPreferences& web_preferences) {
BlinkTestController::Get()->OnOverridePreferences(web_preferences);
}
void BlinkTestClientImpl::CloseRemainingWindows() {
BlinkTestController::Get()->OnCloseRemainingWindows();
}
void BlinkTestClientImpl::GoToOffset(int offset) {
BlinkTestController::Get()->OnGoToOffset(offset);
}
void BlinkTestClientImpl::SendBluetoothManualChooserEvent(
const std::string& event,
const std::string& argument) {
BlinkTestController::Get()->OnSendBluetoothManualChooserEvent(event,
argument);
}
void BlinkTestClientImpl::SetBluetoothManualChooser(bool enable) {
BlinkTestController::Get()->OnSetBluetoothManualChooser(enable);
}
void BlinkTestClientImpl::GetBluetoothManualChooserEvents() {
BlinkTestController::Get()->OnGetBluetoothManualChooserEvents();
}
void BlinkTestClientImpl::SetPopupBlockingEnabled(bool block_popups) {
BlinkTestController::Get()->OnSetPopupBlockingEnabled(block_popups);
}
void BlinkTestClientImpl::LoadURLForFrame(const GURL& url,
const std::string& frame_name) {
BlinkTestController::Get()->OnLoadURLForFrame(url, frame_name);
}
void BlinkTestClientImpl::NavigateSecondaryWindow(const GURL& url) {
BlinkTestController::Get()->OnNavigateSecondaryWindow(url);
}
void BlinkTestClientImpl::SetScreenOrientationChanged() {
BlinkTestController::Get()->OnSetScreenOrientationChanged();
}
} // 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_BLINK_TEST_CLIENT_IMPL_H_
#define CONTENT_SHELL_BROWSER_WEB_TEST_BLINK_TEST_CLIENT_IMPL_H_
#include "base/macros.h"
#include "content/public/common/web_preferences.h"
#include "content/shell/common/blink_test.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "url/gurl.h"
namespace content {
class BlinkTestClientImpl : public mojom::BlinkTestClient {
public:
BlinkTestClientImpl() = default;
~BlinkTestClientImpl() override = default;
static void Create(mojo::PendingReceiver<mojom::BlinkTestClient> receiver);
private:
// BlinkTestClient implementation.
void InitiateLayoutDump() override;
void ResetDone() override;
void PrintMessageToStderr(const std::string& message) override;
void PrintMessage(const std::string& message) override;
void Reload() override;
void OverridePreferences(
const content::WebPreferences& web_preferences) override;
void CloseRemainingWindows() override;
void GoToOffset(int offset) override;
void SendBluetoothManualChooserEvent(const std::string& event,
const std::string& argument) override;
void SetBluetoothManualChooser(bool enable) override;
void GetBluetoothManualChooserEvents() override;
void SetPopupBlockingEnabled(bool block_popups) override;
void LoadURLForFrame(const GURL& url, const std::string& frame_name) override;
void NavigateSecondaryWindow(const GURL& url) override;
void SetScreenOrientationChanged() override;
DISALLOW_COPY_AND_ASSIGN(BlinkTestClientImpl);
};
} // namespace content
#endif // CONTENT_SHELL_BROWSER_WEB_TEST_BLINK_TEST_CLIENT_IMPL_H_
......@@ -579,6 +579,7 @@ bool BlinkTestController::ResetAfterWebTest() {
WebTestContentBrowserClient::Get()->ResetFakeBluetoothDelegate();
navigation_history_dump_ = "";
pixel_dump_.reset();
blink_test_client_receivers_.Clear();
actual_pixel_hash_ = "";
main_frame_dump_ = nullptr;
waiting_for_pixel_results_ = false;
......@@ -1217,7 +1218,7 @@ void BlinkTestController::OnTextDump(const std::string& dump) {
printer_->PrintTextFooter();
}
void BlinkTestController::OnInitiateLayoutDump() {
void BlinkTestController::InitiateLayoutDump() {
// There should be at most 1 layout dump in progress at any given time.
DCHECK_EQ(0, pending_layout_dumps_);
......@@ -1293,15 +1294,15 @@ void BlinkTestController::OnDumpFrameLayoutResponse(int frame_tree_node_id,
->LayoutDumpCompleted(stitched_layout_dump);
}
void BlinkTestController::OnPrintMessage(const std::string& message) {
printer_->AddMessageRaw(message);
void BlinkTestController::PrintMessageToStderr(const std::string& message) {
printer_->AddMessageToStderr(message);
}
void BlinkTestController::OnPrintMessageToStderr(const std::string& message) {
printer_->AddMessageToStderr(message);
void BlinkTestController::PrintMessage(const std::string& message) {
printer_->AddMessageRaw(message);
}
void BlinkTestController::OnOverridePreferences(const WebPreferences& prefs) {
void BlinkTestController::OverridePreferences(const WebPreferences& prefs) {
should_override_prefs_ = true;
prefs_ = prefs;
......@@ -1315,11 +1316,11 @@ void BlinkTestController::OnOverridePreferences(const WebPreferences& prefs) {
main_render_view_host->OnWebkitPreferencesChanged();
}
void BlinkTestController::OnSetPopupBlockingEnabled(bool block_popups) {
void BlinkTestController::SetPopupBlockingEnabled(bool block_popups) {
WebTestContentBrowserClient::Get()->SetPopupBlockingEnabled(block_popups);
}
void BlinkTestController::OnNavigateSecondaryWindow(const GURL& url) {
void BlinkTestController::NavigateSecondaryWindow(const GURL& url) {
if (secondary_window_)
secondary_window_->LoadURL(url);
}
......@@ -1329,7 +1330,7 @@ void BlinkTestController::OnInspectSecondaryWindow() {
devtools_bindings_->Attach();
}
void BlinkTestController::OnSetScreenOrientationChanged() {
void BlinkTestController::SetScreenOrientationChanged() {
WebTestContentBrowserClient::Get()->SetScreenOrientationChanged(true);
}
......@@ -1404,30 +1405,30 @@ void BlinkTestController::SetFilePathForMockFileDialog(
ui::SelectFileDialog::SetFactory(new FakeSelectFileDialogFactory(path));
}
void BlinkTestController::OnGoToOffset(int offset) {
void BlinkTestController::GoToOffset(int offset) {
main_window_->GoBackOrForward(offset);
}
void BlinkTestController::OnReload() {
void BlinkTestController::Reload() {
main_window_->Reload();
}
void BlinkTestController::OnLoadURLForFrame(const GURL& url,
const std::string& frame_name) {
void BlinkTestController::LoadURLForFrame(const GURL& url,
const std::string& frame_name) {
main_window_->LoadURLForFrame(url, frame_name, ui::PAGE_TRANSITION_LINK);
}
void BlinkTestController::OnCloseRemainingWindows() {
void BlinkTestController::CloseRemainingWindows() {
DevToolsAgentHost::DetachAllClients();
std::vector<Shell*> open_windows(Shell::windows());
for (size_t i = 0; i < open_windows.size(); ++i) {
if (open_windows[i] != main_window_ && open_windows[i] != secondary_window_)
open_windows[i]->Close();
for (auto* shell : open_windows) {
if (shell != main_window_ && shell != secondary_window_)
shell->Close();
}
base::RunLoop().RunUntilIdle();
}
void BlinkTestController::OnResetDone() {
void BlinkTestController::ResetDone() {
if (leak_detector_) {
if (main_window_ && main_window_->web_contents()) {
RenderViewHost* rvh = main_window_->web_contents()->GetRenderViewHost();
......@@ -1456,14 +1457,14 @@ void BlinkTestController::OnLeakDetectionDone(
DiscardMainWindow();
}
void BlinkTestController::OnSetBluetoothManualChooser(bool enable) {
void BlinkTestController::SetBluetoothManualChooser(bool enable) {
bluetooth_chooser_factory_.reset();
if (enable) {
bluetooth_chooser_factory_.reset(new WebTestBluetoothChooserFactory());
}
}
void BlinkTestController::OnGetBluetoothManualChooserEvents() {
void BlinkTestController::GetBluetoothManualChooserEvents() {
if (!bluetooth_chooser_factory_) {
printer_->AddErrorMessage(
"FAIL: Must call setBluetoothManualChooser before "
......@@ -1476,7 +1477,7 @@ void BlinkTestController::OnGetBluetoothManualChooserEvents() {
bluetooth_chooser_factory_->GetAndResetEvents());
}
void BlinkTestController::OnSendBluetoothManualChooserEvent(
void BlinkTestController::SendBluetoothManualChooserEvent(
const std::string& event_name,
const std::string& argument) {
if (!bluetooth_chooser_factory_) {
......@@ -1501,7 +1502,7 @@ void BlinkTestController::OnSendBluetoothManualChooserEvent(
bluetooth_chooser_factory_->SendEvent(event, argument);
}
void BlinkTestController::OnBlockThirdPartyCookies(bool block) {
void BlinkTestController::BlockThirdPartyCookies(bool block) {
ShellBrowserContext* browser_context =
ShellContentBrowserClient::Get()->browser_context();
browser_context->GetDefaultStoragePartition(browser_context)
......@@ -1509,6 +1510,11 @@ void BlinkTestController::OnBlockThirdPartyCookies(bool block) {
->BlockThirdPartyCookies(block);
}
void BlinkTestController::AddBlinkTestClientReceiver(
mojo::PendingAssociatedReceiver<mojom::BlinkTestClient> receiver) {
blink_test_client_receivers_.Add(this, std::move(receiver));
}
mojo::AssociatedRemote<mojom::BlinkTestControl>&
BlinkTestController::GetBlinkTestControlRemote(RenderFrameHost* frame) {
GlobalFrameRoutingId key(frame->GetProcess()->GetID(), frame->GetRoutingID());
......
......@@ -35,6 +35,7 @@
#include "content/shell/browser/web_test/leak_detector.h"
#include "content/shell/common/blink_test.mojom.h"
#include "content/shell/common/web_test.mojom.h"
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "ui/gfx/geometry/size.h"
......@@ -110,7 +111,8 @@ class BlinkTestResultPrinter {
class BlinkTestController : public WebContentsObserver,
public RenderProcessHostObserver,
public NotificationObserver,
public GpuDataManagerObserver {
public GpuDataManagerObserver,
public mojom::BlinkTestClient {
public:
static BlinkTestController* Get();
......@@ -159,6 +161,9 @@ class BlinkTestController : public WebContentsObserver,
// return the passed in path.
void SetFilePathForMockFileDialog(const base::FilePath& path);
void AddBlinkTestClientReceiver(
mojo::PendingAssociatedReceiver<mojom::BlinkTestClient> receiver);
// WebContentsObserver implementation.
void PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) override;
......@@ -190,23 +195,25 @@ class BlinkTestController : public WebContentsObserver,
return accumulated_web_test_runtime_flags_changes_;
}
void OnInitiateLayoutDump();
void OnResetDone();
void OnPrintMessageToStderr(const std::string& message);
void OnPrintMessage(const std::string& message);
void OnReload();
void OnOverridePreferences(const WebPreferences& prefs);
void OnCloseRemainingWindows();
void OnGoToOffset(int offset);
void OnSetBluetoothManualChooser(bool enable);
void OnGetBluetoothManualChooserEvents();
void OnSendBluetoothManualChooserEvent(const std::string& event,
const std::string& argument);
void OnSetPopupBlockingEnabled(bool block_popups);
void OnLoadURLForFrame(const GURL& url, const std::string& frame_name);
void OnNavigateSecondaryWindow(const GURL& url);
void OnBlockThirdPartyCookies(bool block);
void OnSetScreenOrientationChanged();
// BlinkTestClient implementation.
void InitiateLayoutDump() override;
void ResetDone() override;
void PrintMessageToStderr(const std::string& message) override;
void PrintMessage(const std::string& message) override;
void Reload() override;
void OverridePreferences(
const content::WebPreferences& web_preferences) override;
void CloseRemainingWindows() override;
void GoToOffset(int offset) override;
void SendBluetoothManualChooserEvent(const std::string& event,
const std::string& argument) override;
void SetBluetoothManualChooser(bool enable) override;
void GetBluetoothManualChooserEvents() override;
void SetPopupBlockingEnabled(bool block_popups) override;
void LoadURLForFrame(const GURL& url, const std::string& frame_name) override;
void NavigateSecondaryWindow(const GURL& url) override;
void SetScreenOrientationChanged() override;
void BlockThirdPartyCookies(bool block);
private:
enum TestPhase { BETWEEN_TESTS, DURING_TEST, CLEAN_UP };
......@@ -352,6 +359,9 @@ class BlinkTestController : public WebContentsObserver,
std::map<RenderProcessHost*, mojo::AssociatedRemote<mojom::WebTestControl>>
web_test_control_map_;
mojo::AssociatedReceiverSet<mojom::BlinkTestClient>
blink_test_client_receivers_;
base::ScopedTempDir writable_directory_for_tests_;
SEQUENCE_CHECKER(sequence_checker_);
......
......@@ -150,7 +150,7 @@ void WebTestClientImpl::SimulateWebContentIndexDelete(const std::string& id) {
}
void WebTestClientImpl::BlockThirdPartyCookies(bool block) {
BlinkTestController::Get()->OnBlockThirdPartyCookies(block);
BlinkTestController::Get()->BlockThirdPartyCookies(block);
}
void WebTestClientImpl::ResetPermissions() {
......
......@@ -26,7 +26,6 @@
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/web_test/blink_test_client_impl.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"
......@@ -39,6 +38,7 @@
#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/blink_test.mojom.h"
#include "content/shell/common/web_test/web_test_switches.h"
#include "content/shell/renderer/web_test/blink_test_helpers.h"
#include "content/test/mock_clipboard_host.h"
......@@ -48,6 +48,7 @@
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/service_manager/public/cpp/binder_map.h"
#include "storage/browser/quota/quota_settings.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "url/origin.h"
namespace content {
......@@ -156,9 +157,6 @@ void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
registry->AddInterface(
base::BindRepeating(&WebTestBluetoothFakeAdapterSetterImpl::Create),
ui_task_runner);
registry->AddInterface(base::BindRepeating(&BlinkTestClientImpl::Create),
ui_task_runner);
StoragePartition* partition =
BrowserContext::GetDefaultStoragePartition(browser_context());
registry->AddInterface(base::BindRepeating(&WebTestClientImpl::Create,
......@@ -190,6 +188,10 @@ void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
&WebTestContentBrowserClient::BindPermissionAutomation,
base::Unretained(this)),
ui_task_runner);
associated_registry->AddInterface(
base::BindRepeating(&WebTestContentBrowserClient::BindBlinkTestController,
base::Unretained(this)));
}
void WebTestContentBrowserClient::BindClientHintsControllerDelegate(
......@@ -404,4 +406,10 @@ 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));
}
} // namespace content
......@@ -11,7 +11,9 @@
#include "content/public/common/client_hints.mojom.h"
#include "content/shell/browser/shell_content_browser_client.h"
#include "content/shell/common/blink_test.mojom-forward.h"
#include "content/shell/common/web_test/fake_bluetooth_chooser.mojom-forward.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/service_manager/public/cpp/binder_map.h"
#include "services/service_manager/public/cpp/binder_registry.h"
......@@ -109,6 +111,9 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
void BindPermissionAutomation(
mojo::PendingReceiver<blink::test::mojom::PermissionAutomation> receiver);
void BindBlinkTestController(
mojo::PendingAssociatedReceiver<mojom::BlinkTestClient> receiver);
std::unique_ptr<MockPlatformNotificationService>
mock_platform_notification_service_;
bool block_popups_ = false;
......
......@@ -50,6 +50,7 @@
#include "content/shell/test_runner/web_test_interfaces.h"
#include "content/shell/test_runner/web_test_runner.h"
#include "content/shell/test_runner/web_widget_test_proxy.h"
#include "ipc/ipc_sync_channel.h"
#include "media/base/audio_capturer_source.h"
#include "media/base/audio_parameters.h"
#include "media/capture/video_capturer_source.h"
......@@ -58,6 +59,7 @@
#include "net/base/net_errors.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/mojom/app_banner/app_banner.mojom.h"
......@@ -180,12 +182,12 @@ void BlinkTestRunner::SetEditCommand(const std::string& name,
}
void BlinkTestRunner::PrintMessageToStderr(const std::string& message) {
GetBlinkTestClientRemote().PrintMessageToStderr(message);
GetBlinkTestClientRemote()->PrintMessageToStderr(message);
}
void BlinkTestRunner::PrintMessage(const std::string& message) {
if (!is_secondary_window_)
GetBlinkTestClientRemote().PrintMessage(message);
GetBlinkTestClientRemote()->PrintMessage(message);
}
void BlinkTestRunner::PostTask(base::OnceClosure task) {
......@@ -238,11 +240,11 @@ void BlinkTestRunner::ApplyPreferences() {
WebPreferences prefs = render_view()->GetWebkitPreferences();
ExportWebTestSpecificPreferences(prefs_, &prefs);
render_view()->SetWebkitPreferences(prefs);
GetBlinkTestClientRemote().OverridePreferences(prefs);
GetBlinkTestClientRemote()->OverridePreferences(prefs);
}
void BlinkTestRunner::SetPopupBlockingEnabled(bool block_popups) {
GetBlinkTestClientRemote().SetPopupBlockingEnabled(block_popups);
GetBlinkTestClientRemote()->SetPopupBlockingEnabled(block_popups);
}
void BlinkTestRunner::UseUnfortunateSynchronousResizeMode(bool enable) {
......@@ -270,7 +272,7 @@ void BlinkTestRunner::ResetAutoResizeMode() {
}
void BlinkTestRunner::NavigateSecondaryWindow(const GURL& url) {
GetBlinkTestClientRemote().NavigateSecondaryWindow(url);
GetBlinkTestClientRemote()->NavigateSecondaryWindow(url);
}
void BlinkTestRunner::InspectSecondaryWindow() {
......@@ -338,19 +340,19 @@ void BlinkTestRunner::SetBluetoothFakeAdapter(const std::string& adapter_name,
}
void BlinkTestRunner::SetBluetoothManualChooser(bool enable) {
GetBlinkTestClientRemote().SetBluetoothManualChooser(enable);
GetBlinkTestClientRemote()->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();
GetBlinkTestClientRemote()->GetBluetoothManualChooserEvents();
}
void BlinkTestRunner::SendBluetoothManualChooserEvent(
const std::string& event,
const std::string& argument) {
GetBlinkTestClientRemote().SendBluetoothManualChooserEvent(event, argument);
GetBlinkTestClientRemote()->SendBluetoothManualChooserEvent(event, argument);
}
void BlinkTestRunner::SetFocus(blink::WebView* web_view, bool focus) {
......@@ -506,7 +508,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();
GetBlinkTestClientRemote()->InitiateLayoutDump();
}
}
......@@ -567,7 +569,7 @@ void BlinkTestRunner::CaptureDumpComplete() {
}
void BlinkTestRunner::CloseRemainingWindows() {
GetBlinkTestClientRemote().CloseRemainingWindows();
GetBlinkTestClientRemote()->CloseRemainingWindows();
}
void BlinkTestRunner::DeleteAllCookies() {
......@@ -579,16 +581,16 @@ int BlinkTestRunner::NavigationEntryCount() {
}
void BlinkTestRunner::GoToOffset(int offset) {
GetBlinkTestClientRemote().GoToOffset(offset);
GetBlinkTestClientRemote()->GoToOffset(offset);
}
void BlinkTestRunner::Reload() {
GetBlinkTestClientRemote().Reload();
GetBlinkTestClientRemote()->Reload();
}
void BlinkTestRunner::LoadURLForFrame(const WebURL& url,
const std::string& frame_name) {
GetBlinkTestClientRemote().LoadURLForFrame(url, frame_name);
GetBlinkTestClientRemote()->LoadURLForFrame(url, frame_name);
}
bool BlinkTestRunner::AllowExternalPages() {
......@@ -654,7 +656,7 @@ void BlinkTestRunner::ForceTextInputStateUpdate(WebLocalFrame* frame) {
}
void BlinkTestRunner::SetScreenOrientationChanged() {
GetBlinkTestClientRemote().SetScreenOrientationChanged();
GetBlinkTestClientRemote()->SetScreenOrientationChanged();
}
// RenderViewObserver --------------------------------------------------------
......@@ -715,7 +717,7 @@ void BlinkTestRunner::DidCommitNavigationInMainFrame() {
waiting_for_reset_ = false;
GetBlinkTestClientRemote().ResetDone();
GetBlinkTestClientRemote()->ResetDone();
}
// Private methods -----------------------------------------------------------
......@@ -729,12 +731,20 @@ BlinkTestRunner::GetBluetoothFakeAdapterSetter() {
return *bluetooth_fake_adapter_setter_;
}
mojom::BlinkTestClient& BlinkTestRunner::GetBlinkTestClientRemote() {
mojo::AssociatedRemote<mojom::BlinkTestClient>&
BlinkTestRunner::GetBlinkTestClientRemote() {
if (!blink_test_client_remote_) {
RenderThread::Get()->BindHostReceiver(
blink_test_client_remote_.BindNewPipeAndPassReceiver());
RenderThread::Get()->GetChannel()->GetRemoteAssociatedInterface(
&blink_test_client_remote_);
blink_test_client_remote_.set_disconnect_handler(
base::BindOnce(&BlinkTestRunner::HandleBlinkTestClientDisconnected,
base::Unretained(this)));
}
return *blink_test_client_remote_;
return blink_test_client_remote_;
}
void BlinkTestRunner::HandleBlinkTestClientDisconnected() {
blink_test_client_remote_.reset();
}
mojom::WebTestClient& BlinkTestRunner::GetWebTestClientRemote() {
......
......@@ -22,6 +22,7 @@
#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/web_test_delegate.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "v8/include/v8.h"
......@@ -181,8 +182,9 @@ class BlinkTestRunner : public RenderViewObserver,
mojo::Remote<mojom::WebTestBluetoothFakeAdapterSetter>
bluetooth_fake_adapter_setter_;
mojom::BlinkTestClient& GetBlinkTestClientRemote();
mojo::Remote<mojom::BlinkTestClient> blink_test_client_remote_;
void HandleBlinkTestClientDisconnected();
mojo::AssociatedRemote<mojom::BlinkTestClient>& GetBlinkTestClientRemote();
mojo::AssociatedRemote<mojom::BlinkTestClient> blink_test_client_remote_;
mojom::WebTestClient& GetWebTestClientRemote();
mojo::Remote<mojom::WebTestClient> web_test_client_remote_;
......
......@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "content/public/common/referrer.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/test/test_runner_support.h"
#include "content/shell/test_runner/accessibility_controller.h"
#include "content/shell/test_runner/event_sender.h"
......@@ -137,22 +138,19 @@ WebFrameTestClient::WebFrameTestClient(WebViewTestProxy* web_view_test_proxy,
DCHECK(web_view_test_proxy_);
}
WebFrameTestClient::~WebFrameTestClient() {}
// static
void WebFrameTestClient::PrintFrameDescription(WebTestDelegate* delegate,
blink::WebLocalFrame* frame) {
std::string WebFrameTestClient::PrintFrameDescription(
WebTestDelegate* delegate,
blink::WebLocalFrame* frame) {
std::string name = content::GetFrameNameForWebTests(frame);
if (frame == frame->View()->MainFrame()) {
DCHECK(name.empty());
delegate->PrintMessage("main frame");
return;
return "main frame";
}
if (name.empty()) {
delegate->PrintMessage("frame (anonymous)");
return;
return "frame (anonymous)";
}
delegate->PrintMessage(std::string("frame \"") + name + "\"");
return std::string("frame \"") + name + "\"";
}
void WebFrameTestClient::PostAccessibilityEvent(
......@@ -440,9 +438,9 @@ bool WebFrameTestClient::ShouldContinueNavigation(
if (test_runner()->ShouldDumpFrameLoadCallbacks()) {
GURL url = info->url_request.Url();
WebFrameTestClient::PrintFrameDescription(
std::string description = WebFrameTestClient::PrintFrameDescription(
delegate(), web_frame_test_proxy_->GetWebFrame());
delegate()->PrintMessage(" - BeginNavigation request to '");
delegate()->PrintMessage(description + " - BeginNavigation request to '");
delegate()->PrintMessage(
DescriptionSuitableForTestResult(url.possibly_invalid_spec()));
delegate()->PrintMessage("', http method ");
......
......@@ -30,11 +30,11 @@ class WebFrameTestClient : public blink::WebLocalFrameClient {
WebFrameTestClient(WebViewTestProxy* web_view_test_proxy,
WebFrameTestProxy* web_frame_test_proxy);
~WebFrameTestClient() override;
~WebFrameTestClient() override = default;
bool ShouldContinueNavigation(blink::WebNavigationInfo* info);
static void PrintFrameDescription(WebTestDelegate* delegate,
blink::WebLocalFrame* frame);
static std::string PrintFrameDescription(WebTestDelegate* delegate,
blink::WebLocalFrame* frame);
// WebLocalFrameClient overrides needed by WebFrameTestProxy.
void PostAccessibilityEvent(const blink::WebAXObject& object,
......
......@@ -46,9 +46,9 @@ class TestRenderFrameObserver : public content::RenderFrameObserver {
const GURL& url,
base::Optional<blink::WebNavigationType> navigation_type) override {
if (test_runner()->ShouldDumpFrameLoadCallbacks()) {
WebFrameTestClient::PrintFrameDescription(delegate(),
render_frame()->GetWebFrame());
delegate()->PrintMessage(" - DidStartNavigation\n");
std::string description = WebFrameTestClient::PrintFrameDescription(
delegate(), render_frame()->GetWebFrame());
delegate()->PrintMessage(description + " - DidStartNavigation\n");
}
if (test_runner()->ShouldDumpUserGestureInFrameLoadCallbacks()) {
......@@ -60,50 +60,53 @@ class TestRenderFrameObserver : public content::RenderFrameObserver {
void ReadyToCommitNavigation(
blink::WebDocumentLoader* document_loader) override {
if (test_runner()->ShouldDumpFrameLoadCallbacks()) {
WebFrameTestClient::PrintFrameDescription(delegate(),
render_frame()->GetWebFrame());
delegate()->PrintMessage(" - ReadyToCommitNavigation\n");
std::string description = WebFrameTestClient::PrintFrameDescription(
delegate(), render_frame()->GetWebFrame());
delegate()->PrintMessage(description + " - ReadyToCommitNavigation\n");
}
}
void DidFailProvisionalLoad() override {
if (test_runner()->ShouldDumpFrameLoadCallbacks()) {
WebFrameTestClient::PrintFrameDescription(delegate(),
render_frame()->GetWebFrame());
delegate()->PrintMessage(" - didFailProvisionalLoadWithError\n");
std::string description = WebFrameTestClient::PrintFrameDescription(
delegate(), render_frame()->GetWebFrame());
delegate()->PrintMessage(description +
" - didFailProvisionalLoadWithError\n");
}
}
void DidCommitProvisionalLoad(bool is_same_document_navigation,
ui::PageTransition transition) override {
if (test_runner()->ShouldDumpFrameLoadCallbacks()) {
WebFrameTestClient::PrintFrameDescription(delegate(),
render_frame()->GetWebFrame());
delegate()->PrintMessage(" - didCommitLoadForFrame\n");
std::string description = WebFrameTestClient::PrintFrameDescription(
delegate(), render_frame()->GetWebFrame());
delegate()->PrintMessage(description + " - didCommitLoadForFrame\n");
}
}
void DidFinishDocumentLoad() override {
if (test_runner()->ShouldDumpFrameLoadCallbacks()) {
WebFrameTestClient::PrintFrameDescription(delegate(),
render_frame()->GetWebFrame());
delegate()->PrintMessage(" - didFinishDocumentLoadForFrame\n");
std::string description = WebFrameTestClient::PrintFrameDescription(
delegate(), render_frame()->GetWebFrame());
delegate()->PrintMessage(description +
" - didFinishDocumentLoadForFrame\n");
}
}
void DidFinishLoad() override {
if (test_runner()->ShouldDumpFrameLoadCallbacks()) {
WebFrameTestClient::PrintFrameDescription(delegate(),
render_frame()->GetWebFrame());
delegate()->PrintMessage(" - didFinishLoadForFrame\n");
std::string description = WebFrameTestClient::PrintFrameDescription(
delegate(), render_frame()->GetWebFrame());
delegate()->PrintMessage(description + " - didFinishLoadForFrame\n");
}
}
void DidHandleOnloadEvents() override {
if (test_runner()->ShouldDumpFrameLoadCallbacks()) {
WebFrameTestClient::PrintFrameDescription(delegate(),
render_frame()->GetWebFrame());
delegate()->PrintMessage(" - didHandleOnloadEventsForFrame\n");
std::string description = WebFrameTestClient::PrintFrameDescription(
delegate(), render_frame()->GetWebFrame());
delegate()->PrintMessage(description +
" - didHandleOnloadEventsForFrame\n");
}
}
......
......@@ -6975,9 +6975,7 @@ crbug.com/1061226 [ Fuchsia ] external/wpt/mediacapture-streams/MediaStream-idl.
# Sheriff 2020-03-13
crbug.com/1061159 [ Fuchsia ] fast/inspector-support/cssURLQuotes.html [ Pass Failure ]
crbug.com/1061118 fast/loader/subframe-removes-itself.html [ Pass Failure ]
crbug.com/1061043 fast/plugins/keypress-event.html [ Pass Failure ]
crbug.com/1061328 http/tests/loading/onreadystatechange-detach.html [ Pass Failure ]
crbug.com/1061097 http/tests/security/promise-access-control-allow.htm [ Pass Failure ]
crbug.com/1061539 [ Mac ] http/tests/images/document-policy-oversized-images-resize.html [ Pass Failure ]
crbug.com/1061539 [ Linux ] http/tests/images/document-policy-oversized-images-resize.html [ Pass Failure ]
......@@ -6990,6 +6988,5 @@ crbug.com/1061131 [ Mac ] editing/selection/replaced-boundaries-1.html [ Pass Fa
# Sheriff 2020-03-16
crbug.com/1061029 [ Win ] external/wpt/html/cross-origin-embedder-policy/cache-storage-reporting.https.html [ Pass Failure ]
crbug.com/1061029 [ Mac ] external/wpt/html/cross-origin-embedder-policy/cache-storage-reporting.https.html [ Pass Failure ]
crbug.com/1061180 http/tests/loading/onbeforeunload-detach.html [ Pass Failure ]
crbug.com/1060175 [ Linux ] http/tests/security/promise-access-control-allow.html [ Pass Failure Timeout ]
crbug.com/1060175 [ Win ] http/tests/security/promise-access-control-allow.html [ Pass Failure Timeout ]
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x600
LayoutBlockFlow {HTML} at (0,0) size 800x600
LayoutBlockFlow {BODY} at (8,8) size 784x584
LayoutBlockFlow {P} at (0,0) size 784x36
LayoutText {#text} at (0,0) size 777x36
text run at (0,0) width 777: "This tests that when a selection that ends at [replaced element, 0] is painted, the replaced element doesn't appear selected."
text run at (0,18) width 312: "This test uses an image for the replaced element."
LayoutBlockFlow {DIV} at (0,52) size 784x107
LayoutText {#text} at (0,89) size 23x18
text run at (0,89) width 23: "abc"
LayoutImage {IMG} at (22.20,0) size 76x103
LayoutText {#text} at (98,89) size 21x18
text run at (98,89) width 21: "def"
selection start: position 1 of child 0 {#text} of child 3 {DIV} of body
selection end: position 4 of child 0 {#text} of child 3 {DIV} of body
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