summaryrefslogtreecommitdiffstats
path: root/tests/quicktestbrowser
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2019-01-31 13:08:21 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-06 15:18:18 +0000
commitf4ca67aa7f70f58d39ef8689ddd5910e215ed6cd (patch)
treeebb9937672b14c725de14fd7da6e3eeac269e861 /tests/quicktestbrowser
parent7aa06a1614b7ca6508d96ee2e8ef0f4c49038a6f (diff)
Web Notifications API
Implements API for end-user notifications. Co-authored by Allan Sandfeld Jensen [ChangeLog][Profile] Support for Web Notifications API for end-user notifications through QWebEngineNotification Task-number: QTBUG-50995 Fixes: QTBUG-51191 Change-Id: Icebaaa05275a713e801f1f8ecdaaec725fa264c8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/quicktestbrowser')
-rw-r--r--tests/quicktestbrowser/ApplicationRoot.qml1
-rw-r--r--tests/quicktestbrowser/BrowserWindow.qml12
-rw-r--r--tests/quicktestbrowser/FeaturePermissionBar.qml29
3 files changed, 29 insertions, 13 deletions
diff --git a/tests/quicktestbrowser/ApplicationRoot.qml b/tests/quicktestbrowser/ApplicationRoot.qml
index 980016535..e2248e350 100644
--- a/tests/quicktestbrowser/ApplicationRoot.qml
+++ b/tests/quicktestbrowser/ApplicationRoot.qml
@@ -53,6 +53,7 @@ QtObject {
var newWindow = browserWindowComponent.createObject(root)
newWindow.currentWebView.profile = profile
profile.downloadRequested.connect(newWindow.onDownloadRequested)
+ profile.userNotification.connect(newWindow.onUserNotification)
return newWindow
}
function createDialog(profile) {
diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml
index 22f98e1c5..381e9c142 100644
--- a/tests/quicktestbrowser/BrowserWindow.qml
+++ b/tests/quicktestbrowser/BrowserWindow.qml
@@ -505,6 +505,18 @@ ApplicationWindow {
download.accept()
}
+ MessageDialog {
+ id: notificationDialog
+ width: 200
+ standardButtons: StandardButton.Ok
+ }
+
+ function onUserNotification(notification) {
+ notificationDialog.title = notification.title
+ notificationDialog.text = notification.origin.toString() + '\n' + notification.message
+ notificationDialog.open()
+ }
+
ZoomController {
id: zoomController
y: parent.mapFromItem(currentWebView, 0 , 0).y - 4
diff --git a/tests/quicktestbrowser/FeaturePermissionBar.qml b/tests/quicktestbrowser/FeaturePermissionBar.qml
index 9c0b25966..500d13206 100644
--- a/tests/quicktestbrowser/FeaturePermissionBar.qml
+++ b/tests/quicktestbrowser/FeaturePermissionBar.qml
@@ -40,10 +40,24 @@ Rectangle {
visible: false
height: acceptButton.height + 4
- onRequestedFeatureChanged: {
- message.text = securityOrigin + " wants to access " + message.textForFeature(requestedFeature);
+
+ function textForFeature(feature) {
+ switch (feature) {
+ case WebEngineView.Geolocation: return 'Allow %1 to access your location information?'
+ case WebEngineView.MediaAudioCapture: return 'Allow %1 to access your microphone?'
+ case WebEngineView.MediaVideoCapture: return 'Allow %1 to access your webcam?'
+ case WebEngineView.MediaAudioVideoCapture: return 'Allow %1 to access your microphone and webcam?'
+ case WebEngineView.DesktopVideoCapture: return 'Allow %1 to capture video of your desktop?'
+ case WebEngineView.DesktopAudioVideoCapture: return 'Allow %1 to capture audio and video of your desktop?'
+ case WebEngineView.Notifications: return 'Allow %1 to show notification on your desktop?'
+ default: break
+ }
+ return 'Grant permission for %1 to unknown or unsupported feature [' + feature + ']?'
}
+ onRequestedFeatureChanged: {
+ message.text = textForFeature(requestedFeature).arg(securityOrigin);
+ }
RowLayout {
anchors {
@@ -54,17 +68,6 @@ Rectangle {
Label {
id: message
Layout.fillWidth: true
-
- function textForFeature(feature) {
- if (feature === WebEngineView.MediaAudioCapture)
- return "your microphone"
- if (feature === WebEngineView.MediaVideoCapture)
- return "your camera"
- if (feature === WebEngineView.MediaAudioVideoCapture)
- return "your camera and microphone"
- if (feature === WebEngineView.Geolocation)
- return "your position"
- }
}
Button {