From c37ee40aa43aac7a717f0e5c24816834cffb2b76 Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Tue, 13 Nov 2018 13:52:45 +0100 Subject: Fix QWebEngineUrlRequestInfo::firstPartyUrl() after 69-based The issue was introduced by this Chromium change: https://chromium-review.googlesource.com/c/chromium/src/+/1025772/ Add new auto tests for first party url. Depends on Chromium change: d2f5d6869f Add net::URLRequest::first_party_url() Task-number: QTBUG-70790 Change-Id: Ib43bde69990e7fb1d495cc32ac2f6860a613f185 Reviewed-by: Allan Sandfeld Jensen --- .../resources/favicon.html | 7 + .../resources/fontawesome.woff | Bin 0 -> 6724 bytes .../resources/icons/favicon.png | Bin 0 -> 3961 bytes .../resources/iframe.html | 6 + .../resources/iframe2.html | 6 + .../resources/iframe3.html | 5 + .../resources/image.html | 5 + .../resources/image_in_iframe.html | 5 + .../resources/media.html | 7 + .../resources/media.mp4 | Bin 0 -> 1493 bytes .../resources/media_in_iframe.html | 5 + .../resources/resource.html | 9 + .../resources/resource_in_iframe.html | 5 + .../resources/script.js | 3 + .../resources/style.css | 7 + .../tst_qwebengineurlrequestinterceptor.cpp | 244 +++++++++++++++++++-- .../tst_qwebengineurlrequestinterceptor.qrc | 25 ++- tests/auto/core/tests.pri | 2 + 18 files changed, 323 insertions(+), 18 deletions(-) create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/favicon.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/fontawesome.woff create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/icons/favicon.png create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe2.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe3.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/image.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/image_in_iframe.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/media.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/media.mp4 create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/media_in_iframe.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/resource.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/resource_in_iframe.html create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/script.js create mode 100644 tests/auto/core/qwebengineurlrequestinterceptor/resources/style.css (limited to 'tests/auto/core') diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/favicon.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/favicon.html new file mode 100644 index 000000000..5251d6ef7 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/favicon.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/fontawesome.woff b/tests/auto/core/qwebengineurlrequestinterceptor/resources/fontawesome.woff new file mode 100644 index 000000000..239b9c94e Binary files /dev/null and b/tests/auto/core/qwebengineurlrequestinterceptor/resources/fontawesome.woff differ diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/icons/favicon.png b/tests/auto/core/qwebengineurlrequestinterceptor/resources/icons/favicon.png new file mode 100644 index 000000000..35717cca5 Binary files /dev/null and b/tests/auto/core/qwebengineurlrequestinterceptor/resources/icons/favicon.png differ diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe.html new file mode 100644 index 000000000..f17027c7a --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe.html @@ -0,0 +1,6 @@ + + +

top

+ + + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe3.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe3.html new file mode 100644 index 000000000..ed6ac5b94 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/iframe3.html @@ -0,0 +1,5 @@ + + +

inner

+ + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/image.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/image.html new file mode 100644 index 000000000..b82e6aab2 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/image.html @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/image_in_iframe.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/image_in_iframe.html new file mode 100644 index 000000000..2a3ac117c --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/image_in_iframe.html @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/media.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/media.html new file mode 100644 index 000000000..fd478a679 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/media.html @@ -0,0 +1,7 @@ + + + + + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/media.mp4 b/tests/auto/core/qwebengineurlrequestinterceptor/resources/media.mp4 new file mode 100644 index 000000000..1431e98dd Binary files /dev/null and b/tests/auto/core/qwebengineurlrequestinterceptor/resources/media.mp4 differ diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/media_in_iframe.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/media_in_iframe.html new file mode 100644 index 000000000..39e9bd9bb --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/media_in_iframe.html @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/resource.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/resource.html new file mode 100644 index 000000000..040acee00 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/resource.html @@ -0,0 +1,9 @@ + + + + + + +

some text

+ + + + + + diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/script.js b/tests/auto/core/qwebengineurlrequestinterceptor/resources/script.js new file mode 100644 index 000000000..e6e0e8e7d --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/script.js @@ -0,0 +1,3 @@ +var request = new XMLHttpRequest(); +request.open('GET', 'test', /* async = */ false); +request.send(); diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/style.css b/tests/auto/core/qwebengineurlrequestinterceptor/resources/style.css new file mode 100644 index 000000000..5ed3811e2 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/style.css @@ -0,0 +1,7 @@ +@font-face { + font-family: fontawesome; + src: url(fontawesome.woff); +} +p { + font-family: fontawesome; +} diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp index 50a3e6ff6..23bf88417 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp @@ -28,6 +28,7 @@ #include "../../widgets/util.h" #include +#include #include #include #include @@ -53,6 +54,11 @@ private Q_SLOTS: void requestedUrl(); void setUrlSameUrl(); void firstPartyUrl(); + void firstPartyUrlNestedIframes_data(); + void firstPartyUrlNestedIframes(); + void requestInterceptorByResourceType_data(); + void requestInterceptorByResourceType(); + void firstPartyUrlHttp(); }; tst_QWebEngineUrlRequestInterceptor::tst_QWebEngineUrlRequestInterceptor() @@ -79,11 +85,22 @@ void tst_QWebEngineUrlRequestInterceptor::cleanupTestCase() { } +struct RequestInfo { + RequestInfo(QWebEngineUrlRequestInfo &info) + : requestUrl(info.requestUrl()) + , firstPartyUrl(info.firstPartyUrl()) + , resourceType(info.resourceType()) + {} + + QUrl requestUrl; + QUrl firstPartyUrl; + int resourceType; +}; + class TestRequestInterceptor : public QWebEngineUrlRequestInterceptor { public: - QList observedUrls; - QList firstPartyUrls; + QList requestInfos; bool shouldIntercept; void interceptRequest(QWebEngineUrlRequestInfo &info) override @@ -95,9 +112,51 @@ public: if (shouldIntercept && info.requestUrl().toString().endsWith(QLatin1String("__placeholder__"))) info.redirect(QUrl("qrc:///resources/content.html")); - observedUrls.append(info.requestUrl()); - firstPartyUrls.append(info.firstPartyUrl()); + requestInfos.append(info); + } + + bool shouldSkipRequest(const RequestInfo &requestInfo) + { + if (requestInfo.resourceType == QWebEngineUrlRequestInfo::ResourceTypeMainFrame || + requestInfo.resourceType == QWebEngineUrlRequestInfo::ResourceTypeSubFrame) + return false; + + // Skip import documents and sandboxed documents. + // See Document::SiteForCookies() in chromium/third_party/blink/renderer/core/dom/document.cc. + // + // TODO: Change this to empty URL during the next chromium update: + // https://chromium-review.googlesource.com/c/chromium/src/+/1213082/ + return requestInfo.firstPartyUrl == QUrl("data:,"); + } + + QList getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceType type) + { + QList infos; + + foreach (auto requestInfo, requestInfos) { + if (shouldSkipRequest(requestInfo)) + continue; + + if (type == requestInfo.resourceType) + infos.append(requestInfo); + } + + return infos; + } + + bool hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceType type) + { + foreach (auto requestInfo, requestInfos) { + if (shouldSkipRequest(requestInfo)) + continue; + + if (type == requestInfo.resourceType) + return true; + } + + return false; } + TestRequestInterceptor(bool intercept) : shouldIntercept(intercept) { @@ -135,7 +194,7 @@ void tst_QWebEngineUrlRequestInterceptor::interceptRequest() // The redirection for __placeholder__ should succeed. QVERIFY(success.toBool()); loadSpy.clear(); - QCOMPARE(interceptor.observedUrls.count(), 4); + QCOMPARE(interceptor.requestInfos.count(), 4); // Make sure that registering an observer does not modify the request. TestRequestInterceptor observer(/* intercept */ false); @@ -145,7 +204,7 @@ void tst_QWebEngineUrlRequestInterceptor::interceptRequest() success = loadSpy.takeFirst().takeFirst(); // Since we do not intercept, loading an invalid path should not succeed. QVERIFY(!success.toBool()); - QCOMPARE(observer.observedUrls.count(), 1); + QCOMPARE(observer.requestInfos.count(), 1); } class LocalhostContentProvider : public QWebEngineUrlRequestInterceptor @@ -203,19 +262,19 @@ void tst_QWebEngineUrlRequestInterceptor::requestedUrl() page.setUrl(QUrl("qrc:///resources/__placeholder__")); QVERIFY(spy.wait()); QTRY_COMPARE(spy.count(), 1); - QCOMPARE(interceptor.observedUrls.at(0), QUrl("qrc:///resources/content.html")); + QCOMPARE(interceptor.requestInfos.at(0).requestUrl, QUrl("qrc:///resources/content.html")); QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); page.setUrl(QUrl("qrc:/non-existent.html")); QTRY_COMPARE(spy.count(), 2); - QCOMPARE(interceptor.observedUrls.at(2), QUrl("qrc:/non-existent.html")); + QCOMPARE(interceptor.requestInfos.at(2).requestUrl, QUrl("qrc:/non-existent.html")); QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); page.setUrl(QUrl("http://abcdef.abcdef")); QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 3, 12000); - QCOMPARE(interceptor.observedUrls.at(3), QUrl("http://abcdef.abcdef/")); + QCOMPARE(interceptor.requestInfos.at(3).requestUrl, QUrl("http://abcdef.abcdef/")); QCOMPARE(page.requestedUrl(), QUrl("qrc:///resources/__placeholder__")); QCOMPARE(page.url(), QUrl("qrc:///resources/content.html")); } @@ -262,12 +321,171 @@ void tst_QWebEngineUrlRequestInterceptor::firstPartyUrl() page.setUrl(QUrl("qrc:///resources/firstparty.html")); QVERIFY(spy.wait()); - QCOMPARE(interceptor.observedUrls.at(0), QUrl("qrc:///resources/firstparty.html")); - QCOMPARE(interceptor.observedUrls.at(1), QUrl("qrc:///resources/content.html")); - QCOMPARE(interceptor.firstPartyUrls.at(0), QUrl("qrc:///resources/firstparty.html")); - QCOMPARE(interceptor.firstPartyUrls.at(1), QUrl("qrc:///resources/firstparty.html")); + QCOMPARE(interceptor.requestInfos.at(0).requestUrl, QUrl("qrc:///resources/firstparty.html")); + QCOMPARE(interceptor.requestInfos.at(1).requestUrl, QUrl("qrc:///resources/content.html")); + QCOMPARE(interceptor.requestInfos.at(0).firstPartyUrl, QUrl("qrc:///resources/firstparty.html")); + QCOMPARE(interceptor.requestInfos.at(1).firstPartyUrl, QUrl("qrc:///resources/firstparty.html")); QCOMPARE(spy.count(), 1); } +void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes_data() +{ + QUrl url = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/iframe.html")); + + QTest::addColumn("requestUrl"); + QTest::newRow("file") << url; + QTest::newRow("qrc") << QUrl("qrc:///resources/iframe.html"); +} + +void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlNestedIframes() +{ + QFETCH(QUrl, requestUrl); + + if (requestUrl.scheme() == "file" && !QDir(TESTS_SOURCE_DIR).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll); + + QString adjustedUrl = requestUrl.adjusted(QUrl::RemoveFilename).toString(); + + QWebEngineProfile profile; + TestRequestInterceptor interceptor(/* intercept */ false); + profile.setRequestInterceptor(&interceptor); + + QWebEnginePage page(&profile); + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + page.setUrl(requestUrl); + QTRY_COMPARE(loadSpy.count(), 1); + + RequestInfo info = interceptor.requestInfos.at(0); + QCOMPARE(info.requestUrl, requestUrl); + QCOMPARE(info.firstPartyUrl, requestUrl); + QCOMPARE(info.resourceType, QWebEngineUrlRequestInfo::ResourceTypeMainFrame); + + info = interceptor.requestInfos.at(1); + QCOMPARE(info.requestUrl, QUrl(adjustedUrl + "iframe2.html")); + QCOMPARE(info.firstPartyUrl, requestUrl); + QCOMPARE(info.resourceType, QWebEngineUrlRequestInfo::ResourceTypeSubFrame); + + info = interceptor.requestInfos.at(2); + QCOMPARE(info.requestUrl, QUrl(adjustedUrl + "iframe3.html")); + QCOMPARE(info.firstPartyUrl, requestUrl); + QCOMPARE(info.resourceType, QWebEngineUrlRequestInfo::ResourceTypeSubFrame); +} + +void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType_data() +{ + QUrl firstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/resource_in_iframe.html")); + QUrl styleRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/style.css")); + QUrl scriptRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/script.js")); + QUrl fontRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/fontawesome.woff")); + QUrl xhrRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/test")); + QUrl imageFirstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/image_in_iframe.html")); + QUrl imageRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/icons/favicon.png")); + QUrl mediaFirstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/media_in_iframe.html")); + QUrl mediaRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/media.mp4")); + QUrl faviconFirstPartyUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/favicon.html")); + QUrl faviconRequestUrl = QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebengineurlrequestinterceptor/resources/icons/favicon.png")); + + QTest::addColumn("requestUrl"); + QTest::addColumn("firstPartyUrl"); + QTest::addColumn("resourceType"); + + QTest::newRow("StyleSheet") << styleRequestUrl << firstPartyUrl << static_cast(QWebEngineUrlRequestInfo::ResourceTypeStylesheet); + QTest::newRow("Script") << scriptRequestUrl << firstPartyUrl << static_cast(QWebEngineUrlRequestInfo::ResourceTypeScript); + QTest::newRow("Image") << imageRequestUrl << imageFirstPartyUrl << static_cast(QWebEngineUrlRequestInfo::ResourceTypeImage); + QTest::newRow("FontResource") << fontRequestUrl << firstPartyUrl << static_cast(QWebEngineUrlRequestInfo::ResourceTypeFontResource); + QTest::newRow("Media") << mediaRequestUrl << mediaFirstPartyUrl << static_cast(QWebEngineUrlRequestInfo::ResourceTypeMedia); + QTest::newRow("Favicon") << faviconRequestUrl << faviconFirstPartyUrl << static_cast(QWebEngineUrlRequestInfo::ResourceTypeFavicon); + QTest::newRow("Xhr") << xhrRequestUrl << firstPartyUrl << static_cast(QWebEngineUrlRequestInfo::ResourceTypeXhr); +} + +void tst_QWebEngineUrlRequestInterceptor::requestInterceptorByResourceType() +{ + if (!QDir(TESTS_SOURCE_DIR).exists()) + W_QSKIP(QString("This test requires access to resources found in '%1'").arg(TESTS_SOURCE_DIR).toLatin1().constData(), SkipAll); + + QFETCH(QUrl, requestUrl); + QFETCH(QUrl, firstPartyUrl); + QFETCH(int, resourceType); + + QWebEngineProfile profile; + TestRequestInterceptor interceptor(/* intercept */ false); + profile.setRequestInterceptor(&interceptor); + + QWebEnginePage page(&profile); + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + page.setUrl(firstPartyUrl); + QTRY_COMPARE(loadSpy.count(), 1); + + QTRY_COMPARE(interceptor.getUrlRequestForType(static_cast(resourceType)).count(), 1); + QList infos = interceptor.getUrlRequestForType(static_cast(resourceType)); + QCOMPARE(infos.at(0).requestUrl, requestUrl); + QCOMPARE(infos.at(0).firstPartyUrl, firstPartyUrl); + QCOMPARE(infos.at(0).resourceType, resourceType); +} + +void tst_QWebEngineUrlRequestInterceptor::firstPartyUrlHttp() +{ + QWebEngineProfile profile; + TestRequestInterceptor interceptor(/* intercept */ false); + profile.setRequestInterceptor(&interceptor); + + QWebEnginePage page(&profile); + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + QUrl firstPartyUrl = QUrl("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_video"); + page.setUrl(QUrl(firstPartyUrl)); + if (!loadSpy.wait(15000) || !loadSpy.at(0).at(0).toBool()) + QSKIP("Couldn't load page from network, skipping test."); + + QList infos; + + // SubFrame + QTRY_VERIFY(interceptor.hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeSubFrame)); + infos = interceptor.getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeSubFrame); + foreach (auto info, infos) + QCOMPARE(info.firstPartyUrl, firstPartyUrl); + + // Stylesheet + QTRY_VERIFY(interceptor.hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeStylesheet)); + infos = interceptor.getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeStylesheet); + foreach (auto info, infos) + QCOMPARE(info.firstPartyUrl, firstPartyUrl); + + // Script + QTRY_VERIFY(interceptor.hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeScript)); + infos = interceptor.getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeScript); + foreach (auto info, infos) + QCOMPARE(info.firstPartyUrl, firstPartyUrl); + + // Image + QTRY_VERIFY(interceptor.hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeImage)); + infos = interceptor.getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeImage); + foreach (auto info, infos) + QCOMPARE(info.firstPartyUrl, firstPartyUrl); + + // FontResource + QTRY_VERIFY(interceptor.hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeFontResource)); + infos = interceptor.getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeFontResource); + foreach (auto info, infos) + QCOMPARE(info.firstPartyUrl, firstPartyUrl); + + // Media + QTRY_VERIFY(interceptor.hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeMedia)); + infos = interceptor.getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeMedia); + foreach (auto info, infos) + QCOMPARE(info.firstPartyUrl, firstPartyUrl); + + // Favicon + QTRY_VERIFY(interceptor.hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeFavicon)); + infos = interceptor.getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeFavicon); + foreach (auto info, infos) + QCOMPARE(info.firstPartyUrl, firstPartyUrl); + + // XMLHttpRequest + QTRY_VERIFY(interceptor.hasUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeXhr)); + infos = interceptor.getUrlRequestForType(QWebEngineUrlRequestInfo::ResourceTypeXhr); + foreach (auto info, infos) + QCOMPARE(info.firstPartyUrl, firstPartyUrl); +} + QTEST_MAIN(tst_QWebEngineUrlRequestInterceptor) #include "tst_qwebengineurlrequestinterceptor.moc" diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc index ca045e7fc..13dbb134e 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc @@ -1,7 +1,22 @@ - - resources/index.html - resources/content.html - resources/firstparty.html - + + resources/content.html + resources/favicon.html + resources/firstparty.html + resources/fontawesome.woff + resources/iframe.html + resources/iframe2.html + resources/iframe3.html + resources/image.html + resources/image_in_iframe.html + resources/index.html + resources/media.html + resources/media.mp4 + resources/media_in_iframe.html + resources/resource.html + resources/resource_in_iframe.html + resources/script.js + resources/style.css + resources/icons/favicon.png + diff --git a/tests/auto/core/tests.pri b/tests/auto/core/tests.pri index 885cf60d4..59d6c0865 100644 --- a/tests/auto/core/tests.pri +++ b/tests/auto/core/tests.pri @@ -12,4 +12,6 @@ exists($$_PRO_FILE_PWD_/$${TARGET}.qrc): RESOURCES += $${TARGET}.qrc QT += testlib network webenginewidgets widgets +# This define is used by some tests to look up resources in the source tree +DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\" include(../embed_info_plist.pri) -- cgit v1.2.3