summaryrefslogtreecommitdiffstats
path: root/tests/auto/core
diff options
context:
space:
mode:
authorDavid Rosca <nowrep@gmail.com>2015-10-08 17:28:19 +0200
committerDavid Rosca <nowrep@gmail.com>2015-10-12 09:12:35 +0000
commiteffa889ba7b7a10b3648a9ded55a5bcd4bae993a (patch)
tree1c737c26152f168fca6ea69f48708ae9eeddc70b /tests/auto/core
parent2e9c6cd0bd6789a4f46fe0bcfbd522f0dd3eb4cb (diff)
Add firstPartyUrl to QWebEngineUrlRequestInfo
Add firstPartyUrl that can be used to identify third-party requests. Change-Id: I2b8e48ff0a1a4402af224c80f91d4e599a61a89c Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'tests/auto/core')
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/resources/firstparty.html5
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp20
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc1
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>