summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2021-06-02 19:40:10 +0200
committerMichal Klocek <michal.klocek@qt.io>2021-06-25 01:33:45 +0200
commitd0ff107c0096fa0e0347ddadda9a98438d27631e (patch)
treec11519ed00eeff9092c83401b2b337a507aa9815 /tests/auto/widgets
parenta5e627160cf9a05ce0dd92e541d44b1861eb84c0 (diff)
Make default profile off the record
Make default profile otr, this prevents accessing data cache which could be created by older other version of Chromium. Allow to register a protocol handler on ort profile. [ChangeLog][QtWebEngineCore] Default profile is off-the-record Off-the-record profile can have registered protocol handlers. Task-number: QTBUG-66068 Pick-to: 6.2 Change-Id: Ief202de5c6734d293cb64d83ad447b1eba19e9a4 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp80
1 files changed, 36 insertions, 44 deletions
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index 60073251c..a998d7998 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -57,9 +57,8 @@ class tst_QWebEngineProfile : public QObject
private Q_SLOTS:
void initTestCase();
- void init();
- void cleanup();
- void privateProfile();
+ void userDefaultProfile();
+ void defaultProfile();
void testProfile();
void clearDataFromCache();
void disableCache();
@@ -105,48 +104,41 @@ void tst_QWebEngineProfile::initTestCase()
QWebEngineUrlScheme::registerScheme(myscheme);
}
-void tst_QWebEngineProfile::init()
+void tst_QWebEngineProfile::userDefaultProfile()
{
- //make sure defualt global profile is 'default' across all the tests
- QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
- QVERIFY(profile);
- QVERIFY(!profile->isOffTheRecord());
- QCOMPARE(profile->storageName(), QStringLiteral("Default"));
- QCOMPARE(profile->httpCacheType(), QWebEngineProfile::DiskHttpCache);
- QCOMPARE(profile->persistentCookiesPolicy(), QWebEngineProfile::AllowPersistentCookies);
- QCOMPARE(profile->cachePath(), QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
- + QStringLiteral("/QtWebEngine/Default"));
- QCOMPARE(profile->persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
- + QStringLiteral("/QtWebEngine/Default"));
+ QWebEngineProfile profile("Default");
+ QVERIFY(!profile.isOffTheRecord());
+ QCOMPARE(profile.storageName(), QStringLiteral("Default"));
+ QCOMPARE(profile.httpCacheType(), QWebEngineProfile::DiskHttpCache);
+ QCOMPARE(profile.persistentCookiesPolicy(), QWebEngineProfile::AllowPersistentCookies);
+ QCOMPARE(profile.cachePath(),
+ QStandardPaths::writableLocation(QStandardPaths::CacheLocation)
+ + QStringLiteral("/QtWebEngine/Default"));
+ QCOMPARE(profile.persistentStoragePath(),
+ QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ + QStringLiteral("/QtWebEngine/Default"));
}
-void tst_QWebEngineProfile::cleanup()
+void tst_QWebEngineProfile::defaultProfile()
{
QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
- profile->setCachePath(QString());
- profile->setPersistentStoragePath(QString());
- profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
- profile->removeAllUrlSchemeHandlers();
-}
-
-void tst_QWebEngineProfile::privateProfile()
-{
- QWebEngineProfile otrProfile;
- QVERIFY(otrProfile.isOffTheRecord());
- QCOMPARE(otrProfile.httpCacheType(), QWebEngineProfile::MemoryHttpCache);
- QCOMPARE(otrProfile.persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies);
- QCOMPARE(otrProfile.cachePath(), QString());
- QCOMPARE(otrProfile.persistentStoragePath(), QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
- + QStringLiteral("/QtWebEngine/OffTheRecord"));
+ QVERIFY(profile);
+ QVERIFY(profile->isOffTheRecord());
+ QCOMPARE(profile->httpCacheType(), QWebEngineProfile::MemoryHttpCache);
+ QCOMPARE(profile->persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies);
+ QCOMPARE(profile->cachePath(), QString());
+ QCOMPARE(profile->persistentStoragePath(),
+ QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ + QStringLiteral("/QtWebEngine/OffTheRecord"));
// TBD: setters do not really work
- otrProfile.setCachePath(QStringLiteral("/home/foo/bar"));
- QCOMPARE(otrProfile.cachePath(), QString());
- otrProfile.setPersistentStoragePath(QStringLiteral("/home/foo/bar"));
- QCOMPARE(otrProfile.persistentStoragePath(), QStringLiteral("/home/foo/bar"));
- otrProfile.setHttpCacheType(QWebEngineProfile::DiskHttpCache);
- QCOMPARE(otrProfile.httpCacheType(), QWebEngineProfile::MemoryHttpCache);
- otrProfile.setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
- QCOMPARE(otrProfile.persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies);
+ profile->setCachePath(QStringLiteral("/home/foo/bar"));
+ QCOMPARE(profile->cachePath(), QString());
+ profile->setPersistentStoragePath(QStringLiteral("/home/foo/bar"));
+ QCOMPARE(profile->persistentStoragePath(), QStringLiteral("/home/foo/bar"));
+ profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
+ QCOMPARE(profile->httpCacheType(), QWebEngineProfile::MemoryHttpCache);
+ profile->setPersistentCookiesPolicy(QWebEngineProfile::ForcePersistentCookies);
+ QCOMPARE(profile->persistentCookiesPolicy(), QWebEngineProfile::NoPersistentCookies);
}
@@ -255,18 +247,18 @@ void tst_QWebEngineProfile::disableCache()
AutoDir cacheDir("./tst_QWebEngineProfile_disableCache");
- QWebEnginePage page;
- QWebEngineProfile *profile = page.profile();
- profile->setCachePath(cacheDir.path());
+ QWebEngineProfile profile("disableCache");
+ QWebEnginePage page(&profile);
+ profile.setCachePath(cacheDir.path());
QVERIFY(!cacheDir.exists("Cache"));
- profile->setHttpCacheType(QWebEngineProfile::NoCache);
+ profile.setHttpCacheType(QWebEngineProfile::NoCache);
// Wait for cache to be cleared.
QTest::qWait(1000);
QVERIFY(loadSync(&page, server.url("/hedgehog.html")));
QVERIFY(!cacheDir.exists("Cache"));
- profile->setHttpCacheType(QWebEngineProfile::DiskHttpCache);
+ profile.setHttpCacheType(QWebEngineProfile::DiskHttpCache);
QVERIFY(loadSync(&page, server.url("/hedgehog.html")));
QVERIFY(cacheDir.exists("Cache"));