0

Move AccessiblityController to be on the frame instead of the view.

Move AccessiblityController from the WebViewTestProxy to WebFrameTestProxy.

BUG=1155202

Change-Id: I1ffd554e2c250031b4b9c0008275831d630cc0b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2659485
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849157}
This commit is contained in:
Dave Tapuska
2021-02-01 17:40:25 +00:00
committed by Chromium LUCI CQ
parent 5243f72800
commit 1b235d8bf6
6 changed files with 19 additions and 40 deletions

@ -2326,9 +2326,7 @@ void TestRunner::Reset() {
work_queue_.Reset();
}
void TestRunner::ResetWebView(WebViewTestProxy* web_view_test_proxy) {
blink::WebView* web_view = web_view_test_proxy->GetWebView();
void TestRunner::ResetWebView(blink::WebView* web_view) {
web_view->SetTabKeyCyclesThroughElements(true);
web_view->GetSettings()->SetHighlightAds(false);
web_view->GetSettings()->SetCaretBrowsingEnabled(false);

@ -82,8 +82,8 @@ class TestRunner {
// Resets global TestRunner state for the next test.
void Reset();
// Resets state on the |web_view_test_proxy| for the next test.
void ResetWebView(WebViewTestProxy* web_view_test_proxy);
// Resets state on the |web_view| for the next test.
void ResetWebView(blink::WebView* web_view);
// Resets state on the |web_frame_widget| for the next test.
void ResetWebFrameWidget(blink::WebFrameWidget* web_frame_widget);

@ -235,7 +235,8 @@ WebFrameTestProxy::WebFrameTestProxy(RenderFrameImpl::CreateParams params,
: RenderFrameImpl(std::move(params)),
web_view_test_proxy_(static_cast<WebViewTestProxy*>(render_view())),
test_runner_(test_runner),
text_input_controller_(web_view_test_proxy_) {}
text_input_controller_(web_view_test_proxy_),
accessibility_controller_(web_view_test_proxy_) {}
WebFrameTestProxy::~WebFrameTestProxy() {
if (IsMainFrame())
@ -282,13 +283,15 @@ void WebFrameTestProxy::Reset() {
blink::WebView* web_view = GetWebFrame()->View();
web_view->SetWebPreferences(web_view->GetWebPreferences());
web_view_test_proxy_->Reset();
// Resets things on the WebView that TestRunnerBindings can modify.
test_runner()->ResetWebView(web_view);
}
if (IsLocalRoot()) {
test_runner()->ResetWebFrameWidget(GetLocalRootWebFrameWidget());
GetLocalRootFrameWidgetTestHelper()->Reset();
}
accessibility_controller_.Reset();
spell_check_->Reset();
}
@ -671,13 +674,10 @@ void WebFrameTestProxy::HandleWebAccessibilityEvent(
if (!test_runner()->TestIsRunning())
return;
AccessibilityController* accessibility_controller =
web_view_test_proxy_->accessibility_controller();
accessibility_controller->NotificationReceived(GetWebFrame(), object,
accessibility_controller_.NotificationReceived(GetWebFrame(), object,
event_name, event_intents);
if (accessibility_controller->ShouldLogAccessibilityEvents()) {
if (accessibility_controller_.ShouldLogAccessibilityEvents()) {
std::string message("AccessibilityNotification - ");
message += event_name;
@ -714,15 +714,15 @@ void WebFrameTestProxy::DidClearWindowObject() {
// especially problematic for web platform tests that would inject javascript
// into the page when installing bindings.
if (test_runner()->TestIsRunning()) {
blink::WebLocalFrame* frame = GetWebFrame();
// These calls will install the various JS bindings for web tests into the
// frame before JS has a chance to run.
GCController::Install(GetWebFrame());
GCController::Install(frame);
test_runner()->Install(this, spell_check_.get());
text_input_controller_.Install(GetWebFrame());
web_view_test_proxy_->Install(GetWebFrame());
GetLocalRootFrameWidgetTestHelper()->GetEventSender()->Install(
GetWebFrame());
blink::WebTestingSupport::InjectInternalsObject(GetWebFrame());
accessibility_controller_.Install(frame);
text_input_controller_.Install(frame);
GetLocalRootFrameWidgetTestHelper()->GetEventSender()->Install(frame);
blink::WebTestingSupport::InjectInternalsObject(frame);
}
RenderFrameImpl::DidClearWindowObject();
}

@ -13,6 +13,7 @@
#include "base/macros.h"
#include "content/renderer/render_frame_impl.h"
#include "content/web_test/common/web_test.mojom.h"
#include "content/web_test/renderer/accessibility_controller.h"
#include "content/web_test/renderer/text_input_controller.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
@ -111,6 +112,8 @@ class WebFrameTestProxy : public RenderFrameImpl,
TextInputController text_input_controller_;
AccessibilityController accessibility_controller_;
mojo::AssociatedReceiver<mojom::WebTestRenderFrame>
web_test_render_frame_receiver_{this};

@ -31,16 +31,6 @@ WebViewTestProxy::WebViewTestProxy(AgentSchedulingGroup& agent_scheduling_group,
WebViewTestProxy::~WebViewTestProxy() = default;
void WebViewTestProxy::Reset() {
accessibility_controller_.Reset();
// Resets things on the WebView that TestRunnerBindings can modify.
test_runner_->ResetWebView(this);
}
void WebViewTestProxy::Install(blink::WebLocalFrame* frame) {
accessibility_controller_.Install(frame);
}
blink::WebString WebViewTestProxy::GetAbsoluteWebStringFromUTF8Path(
const std::string& utf8_path) {
base::FilePath path = base::FilePath::FromUTF8Unsafe(utf8_path);

@ -15,7 +15,6 @@
#include "content/renderer/agent_scheduling_group.h"
#include "content/renderer/render_view_impl.h"
#include "content/web_test/common/web_test.mojom.h"
#include "content/web_test/renderer/accessibility_controller.h"
#include "third_party/blink/public/common/page/drag_operation.h"
#include "third_party/blink/public/platform/web_url_error.h"
#include "third_party/blink/public/platform/web_url_request.h"
@ -25,12 +24,10 @@
#include "third_party/blink/public/web/web_view_client.h"
namespace blink {
class WebLocalFrame;
class WebString;
} // namespace blink
namespace content {
class AccessibilityController;
class TestRunner;
// WebViewTestProxy is used to run web tests. This class is a partial fake
@ -57,13 +54,6 @@ class WebViewTestProxy : public RenderViewImpl {
const mojom::CreateViewParams& params,
TestRunner* test_runner);
AccessibilityController* accessibility_controller() {
return &accessibility_controller_;
}
void Reset();
void Install(blink::WebLocalFrame* frame);
// Convert the provided relative path into an absolute path.
blink::WebString GetAbsoluteWebStringFromUTF8Path(const std::string& path);
@ -91,8 +81,6 @@ class WebViewTestProxy : public RenderViewImpl {
bool is_main_window_ = false;
mojom::WebTestRunTestConfiguration test_config_;
AccessibilityController accessibility_controller_{this};
DISALLOW_COPY_AND_ASSIGN(WebViewTestProxy);
};