diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index aae0efea8af6930a5ef2fe09da648cdc3f096f83..ae75b7f34dd4bbf60b35359b65bfd5e5ae30a779 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -356,6 +356,8 @@ void QQuickWebEngineViewPrivate::navigationRequested(int navigationType, const Q Q_EMIT q->navigationRequested(&navigationRequest); navigationRequestAction = navigationRequest.action(); + if ((navigationRequestAction == WebContentsAdapterClient::AcceptRequest) && adapter) + adapter->stopFinding(); } void QQuickWebEngineViewPrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> dialog) diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 6042b9fdc4b203f71ac968c0cd23c41cf435f7f8..51456128f82aa3d7b19147b478b4401137648316 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -1431,6 +1431,8 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl & { Q_Q(QWebEnginePage); bool accepted = q->acceptNavigationRequest(url, static_cast<QWebEnginePage::NavigationType>(navigationType), isMainFrame); + if (accepted && adapter) + adapter->stopFinding(); navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest; } diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml index 8526012c9d78b8fedd3d2f646df72b36b80601d2..f8730ca7b502b99df3df0a4d8d2bb532442f9f3f 100644 --- a/tests/auto/quick/qmltests/data/tst_findText.qml +++ b/tests/auto/quick/qmltests/data/tst_findText.qml @@ -211,9 +211,9 @@ TestWebEngineView { if (!webEngineView.waitForLoadSucceeded(12000)) skip("Couldn't load page from network, skipping test."); - // Can't be sure whether the findText succeeded before the new load. - // Thus don't check the find result just whether the callback was called. - tryVerify(function() { return webEngineView.matchCount != -1; }); + // The callback is not supposed to be called, see QTBUG-61506. + // Check whether the callback was called (-1 = no, other values = yes). + tryVerify(function() { return webEngineView.matchCount == -1; }); } } }