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

Side by Side 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, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/page/AutoscrollController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "core/frame/Settings.h" 52 #include "core/frame/Settings.h"
53 #include "core/frame/VisualViewport.h" 53 #include "core/frame/VisualViewport.h"
54 #include "core/frame/WebLocalFrameBase.h" 54 #include "core/frame/WebLocalFrameBase.h"
55 #include "core/html/HTMLIFrameElement.h" 55 #include "core/html/HTMLIFrameElement.h"
56 #include "core/html/HTMLInputElement.h" 56 #include "core/html/HTMLInputElement.h"
57 #include "core/html/HTMLTextAreaElement.h" 57 #include "core/html/HTMLTextAreaElement.h"
58 #include "core/inspector/DevToolsEmulator.h" 58 #include "core/inspector/DevToolsEmulator.h"
59 #include "core/layout/api/LayoutViewItem.h" 59 #include "core/layout/api/LayoutViewItem.h"
60 #include "core/loader/DocumentLoader.h" 60 #include "core/loader/DocumentLoader.h"
61 #include "core/loader/FrameLoadRequest.h" 61 #include "core/loader/FrameLoadRequest.h"
62 #include "core/page/ChromeClient.h"
62 #include "core/page/Page.h" 63 #include "core/page/Page.h"
63 #include "core/page/PrintContext.h" 64 #include "core/page/PrintContext.h"
64 #include "core/page/ScopedPageSuspender.h" 65 #include "core/page/ScopedPageSuspender.h"
65 #include "core/paint/PaintLayer.h" 66 #include "core/paint/PaintLayer.h"
66 #include "core/paint/PaintLayerPainter.h" 67 #include "core/paint/PaintLayerPainter.h"
67 #include "core/timing/DOMWindowPerformance.h" 68 #include "core/timing/DOMWindowPerformance.h"
68 #include "core/timing/Performance.h" 69 #include "core/timing/Performance.h"
69 #include "platform/KeyboardCodes.h" 70 #include "platform/KeyboardCodes.h"
70 #include "platform/geometry/IntRect.h" 71 #include "platform/geometry/IntRect.h"
71 #include "platform/geometry/IntSize.h" 72 #include "platform/geometry/IntSize.h"
72 #include "platform/graphics/Color.h" 73 #include "platform/graphics/Color.h"
73 #include "platform/graphics/GraphicsContext.h" 74 #include "platform/graphics/GraphicsContext.h"
74 #include "platform/graphics/GraphicsLayer.h" 75 #include "platform/graphics/GraphicsLayer.h"
75 #include "platform/graphics/paint/PaintRecordBuilder.h" 76 #include "platform/graphics/paint/PaintRecordBuilder.h"
76 #include "platform/scroll/ScrollTypes.h" 77 #include "platform/scroll/ScrollTypes.h"
77 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 78 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
78 #include "platform/testing/URLTestHelpers.h" 79 #include "platform/testing/URLTestHelpers.h"
79 #include "platform/testing/UnitTestHelpers.h" 80 #include "platform/testing/UnitTestHelpers.h"
80 #include "platform/wtf/PtrUtil.h" 81 #include "platform/wtf/PtrUtil.h"
81 #include "public/platform/Platform.h" 82 #include "public/platform/Platform.h"
82 #include "public/platform/WebCoalescedInputEvent.h" 83 #include "public/platform/WebCoalescedInputEvent.h"
84 #include "public/platform/WebCursorInfo.h"
83 #include "public/platform/WebDisplayMode.h" 85 #include "public/platform/WebDisplayMode.h"
84 #include "public/platform/WebDragData.h" 86 #include "public/platform/WebDragData.h"
85 #include "public/platform/WebDragOperation.h" 87 #include "public/platform/WebDragOperation.h"
86 #include "public/platform/WebFloatPoint.h" 88 #include "public/platform/WebFloatPoint.h"
87 #include "public/platform/WebInputEvent.h" 89 #include "public/platform/WebInputEvent.h"
88 #include "public/platform/WebKeyboardEvent.h" 90 #include "public/platform/WebKeyboardEvent.h"
89 #include "public/platform/WebLayerTreeView.h" 91 #include "public/platform/WebLayerTreeView.h"
90 #include "public/platform/WebMockClipboard.h" 92 #include "public/platform/WebMockClipboard.h"
91 #include "public/platform/WebSize.h" 93 #include "public/platform/WebSize.h"
92 #include "public/platform/WebThread.h" 94 #include "public/platform/WebThread.h"
(...skipping 2476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 key_event.windows_key_code = VKEY_DOWN; 2571 key_event.windows_key_code = VKEY_DOWN;
2570 key_event.SetModifiers(WebInputEvent::kAltKey); 2572 key_event.SetModifiers(WebInputEvent::kAltKey);
2571 key_event.is_system_key = false; 2573 key_event.is_system_key = false;
2572 key_event.SetType(WebInputEvent::kRawKeyDown); 2574 key_event.SetType(WebInputEvent::kRawKeyDown);
2573 EXPECT_EQ(WebInputEventResult::kHandledSystem, 2575 EXPECT_EQ(WebInputEventResult::kHandledSystem,
2574 web_view->HandleInputEvent(WebCoalescedInputEvent(key_event))); 2576 web_view->HandleInputEvent(WebCoalescedInputEvent(key_event)));
2575 key_event.SetType(WebInputEvent::kKeyUp); 2577 key_event.SetType(WebInputEvent::kKeyUp);
2576 web_view->HandleInputEvent(WebCoalescedInputEvent(key_event)); 2578 web_view->HandleInputEvent(WebCoalescedInputEvent(key_event));
2577 } 2579 }
2578 2580
2581 class MiddleClickAutoscrollWebWidgetClient
2582 : public FrameTestHelpers::TestWebWidgetClient {
2583 public:
2584 // WebWidgetClient methods
2585
2586 void DidChangeCursor(const WebCursorInfo& cursor) override {
2587 last_cursor_type_ = cursor.type;
2588 }
2589
2590 int GetLastCursorType() const { return last_cursor_type_; }
2591
2592 private:
2593 int last_cursor_type_ = 0;
2594 };
2595
2596 TEST_P(WebViewTest, MiddleClickAutoscrollCursor) {
2597 MiddleClickAutoscrollWebWidgetClient client;
2598 RuntimeEnabledFeatures::SetMiddleClickAutoscrollEnabled(true);
2599 RegisterMockedHttpURLLoad("content-width-1000.html");
2600
2601 WebViewBase* web_view = web_view_helper_.InitializeAndLoad(
2602 base_url_ + "content-width-1000.html", nullptr, nullptr, &client);
2603 web_view->Resize(WebSize(100, 100));
2604 web_view->UpdateAllLifecyclePhases();
2605 RunPendingTasks();
2606
2607 WebMouseEvent mouse_event(WebInputEvent::kMouseDown,
2608 WebInputEvent::kNoModifiers,
2609 WebInputEvent::kTimeStampForTesting);
2610 mouse_event.button = WebMouseEvent::Button::kMiddle;
2611 mouse_event.SetPositionInWidget(1, 1);
2612 mouse_event.click_count = 1;
2613
2614 // Start middle-click autoscroll.
2615 web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event));
2616 mouse_event.SetType(WebInputEvent::kMouseUp);
2617 web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event));
2618
2619 EXPECT_EQ(MiddlePanningCursor().GetType(), client.GetLastCursorType());
2620
2621 LocalFrame* local_frame =
2622 ToWebLocalFrameBase(web_view->MainFrame())->GetFrame();
2623
2624 // Even if a plugin tries to change the cursor type, that should be ignored
2625 // during middle-click autoscroll.
2626 web_view->GetChromeClient().SetCursorForPlugin(WebCursorInfo(PointerCursor()),
2627 local_frame);
2628 EXPECT_EQ(MiddlePanningCursor().GetType(), client.GetLastCursorType());
2629
2630 // End middle-click autoscroll.
2631 mouse_event.SetType(WebInputEvent::kMouseDown);
2632 web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event));
2633 mouse_event.SetType(WebInputEvent::kMouseUp);
2634 web_view->HandleInputEvent(WebCoalescedInputEvent(mouse_event));
2635
2636 web_view->GetChromeClient().SetCursorForPlugin(WebCursorInfo(IBeamCursor()),
2637 local_frame);
2638 EXPECT_EQ(IBeamCursor().GetType(), client.GetLastCursorType());
2639 }
2640
2579 static void ConfigueCompositingWebView(WebSettings* settings) { 2641 static void ConfigueCompositingWebView(WebSettings* settings) {
2580 settings->SetAcceleratedCompositingEnabled(true); 2642 settings->SetAcceleratedCompositingEnabled(true);
2581 settings->SetPreferCompositingToLCDTextEnabled(true); 2643 settings->SetPreferCompositingToLCDTextEnabled(true);
2582 } 2644 }
2583 2645
2584 TEST_P(WebViewTest, ShowPressOnTransformedLink) { 2646 TEST_P(WebViewTest, ShowPressOnTransformedLink) {
2585 FrameTestHelpers::WebViewHelper web_view_helper; 2647 FrameTestHelpers::WebViewHelper web_view_helper;
2586 WebViewBase* web_view_impl = web_view_helper.Initialize( 2648 WebViewBase* web_view_impl = web_view_helper.Initialize(
2587 nullptr, nullptr, nullptr, &ConfigueCompositingWebView); 2649 nullptr, nullptr, nullptr, &ConfigueCompositingWebView);
2588 2650
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
4335 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars()); 4397 EXPECT_FALSE(frame_view->VisualViewportSuppliesScrollbars());
4336 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) { 4398 if (RuntimeEnabledFeatures::RootLayerScrollingEnabled()) {
4337 EXPECT_NE(nullptr, 4399 EXPECT_NE(nullptr,
4338 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar()); 4400 frame_view->LayoutViewportScrollableArea()->VerticalScrollbar());
4339 } else { 4401 } else {
4340 EXPECT_NE(nullptr, frame_view->VerticalScrollbar()); 4402 EXPECT_NE(nullptr, frame_view->VerticalScrollbar());
4341 } 4403 }
4342 } 4404 }
4343 4405
4344 } // namespace blink 4406 } // namespace blink
OLDNEW
« 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