diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-14 12:29:28 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-10-14 12:29:54 +0200 |
commit | 9be23eb946580519b2b0600cc854ec8050b90659 (patch) | |
tree | 63ccf0e565f346a0788d937b004e01d2ec029b5e /tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp | |
parent | 4f2e66f9d898e9c11a7ad6e552d0d47bb15d4051 (diff) | |
parent | 981e38d2dc82c047c6ad8ec19427d3ac7434dc3c (diff) |
Merge remote-tracking branch 'origin/5.6' into devwip/47-based
Change-Id: I0569b04ced3456a1d5d91e02e117963115fcf1b2
Diffstat (limited to 'tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp')
-rw-r--r-- | tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp | 20 |
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" |