diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-01-13 23:23:08 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-06-22 19:39:09 +0000 |
commit | 3feab861f5ead63e2a661343f0df2358fa0af894 (patch) | |
tree | 718a425a63cc0b16f73eeaa6c76041da3e7050d3 /tests | |
parent | af6471cc9165b58fb2e28937c54a00f24fd3bf61 (diff) |
RenderWidgetHostViewQtDelegateItem: keep grabs
If a WebView or WebEngineView gets a mouse or touch grab, we don't want
to give it up to any handlers that may be lurking on Items underneath.
WebView is opaque, so we don't know whether the user is trying to drag a
scrollbar or something else, but interactive items outside shouldn't
interfere, in general.
[ChangeLog][QtWebEngineQuick] WebEngineView (or WebView backed by Qt
WebEngine) no longer allows components outside to take over the mouse or
touch exclusive grab. For example if the user starts dragging a
scrollbar inside the web view, that continues until release, regardless
of any DragHandler, Flickable etc.
Fixes: QTBUG-103518
Pick-to: 6.5 6.6
Change-Id: I4352dc8482020f0efc7a0901e94ccf7fc147fa1b
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qmltests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_dragHandlerUnderView.qml | 67 |
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/quick/qmltests/CMakeLists.txt b/tests/auto/quick/qmltests/CMakeLists.txt index acd783bd5..6301e5ab6 100644 --- a/tests/auto/quick/qmltests/CMakeLists.txt +++ b/tests/auto/quick/qmltests/CMakeLists.txt @@ -25,6 +25,7 @@ set(testList tst_datalist.qml tst_desktopBehaviorLoadHtml.qml tst_download.qml + tst_dragHandlerUnderView.qml tst_favicon.qml tst_faviconDatabase.qml tst_filePicker.qml diff --git a/tests/auto/quick/qmltests/data/tst_dragHandlerUnderView.qml b/tests/auto/quick/qmltests/data/tst_dragHandlerUnderView.qml new file mode 100644 index 000000000..c22bd44c2 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_dragHandlerUnderView.qml @@ -0,0 +1,67 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import QtQuick +import QtTest +import QtWebEngine + +Item { + id: parentItem + width: 400 + height: 300 + + Rectangle { + id: draggableDownUnder + color: "wheat" + width: 350 + height: 250 + + DragHandler { id: dragHandler } + } + + TestWebEngineView { + id: webEngineView + width: 300 + height: 250 + + property var testUrl: Qt.resolvedUrl("test4.html") + + SignalSpy { + id: scrollPositionSpy + target: webEngineView + signalName: "onScrollPositionChanged" + } + + SignalSpy { + id: dragActiveSpy + target: dragHandler + signalName: "activeChanged" + } + + TestCase { + id: testCase + name: "KeepMouseGrabDuringScrolling" + when: windowShown + + function test_scroll() { + webEngineView.url = Qt.resolvedUrl("test4.html"); + verify(webEngineView.waitForLoadSucceeded()); + + mousePress(webEngineView, 295, 20); + mouseMove(webEngineView, 295, 200); + mouseRelease(webEngineView, 295, 200); + + // WebEngineView scrolled if the scrollbar was visible. + // But on macOS, the scrollbar is hidden, so text gets selected. + tryVerify(function() { + return (scrollPositionSpy.count === 1 && webEngineView.scrollPosition.y > 100) + || webEngineView.getTextSelection().length > 0; + }); + + // DragHandler didn't take over and drag + compare(dragActiveSpy.count, 0); + compare(draggableDownUnder.y, 0); + } + } + } +} |