diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-04-03 12:34:04 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-04-05 15:14:59 +0000 |
commit | a5ced3ad19e2ada6a0ed5a48de21d2879ba2f333 (patch) | |
tree | 38081c0f605fcdfed63482b72c6c8a2a06d6beba /tests/auto/core | |
parent | 0aca80b0a29aa64536653a56aa87f626acc47189 (diff) |
Use cookie-access rights for webcontent settings
This ties the indexed-db, DOM storage and filesystem access to
cookie rights as they can all do the same cookies. A previous
patch did the same for workers, but we were missing this
class to complete the logic.
Change-Id: I5ea894b6c631bcf25439759174866d260b91b71a
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'tests/auto/core')
-rw-r--r-- | tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp index 4350575ab..b24c05a37 100644 --- a/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp +++ b/tests/auto/core/qwebenginecookiestore/tst_qwebenginecookiestore.cpp @@ -52,6 +52,7 @@ private Q_SLOTS: void setAndDeleteCookie(); void batchCookieTasks(); void basicFilter(); + void html5featureFilter(); private: QWebEngineProfile m_profile; @@ -219,5 +220,30 @@ void tst_QWebEngineCookieStore::basicFilter() QCOMPARE(cookieAddedSpy.count(), 2); } +void tst_QWebEngineCookieStore::html5featureFilter() +{ + QWebEnginePage page(&m_profile); + QWebEngineCookieStore *client = m_profile.cookieStore(); + + QAtomicInt accessTested = 0; + client->setCookieFilter([&](const QWebEngineCookieStore::FilterRequest &){ ++accessTested; return false;}); + + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + + page.load(QUrl("qrc:///resources/content.html")); + + QTRY_COMPARE(loadSpy.count(), 1); + QVERIFY(loadSpy.takeFirst().takeFirst().toBool()); + QCOMPARE(accessTested.loadAcquire(), 0); + QTest::ignoreMessage(QtCriticalMsg, QRegularExpression(".*Uncaught SecurityError.*sessionStorage.*")); + page.runJavaScript("sessionStorage.test = 5;"); + QTRY_COMPARE(accessTested.loadAcquire(), 1); + + QTest::ignoreMessage(QtCriticalMsg, QRegularExpression(".*Uncaught SecurityError.*sessionStorage.*")); + QAtomicInt callbackTriggered = 0; + page.runJavaScript("sessionStorage.test", [&](const QVariant &v) { QVERIFY(!v.isValid()); callbackTriggered = 1; }); + QTRY_VERIFY(callbackTriggered); +} + QTEST_MAIN(tst_QWebEngineCookieStore) #include "tst_qwebenginecookiestore.moc" |