Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: third_party/WebKit/Source/core/exported/WebViewTest.cpp

Issue 2961003002: Prevent plugins from changing mouse cursor during middle-click autoscroll. (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/page/AutoscrollController.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/exported/WebViewTest.cpp
diff --git a/third_party/WebKit/Source/core/exported/WebViewTest.cpp b/third_party/WebKit/Source/core/exported/WebViewTest.cpp
index b78f2dae45c56b2ab40515119e0da8966551cb65..cdb4c849d8e3d8f8f781de31485bab770a7538de 100644
--- a/third_party/WebKit/Source/core/exported/WebViewTest.cpp
+++ b/third_party/WebKit/Source/core/exported/WebViewTest.cpp
@@ -59,6 +59,7 @@
#include "core/layout/api/LayoutViewItem.h"
#include "core/loader/DocumentLoader.h"
#include "core/loader/FrameLoadRequest.h"
+#include "core/page/ChromeClient.h"
#include "core/page/Page.h"
#include "core/page/PrintContext.h"
#include "core/page/ScopedPageSuspender.h"
@@ -80,6 +81,7 @@
#include "platform/wtf/PtrUtil.h"
#include "public/platform/Platform.h"
#include "public/platform/WebCoalescedInputEvent.h"
+#include "public/platform/WebCursorInfo.h"
#include "public/platform/WebDisplayMode.h"
#include "public/platform/WebDragData.h"
#include "public/platform/WebDragOperation.h"
@@ -2576,6 +2578,66 @@ TEST_P(WebViewTest, KeyDownScrollsHandled) {
web_view->HandleInputEvent(WebCoalescedInputEvent(key_event));
}
+class MiddleClickAutoscrollWebWidgetClient
+ : public FrameTestHelpers::TestWebWidgetClient {
+ public:
+ // WebWidgetClient methods
+
+ void DidChangeCursor(const WebCursorInfo& cursor) override {
+ last_cursor_type_ = cursor.type;
+ }
+
+ int GetLastCursorType() const { return last_cursor_type_; }
+
+ private:
+ int last_cursor_type_ = 0;
+};
+
+TEST_P(WebViewTest, MiddleClickAutoscrollCursor) {
+ MiddleClickAutoscrollWebWidgetClient client;
+ RuntimeEnabledFeatures::SetMiddleClickAutoscrollEnabled(true);
+ RegisterMockedHttpURLLoad("content-width-1000.html");
+
+ WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
+ base_url_ + "content-width-1000.html", nullptr, nullptr, &client);
+ web_view->Resize(WebSize(100, 100));
+ web_view->UpdateAllLifecyclePhases();
+ RunPendingTasks();
+
+ WebMouseEvent mouse_event(WebInputEvent::kMouseDown,
+ WebInputEvent::kNoModifiers,
+ WebInputEvent::kTimeStampForTesting);
+ mouse_event.button = WebMouseEvent::Button::kMiddle;
+ mouse_event.SetPositionInWidget(1, 1);
+ mouse_event.click_count = 1;
+
+ // Start middle-click autoscroll.
+ web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event));
+ mouse_event.SetType(WebInputEvent::kMouseUp);
+ web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event));
+
+ EXPECT_EQ(MiddlePanningCursor().GetType(), client.GetLastCursorType());
+
+ LocalFrame* local_frame =
+ ToWebLocalFrameBase(web_view->MainFrame())->GetFrame();
+
+ // Even if a plugin tries to change the cursor type, that should be ignored
+ // during middle-click autoscroll.
+ web_view->GetChromeClient().SetCursorForPlugin(WebCursorInfo(PointerCursor()),
+ local_frame);
+ EXPECT_EQ(MiddlePanningCursor().GetType(), client.GetLastCursorType());
+
+ // End middle-click autoscroll.
+ mouse_event.SetType(WebInputEvent::kMouseDown);
+ web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event));
+ mouse_event.SetType(WebInputEvent::kMouseUp);
+ web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event));
+
+ web_view->GetChromeClient().SetCursorForPlugin(WebCursorInfo(IBeamCursor()),
+ local_frame);
+ EXPECT_EQ(IBeamCursor().GetType(), client.GetLastCursorType());
+}
+
static void ConfigueCompositingWebView(WebSettings* settings) {
settings->SetAcceleratedCompositingEnabled(true);
settings->SetPreferCompositingToLCDTextEnabled(true);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/page/AutoscrollController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698