diff options
Diffstat (limited to 'tests')
3 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/firstparty.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/firstparty.html new file mode 100644 index 000000000..8bc540c08 --- /dev/null +++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/firstparty.html @@ -0,0 +1,5 @@ +<html> +<body> +<iframe src="qrc:///resources/content.html"></iframe> +</body> +</html> diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp index a2f9e0c37..4891cafd0 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp @@ -66,6 +66,7 @@ private Q_SLOTS: void ipv6HostEncoding(); void requestedUrl(); void setUrlSameUrl(); + void firstPartyUrl(); }; tst_QWebEngineUrlRequestInterceptor::tst_QWebEngineUrlRequestInterceptor() @@ -96,6 +97,7 @@ class TestRequestInterceptor : public QWebEngineUrlRequestInterceptor { public: QList<QUrl> observedUrls; + QList<QUrl> firstPartyUrls; bool shouldIntercept; bool interceptRequest(QWebEngineUrlRequestInfo &info) override @@ -105,6 +107,7 @@ public: info.redirect(QUrl("qrc:///resources/content.html")); observedUrls.append(info.requestUrl()); + firstPartyUrls.append(info.firstPartyUrl()); return shouldIntercept; } TestRequestInterceptor(bool intercept) @@ -253,5 +256,22 @@ void tst_QWebEngineUrlRequestInterceptor::setUrlSameUrl() QCOMPARE(spy.count(), 4); } +void tst_QWebEngineUrlRequestInterceptor::firstPartyUrl() +{ + QWebEnginePage page; + TestRequestInterceptor interceptor(/* intercept */ false); + page.profile()->setRequestInterceptor(&interceptor); + + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + + page.setUrl(QUrl("qrc:///resources/firstparty.html")); + waitForSignal(&page, SIGNAL(loadFinished(bool))); + 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(spy.count(), 1); +} + 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 afeae268b..ca045e7fc 100644 --- a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc +++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc @@ -2,5 +2,6 @@ <qresource> <file>resources/index.html</file> <file>resources/content.html</file> + <file>resources/firstparty.html</file> </qresource> </RCC> |