bdd: Add some tests for HTML5 notifications.

This commit is contained in:
Florian Bruhin 2016-01-14 07:49:25 +01:00
parent 1ddf817f4c
commit cf09e477a4
2 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function permission_cb(permission) {
switch (permission) {
case "granted":
console.log("notification permission granted");
break;
case "denied":
console.log("notification permission denied");
break;
case "default":
console.log("notification permission aborted");
break;
default:
console.log("[FAIL] unknown value for permission: " + Notification.permission);
break;
}
}
function get_notification_permission() {
if ("Notification" in window) {
if (Notification.permission === "default") {
Notification.requestPermission(permission_cb);
} else {
console.log("[FAIL] unknown initial value for Notification.permission: " + Notification.permission);
}
} else {
console.log("[FAIL] notifications unavailable");
}
}
</script>
</head>
<body>
<input type="button" onclick="get_notification_permission()" value="Get notification permission">
</body>
</html>

View File

@ -137,3 +137,43 @@ Feature: Prompts
And I wait for a prompt
And I run :leave-mode
Then the javascript message "geolocation permission denied" should be logged
# Notifications
Scenario: Always rejecting notifications
When I set content -> notifications to false
And I open data/prompt/notifications.html
And I click the button
Then the javascript message "notification permission denied" should be logged
Scenario: Always accepting notifications
When I set content -> notifications to true
And I open data/prompt/notifications.html
And I click the button
Then the javascript message "notification permission granted" should be logged
Scenario: notifications with ask -> false
When I set content -> notifications to ask
And I open data/prompt/notifications.html
And I click the button
And I wait for a prompt
And I run :prompt-no
Then the javascript message "notification permission denied" should be logged
Scenario: notifications with ask -> true
When I set content -> notifications to ask
And I open data/prompt/notifications.html
And I click the button
And I wait for a prompt
And I run :prompt-yes
Then the javascript message "notification permission granted" should be logged
# This actually gives us a denied rather than an aborted
@skip
Scenario: notifications with ask -> abort
When I set content -> notifications to ask
And I open data/prompt/notifications.html
And I click the button
And I wait for a prompt
And I run :leave-mode
Then the javascript message "notification permission aborted" should be logged