summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorRobert Hogan <robert@roberthogan.net>2011-05-24 11:04:27 +0200
committerPeter Hartmann <peter.hartmann@nokia.com>2011-05-24 12:12:04 +0200
commit093a92fb03e7c163882d1ba5fbdaf9fabb5bd969 (patch)
tree5b67504e44e34abdd0c1dfc69c73bd8118e6a40b /tests/auto
parent6c72eb845657b670af5435ef8084ae91e5dfbbdd (diff)
Add QUrl::topLevelDomain() and move TLD table from QtNetwork to QtCore
Move Qt's copy of the Mozilla public suffix list from QtNetwork to QtCore and use it to expose a new API function QUrl::topLevelDomain(). This function returns the section of the url that is a registrar-controlled top level domain. QtCore now exports a couple of functions to the other Qt modules: qTopLevelDomain, a helper function for QUrl::topLevelDomain(); and qIsEffectiveTLD(), a helper function for QNetworkCookeieJar. The motivation for this new API is to allow QtWebKit implement a Third-Party Cookie blocking policy. For this QtWebKit needs to know the element of the url that is the registry-controlled TLD. Without this knowledge it would end up blocking third-party cookies per host rather than per registry-controlled domain. See also https://bugs.webkit.org/show_bug.cgi?id=45455 Merge-request: 1205 Task-number: QTBUG-13601 Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com> (cherry picked from commit 154402f56dcf8303a6ce601a52215226af8d31ba)
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp4
-rw-r--r--tests/auto/qurl/tst_qurl.cpp26
2 files changed, 28 insertions, 2 deletions
diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
index 178f6d8a64..1f7c2693df 100644
--- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
+++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp
@@ -42,7 +42,7 @@
#include <QtTest/QtTest>
#include <QtNetwork/QNetworkCookieJar>
-#include "private/qnetworkcookiejar_p.h"
+#include "private/qtldurl_p.h"
class tst_QNetworkCookieJar: public QObject
{
@@ -438,7 +438,7 @@ void tst_QNetworkCookieJar::effectiveTLDs()
#endif
QFETCH(QString, domain);
QFETCH(bool, isTLD);
- QCOMPARE(QNetworkCookieJarPrivate::isEffectiveTLD(domain), isTLD);
+ QCOMPARE(qIsEffectiveTLD(domain), isTLD);
}
QTEST_MAIN(tst_QNetworkCookieJar)
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 336ee36584..85aae1fd6e 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -49,6 +49,7 @@
#include <qurl.h>
#include <qtextcodec.h>
#include <qmap.h>
+#include "private/qtldurl_p.h"
// For testsuites
#define IDNA_ACE_PREFIX "xn--"
@@ -88,6 +89,8 @@ public slots:
void init();
void cleanup();
private slots:
+ void effectiveTLDs_data();
+ void effectiveTLDs();
void getSetCheck();
void constructing();
void assignment();
@@ -4005,5 +4008,28 @@ void tst_QUrl::taskQTBUG_8701()
QCOMPARE(foo_uni_bar, QUrl(foo_uni_bar, QUrl::StrictMode).toString());
}
+void tst_QUrl::effectiveTLDs_data()
+{
+ QTest::addColumn<QUrl>("domain");
+ QTest::addColumn<QString>("TLD");
+
+ QTest::newRow("yes0") << QUrl::fromEncoded("http://test.co.uk") << ".co.uk";
+ QTest::newRow("yes1") << QUrl::fromEncoded("http://test.com") << ".com";
+ QTest::newRow("yes2") << QUrl::fromEncoded("http://www.test.de") << ".de";
+ QTest::newRow("yes3") << QUrl::fromEncoded("http://test.ulm.museum") << ".ulm.museum";
+ QTest::newRow("yes4") << QUrl::fromEncoded("http://www.com.krodsherad.no") << ".krodsherad.no";
+ QTest::newRow("yes5") << QUrl::fromEncoded("http://www.co.uk.1.bg") << ".1.bg";
+ QTest::newRow("yes6") << QUrl::fromEncoded("http://www.com.com.cn") << ".com.cn";
+ QTest::newRow("yes7") << QUrl::fromEncoded("http://www.test.org.ws") << ".org.ws";
+ QTest::newRow("yes9") << QUrl::fromEncoded("http://www.com.co.uk.wallonie.museum") << ".wallonie.museum";
+}
+
+void tst_QUrl::effectiveTLDs()
+{
+ QFETCH(QUrl, domain);
+ QFETCH(QString, TLD);
+ QCOMPARE(domain.topLevelDomain(), TLD);
+}
+
QTEST_MAIN(tst_QUrl)
#include "tst_qurl.moc"