diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 2cbb9e477d86707c3b99c99df9f63ff3c1e069f3..1c856e5b2b5744146d7abc40050150fff5b827c3 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -246,7 +246,7 @@ void WebContentsDelegateQt::RenderFrameDeleted(content::RenderFrameHost *render_ void WebContentsDelegateQt::EmitLoadStarted(const QUrl &url, bool isErrorPage) { - if (m_lastLoadProgress >= 0) // already running + if (m_lastLoadProgress >= 0 && m_lastLoadProgress < 100) // already running return; m_viewClient->loadStarted(url, isErrorPage); m_viewClient->loadProgressChanged(0); diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml index 37ba4da43e208d0931fbdf3d863f96bba551ddc3..d48ab277cc15c96a883f6300cc481a13cbc27bc6 100644 --- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml +++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml @@ -281,5 +281,31 @@ TestWebEngineView { compare(loadRequest.activeUrl, url); webEngineView.clear(); } + + function test_loadStartedAfterInPageNavigation() { + webEngineView.url = Qt.resolvedUrl("test4.html"); + verify(webEngineView.waitForLoadSucceeded()); + compare(webEngineView.loadProgress, 100); + compare(loadRequestArray.length, 2); + compare(loadRequestArray[0].status, WebEngineView.LoadStartedStatus); + compare(loadRequestArray[1].status, WebEngineView.LoadSucceededStatus); + + // In-page navigation. + webEngineView.url = Qt.resolvedUrl("test4.html#content"); + // In-page navigation doesn't trigger load succeeded, wait for load progress instead. + tryCompare(webEngineView, "loadProgress", 100); + compare(loadRequestArray.length, 3); + compare(loadRequestArray[2].status, WebEngineView.LoadStartedStatus); + + // Load after in-page navigation. + webEngineView.url = Qt.resolvedUrl("test4.html"); + verify(webEngineView.waitForLoadSucceeded()); + compare(webEngineView.loadProgress, 100); + compare(loadRequestArray.length, 5); + compare(loadRequestArray[3].status, WebEngineView.LoadStartedStatus); + compare(loadRequestArray[4].status, WebEngineView.LoadSucceededStatus); + + webEngineView.clear(); + } } }