diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-04-30 13:38:45 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-05-05 12:50:08 +0200 |
commit | 45a3e4c5b6e3953a8afcfafcfc83eef23b6400aa (patch) | |
tree | 056e7e2cb003fdc10651180ef2ff9a7f63ef812c /tests | |
parent | 53498cb73392a222a113ae257f24f91e6d912518 (diff) |
Document early feature reply for Notification
Make it easier to get right by normalizing the origin and test it.
Task-number: QTBUG-83476
Change-Id: Ie4562e937cbcca5a1cf24e00d340a3ac2e9e2210
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index ab19548e8..3f3534931 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -207,6 +207,7 @@ private Q_SLOTS: void notificationRequest(); void sendNotification(); void contentsSize(); + void notificationPermission(); void setLifecycleState(); void setVisible(); @@ -3615,6 +3616,18 @@ void tst_QWebEnginePage::notificationRequest() QCOMPARE(page.getPermission(), permission); } +void tst_QWebEnginePage::notificationPermission() +{ + QWebEngineProfile otr; + QWebEnginePage page(&otr, nullptr); + QSignalSpy spy(&page, &QWebEnginePage::loadFinished); + page.setHtml(QString("<html><body>Test</body></html>"), QUrl("https://www.example.com")); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(evaluateJavaScriptSync(&page, QStringLiteral("Notification.permission")), QLatin1String("default")); + page.setFeaturePermission(QUrl("https://www.example.com"), QWebEnginePage::Notifications, QWebEnginePage::PermissionGrantedByUser); + QTRY_COMPARE(evaluateJavaScriptSync(&page, QStringLiteral("Notification.permission")), QLatin1String("granted")); +} + void tst_QWebEnginePage::sendNotification() { NotificationPage page(QWebEnginePage::PermissionGrantedByUser); |