From f32b3514a5186bc4f5452f004324bdb7782d30a3 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Fri, 14 Apr 2017 10:38:50 -0400 Subject: Make FocusOnNavigationEnabled setting disabled by default Before this setting was added in Qt 5.8, the behavior was that QWebEngineView/WebEngineView got the focus automatically. With the new setting added it is configurable, but it was left enabled for compatibility reasons. It would had to be changed at some point anyway: none of other QML items or widgets grab the focus after creation, so why would QWebEngineView/WebEngineView do? This patch also fixes a bug with the text cursor in WebView (the cursor was blinking as if WebView had the focus when it did not). [ChangeLog][Important Changes][QtWebEngine][General] focusOnNavigationEnabled setting which allows controlling whether a web view will receive focus on a navigation request is now disabled by default. Task-number: QTBUG-60152 Task-number: QTBUG-60149 Change-Id: I78dc9bb9ffc70bf06217952acd456b97651c5185 Reviewed-by: Qt CI Bot Reviewed-by: Michal Klocek --- tests/auto/quick/qmltests/data/TestWebEngineView.qml | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto/quick/qmltests') diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml index a7d890072..8304a993a 100644 --- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml +++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml @@ -33,6 +33,7 @@ import QtWebEngine 1.3 WebEngineView { property var loadStatus: null property bool windowCloseRequestedSignalEmitted: false + settings.focusOnNavigationEnabled: true function waitForLoadSucceeded() { var success = _waitFor(function() { return loadStatus == WebEngineView.LoadSucceededStatus }) -- cgit v1.2.3 From 7282fb4fb4861320539f2b7288f63e1d4f48749d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 19 Jul 2017 14:12:54 +0200 Subject: Adaptations for Chromium 60 Change-Id: I536258e22c2ec143f2fd3f1cbda229e0611b6af4 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Qt CI Bot --- tests/auto/quick/qmltests/data/confirmclose.html | 3 ++- .../quick/qmltests/data/tst_javaScriptDialogs.qml | 22 ++++++++++++++++++++++ tests/auto/quick/qmltests/tst_qmltests.cpp | 13 +++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) (limited to 'tests/auto/quick/qmltests') diff --git a/tests/auto/quick/qmltests/data/confirmclose.html b/tests/auto/quick/qmltests/data/confirmclose.html index ba11da7a4..c2acbb67f 100644 --- a/tests/auto/quick/qmltests/data/confirmclose.html +++ b/tests/auto/quick/qmltests/data/confirmclose.html @@ -1,5 +1,6 @@ - + Be greeted, precious viewer! diff --git a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml index 73673f511..44836d67c 100644 --- a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml +++ b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml @@ -34,6 +34,7 @@ import "../mock-delegates/TestParams" 1.0 TestWebEngineView { id: webEngineView + anchors.fill: parent testSupport: WebEngineTestSupport { property bool windowCloseRejectedSignalEmitted: false @@ -52,6 +53,7 @@ TestWebEngineView { TestCase { id: test name: "WebEngineViewJavaScriptDialogs" + when: windowShown function init() { JSDialogParams.dialogMessage = ""; @@ -82,11 +84,29 @@ TestWebEngineView { } + function simulateUserGesture() { + // A user gesture after page load is required since Chromium 60 to allow showing + // an onbeforeunload dialog. + // See https://www.chromestatus.com/feature/5082396709879808 + mouseClick(webEngineView, 10, 10, Qt.LeftButton) + + var mousePressReceived; + runJavaScript("window.mousePressReceived", function(result) { + mousePressReceived = result; + }); + + tryVerify(function() { + return mousePressReceived != undefined + }, 5000); + } + function test_confirmClose() { webEngineView.url = Qt.resolvedUrl("confirmclose.html"); verify(webEngineView.waitForLoadSucceeded()); webEngineView.windowCloseRequestedSignalEmitted = false; JSDialogParams.shouldAcceptDialog = true; + + simulateUserGesture() webEngineView.triggerWebAction(WebEngineView.RequestClose); verify(webEngineView.waitForWindowCloseRequested()); } @@ -96,6 +116,8 @@ TestWebEngineView { verify(webEngineView.waitForLoadSucceeded()); webEngineView.testSupport.windowCloseRejectedSignalEmitted = false; JSDialogParams.shouldAcceptDialog = false; + + simulateUserGesture() webEngineView.triggerWebAction(WebEngineView.RequestClose); verify(webEngineView.testSupport.waitForWindowCloseRejected()); } diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp index 5dc909709..2aa24b76c 100644 --- a/tests/auto/quick/qmltests/tst_qmltests.cpp +++ b/tests/auto/quick/qmltests/tst_qmltests.cpp @@ -114,8 +114,17 @@ int main(int argc, char **argv) // Force to use English language for testing due to error message checks QLocale::setDefault(QLocale("en")); - if (!QCoreApplication::instance()) - app.reset(new Application(argc, argv)); + static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")}; + QVector w_argv(argc); \ + for (int i = 0; i < argc; ++i) \ + w_argv[i] = argv[i]; \ + for (int i = 0; i < params.size(); ++i) \ + w_argv.append(params[i].data()); \ + int w_argc = w_argv.size(); \ + + if (!QCoreApplication::instance()) { + app.reset(new Application(w_argc, const_cast(w_argv.data()))); + } QtWebEngine::initialize(); QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true); -- cgit v1.2.3