diff options
9 files changed, 58 insertions, 45 deletions
diff --git a/src/3rdparty b/src/3rdparty -Subproject f0775ea93ab66f0676993db1633c9098dfb3a3a +Subproject 966cecdda579ccb32ad28c135e0157e627bd5aa diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp index 926c3e042..50a3e6ff6 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp @@ -88,6 +88,9 @@ public: void interceptRequest(QWebEngineUrlRequestInfo &info) override { + // Since 63 we also intercept some unrelated blob requests.. + if (info.requestUrl().scheme() == QLatin1String("blob")) + return; info.block(info.requestMethod() != QByteArrayLiteral("GET")); if (shouldIntercept && info.requestUrl().toString().endsWith(QLatin1String("__placeholder__"))) info.redirect(QUrl("qrc:///resources/content.html")); @@ -152,6 +155,9 @@ public: void interceptRequest(QWebEngineUrlRequestInfo &info) override { + // Since 63 we also intercept the original data requests + if (info.requestUrl().scheme() == QLatin1String("data")) + return; if (info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeFavicon) return; diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml index cadad4e27..f5e83c5d2 100644 --- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml +++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml @@ -35,26 +35,27 @@ WebEngineView { property bool windowCloseRequestedSignalEmitted: false settings.focusOnNavigationEnabled: true - function waitForLoadSucceeded() { - var success = _waitFor(function() { return loadStatus == WebEngineView.LoadSucceededStatus }) + function waitForLoadSucceeded(timeout) { + var success = _waitFor(function() { return loadStatus == WebEngineView.LoadSucceededStatus }, timeout) loadStatus = null return success } - function waitForLoadFailed() { - var failure = _waitFor(function() { return loadStatus == WebEngineView.LoadFailedStatus }) + function waitForLoadFailed(timeout) { + var failure = _waitFor(function() { return loadStatus == WebEngineView.LoadFailedStatus }, timeout) loadStatus = null return failure } - function waitForLoadStopped() { - var stop = _waitFor(function() { return loadStatus == WebEngineView.LoadStoppedStatus }) + function waitForLoadStopped(timeout) { + var stop = _waitFor(function() { return loadStatus == WebEngineView.LoadStoppedStatus }, timeout) loadStatus = null return stop } function waitForWindowCloseRequested() { return _waitFor(function() { return windowCloseRequestedSignalEmitted; }); } - function _waitFor(predicate) { - var timeout = 12000 + function _waitFor(predicate, timeout) { + if (timeout === undefined) + timeout = 12000; var i = 0 while (i < timeout && !predicate()) { testResult.wait(50) diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml index 80d7a18b3..37ba4da43 100644 --- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml +++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml @@ -209,7 +209,7 @@ TestWebEngineView { var bogusSite = "http://www.somesitethatdoesnotexist.abc/"; var handleLoadFailed = function(loadRequest) { - if (loadRequest.status == WebEngineView.LoadFailedStatus) { + if (loadRequest.status === WebEngineView.LoadFailedStatus) { // loadHtml constructs data URL webEngineView.loadHtml("load failed", bogusSite); compare(loadRequest.url, bogusSite); @@ -231,7 +231,7 @@ TestWebEngineView { loadRequest = loadRequestArray[2]; compare(loadRequest.status, WebEngineView.LoadStartedStatus); compare(loadRequest.activeUrl, aboutBlank); - compare(loadRequest.url, bogusSite) + compare(loadRequest.url, "data:text/html;charset=UTF-8,load failed") loadRequest = loadRequestArray[3]; compare(loadRequest.status, WebEngineView.LoadSucceededStatus); compare(loadRequest.activeUrl, bogusSite); @@ -262,7 +262,7 @@ TestWebEngineView { var loadRequest = null; var handleLoadStarted = function(loadRequest) { - if (loadRequest.status == WebEngineView.LoadStartedStatus) + if (loadRequest.status === WebEngineView.LoadStartedStatus) webEngineView.stop(); } webEngineView.loadingChanged.connect(handleLoadStarted); diff --git a/tests/auto/quick/qmltests/data/tst_viewSource.qml b/tests/auto/quick/qmltests/data/tst_viewSource.qml index 576035ef2..a9cf11f34 100644 --- a/tests/auto/quick/qmltests/data/tst_viewSource.qml +++ b/tests/auto/quick/qmltests/data/tst_viewSource.qml @@ -64,7 +64,7 @@ TestWebEngineView { function init() { webEngineView.url = Qt.resolvedUrl("test1.html"); - verify(webEngineView.waitForLoadSucceeded()); + verify(webEngineView.waitForLoadSucceeded(20000)); newViewRequestedSpy.clear(); titleChangedSpy.clear(); @@ -113,9 +113,9 @@ TestWebEngineView { webEngineView.url = row.userInputUrl; if (row.loadSucceed) { - verify(webEngineView.waitForLoadSucceeded()); + verify(webEngineView.waitForLoadSucceeded(15000)); } else { - verify(webEngineView.waitForLoadFailed()); + verify(webEngineView.waitForLoadFailed(15000)); } tryVerify(function() { return titleChangedSpy.count == 1; }); diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp index 3ce697faf..992254206 100644 --- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp +++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp @@ -622,6 +622,8 @@ void tst_QWebEngineDownloads::downloadViaSetUrl() auto indexFavRR = waitForFaviconRequest(&server); QVERIFY(indexFavRR); + indexRR.reset(); + indexFavRR.reset(); QTRY_COMPARE(loadSpy.count(), 1); QTRY_COMPARE(urlSpy.count(), 1); @@ -642,16 +644,20 @@ void tst_QWebEngineDownloads::downloadViaSetUrl() auto fileRR = waitForRequest(&server); QVERIFY(fileRR); + QCOMPARE(fileRR->requestMethod(), QByteArrayLiteral("GET")); + QCOMPARE(fileRR->requestPath(), QByteArrayLiteral("/file")); fileRR->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment")); fileRR->setResponseBody(QByteArrayLiteral("redacted")); fileRR->sendResponse(); - auto fileFavRR = waitForFaviconRequest(&server); - QVERIFY(fileFavRR); +// Since 63 we no longer get favicon requests here: +// auto fileFavRR = waitForFaviconRequest(&server); +// QVERIFY(fileFavRR); QTRY_COMPARE(loadSpy.count(), 1); QTRY_COMPARE(urlSpy.count(), 2); QTRY_COMPARE(downloadUrls.count(), 1); + fileRR.reset(); QCOMPARE(loadSpy.takeFirst().value(0).toBool(), false); QCOMPARE(urlSpy.takeFirst().value(0).toUrl(), fileUrl); QCOMPARE(urlSpy.takeFirst().value(0).toUrl(), indexUrl); diff --git a/tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp b/tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp index 83c590967..da041ee59 100644 --- a/tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp +++ b/tests/auto/widgets/qwebenginefaviconmanager/tst_qwebenginefaviconmanager.cpp @@ -239,7 +239,7 @@ void tst_QWebEngineFaviconManager::errorPageEnabled() QUrl url("http://url.invalid"); m_page->load(url); - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 12000); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.count(), 1, 14000); QCOMPARE(iconUrlChangedSpy.count(), 0); QCOMPARE(iconChangedSpy.count(), 0); diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index c41b07b47..23c66058e 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -294,43 +294,41 @@ void tst_QWebEnginePage::cleanupTestCase() class NavigationRequestOverride : public QWebEnginePage { public: - NavigationRequestOverride(QWebEngineView* parent, bool initialValue) : QWebEnginePage(parent), m_acceptNavigationRequest(initialValue) {} + NavigationRequestOverride(QWebEngineProfile* profile, bool initialValue) : QWebEnginePage(profile, nullptr), m_acceptNavigationRequest(initialValue) {} bool m_acceptNavigationRequest; protected: virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) { Q_UNUSED(url); - Q_UNUSED(type); Q_UNUSED(isMainFrame); - - return m_acceptNavigationRequest; + if (type == QWebEnginePage::NavigationTypeFormSubmitted) + return m_acceptNavigationRequest; + return true; } }; void tst_QWebEnginePage::acceptNavigationRequest() { - QWebEngineView view; - QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool))); + QWebEngineProfile profile; + NavigationRequestOverride page(&profile, false); - NavigationRequestOverride* newPage = new NavigationRequestOverride(&view, false); - view.setPage(newPage); + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); - // acceptNavigationRequest and QWebEngineUrlRequestInterceptor::interceptRequest are not called - // for data: urls, which means the test is broken, aka setting - // newPage->m_acceptNavigationRequest to false does nothing to stop the page from loading. - // See QTBUG-50922 comments. - view.setHtml(QString("<html><body><form name='tstform' action='data:text/html,foo'method='get'>" + page.setHtml(QString("<html><body><form name='tstform' action='data:text/html,foo'method='get'>" "<input type='text'><input type='submit'></form></body></html>"), QUrl()); QTRY_COMPARE(loadSpy.count(), 1); - evaluateJavaScriptSync(view.page(), "tstform.submit();"); - - newPage->m_acceptNavigationRequest = true; - evaluateJavaScriptSync(view.page(), "tstform.submit();"); + evaluateJavaScriptSync(&page, "tstform.submit();"); QTRY_COMPARE(loadSpy.count(), 2); - QCOMPARE(toPlainTextSync(view.page()), QString("foo?")); + // Content hasn't changed so the form submit will still work + page.m_acceptNavigationRequest = true; + evaluateJavaScriptSync(&page, "tstform.submit();"); + QTRY_COMPARE(loadSpy.count(), 3); + + // Now the content has changed + QCOMPARE(toPlainTextSync(&page), QString("foo?")); } class JSTestPage : public QWebEnginePage @@ -1936,7 +1934,7 @@ void tst_QWebEnginePage::userAgentNewlineStripping() // The user agent will be updated after a page load. page.load(QUrl("about:blank")); - QCOMPARE(evaluateJavaScriptSync(&page, "navigator.userAgent").toString(), QStringLiteral("My User Agent X-New-Http-Header: Oh Noes!")); + QTRY_COMPARE(evaluateJavaScriptSync(&page, "navigator.userAgent").toString(), QStringLiteral("My User Agent X-New-Http-Header: Oh Noes!")); } void tst_QWebEnginePage::crashTests_LazyInitializationOfMainFrame() @@ -3405,7 +3403,7 @@ void tst_QWebEnginePage::setHtmlWithImageResource() QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); page.setHtml(html, QUrl("file:///path/to/file")); - QTRY_COMPARE(spy.count(), 1); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 12000); QCOMPARE(evaluateJavaScriptSync(&page, "document.images.length").toInt(), 1); QCOMPARE(evaluateJavaScriptSync(&page, "document.images[0].width").toInt(), 128); @@ -4044,7 +4042,6 @@ void tst_QWebEnginePage::setUrlHistory() void tst_QWebEnginePage::setUrlUsingStateObject() { - const QUrl aboutBlank("about:blank"); QUrl url; QSignalSpy urlChangedSpy(m_page, SIGNAL(urlChanged(QUrl))); int expectedUrlChangeCount = 0; @@ -4056,7 +4053,7 @@ void tst_QWebEnginePage::setUrlUsingStateObject() expectedUrlChangeCount++; QTRY_COMPARE(urlChangedSpy.count(), expectedUrlChangeCount); QCOMPARE(m_page->url(), url); - QCOMPARE(m_page->history()->count(), 1); + QTRY_COMPARE(m_page->history()->count(), 1); evaluateJavaScriptSync(m_page, "window.history.pushState(null, 'push', 'navigate/to/here')"); expectedUrlChangeCount++; @@ -4336,8 +4333,8 @@ void tst_QWebEnginePage::toPlainTextLoadFinishedRace() QTRY_VERIFY(spy.count() == 1); QCOMPARE(toPlainTextSync(page.data()), QString("foobarbaz")); - page->load(QUrl("fail:unknown/scheme")); - QTRY_VERIFY(spy.count() == 2); + page->load(QUrl("http://fail.invalid/")); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 2, 12000); QString s = toPlainTextSync(page.data()); QVERIFY(s.contains("foobarbaz") == !enableErrorPage); diff --git a/tests/auto/widgets/qwebengineschemes/tst_qwebengineschemes.cpp b/tests/auto/widgets/qwebengineschemes/tst_qwebengineschemes.cpp index cacfc1a3c..9381b3930 100644 --- a/tests/auto/widgets/qwebengineschemes/tst_qwebengineschemes.cpp +++ b/tests/auto/widgets/qwebengineschemes/tst_qwebengineschemes.cpp @@ -49,8 +49,10 @@ public: { } int acceptNavigationRequestCalls = 0; - bool acceptNavigationRequest(const QUrl &/*url*/, NavigationType /*type*/, bool /*isMainFrame*/) override + bool acceptNavigationRequest(const QUrl &/*url*/, NavigationType type, bool /*isMainFrame*/) override { + if (type == QWebEnginePage::NavigationTypeTyped) + return true; this->acceptNavigationRequestCalls++; return false; } @@ -60,13 +62,14 @@ void tst_QWebEngineSchemes::unknownUrlSchemePolicy() { QWebEngineView view; AcceptNavigationRequestHandler page; + QSignalSpy loadFinishedSpy(&page, &QWebEnginePage::loadFinished); view.setPage(&page); view.resize(400, 40); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QWebEngineSettings *settings = view.page()->profile()->settings(); + settings->setAttribute(QWebEngineSettings::ErrorPageEnabled, false); settings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true); - QSignalSpy loadFinishedSpy(&view, &QWebEngineView::loadFinished); QWebEngineSettings::UnknownUrlSchemePolicy policies[6] = {QWebEngineSettings::DisallowUnknownUrlSchemes, QWebEngineSettings::DisallowUnknownUrlSchemes, @@ -91,7 +94,7 @@ void tst_QWebEngineSchemes::unknownUrlSchemePolicy() } else { // navigation request coming from user interaction shouldAccept = (2 <= i); // all cases except DisallowUnknownUrlSchemes view.setHtml("<html><body><a id='nonexlink' href='nonexistentscheme://somewhere'>nonexistentscheme://somewhere</a></body></html>"); - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 1, 30000); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 1, 15000); // focus and trigger the link view.page()->runJavaScript("document.getElementById('nonexlink').focus();", [&view](const QVariant &result) { Q_UNUSED(result); @@ -101,7 +104,7 @@ void tst_QWebEngineSchemes::unknownUrlSchemePolicy() } bool errorPageEnabled = settings->testAttribute(QWebEngineSettings::ErrorPageEnabled); - QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 2 + (errorPageEnabled ? 1 : 0), 30000); + QTRY_COMPARE_WITH_TIMEOUT(loadFinishedSpy.size(), 2 + (errorPageEnabled ? 1 : 0), 15000); QCOMPARE(page.acceptNavigationRequestCalls, shouldAccept ? 1 : 0); } } |