summaryrefslogtreecommitdiffstats
path: root/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp')
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp20
1 files changed, 20 insertions, 0 deletions
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"