| Index: LayoutTests/push_messaging/push-messaging-has-permission.html
|
| diff --git a/LayoutTests/push_messaging/push-messaging-has-permission.html b/LayoutTests/push_messaging/push-messaging-has-permission.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9def5d6c3aab53d44f675ceb12eb4a877fc8d5a4
|
| --- /dev/null
|
| +++ b/LayoutTests/push_messaging/push-messaging-has-permission.html
|
| @@ -0,0 +1,48 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| +<head>
|
| +<script src="../resources/js-test.js"></script>
|
| +</head>
|
| +<body>
|
| +<script>
|
| +description('Tests for the Push API hasPermission method.');
|
| +
|
| +if (!window.testRunner)
|
| + debug('This test can not run without testRunner');
|
| +
|
| +window.jsTestIsAsync = true;
|
| +
|
| +function testPushHasPermissionDefault() {
|
| + window.testRunner.setMockPushClientError('permission_default');
|
| + testPushHasPermission('default', testPushHasPermissionDenied);
|
| +}
|
| +
|
| +function testPushHasPermissionDenied() {
|
| + window.testRunner.setMockPushClientError('deny_permission');
|
| + testPushHasPermission('denied', testPushHasPermissionGranted);
|
| +}
|
| +
|
| +function testPushHasPermissionGranted() {
|
| + window.testRunner.setMockPushClientSuccess('endpoint', 'registrationId');
|
| + testPushHasPermission('granted');
|
| +}
|
| +
|
| +function testPushHasPermission(expectedStatus, runNext) {
|
| + navigator.push.hasPermission().then(function(permissionStatus) {
|
| + status = permissionStatus;
|
| + shouldBeEqualToString('status', expectedStatus);
|
| + if (runNext)
|
| + runNext();
|
| + else
|
| + finishJSTest();
|
| + }, function() {
|
| + testFailed('Promise rejected unexpectedly.');
|
| + finishJSTest();
|
| + });
|
| +}
|
| +
|
| +testPushHasPermissionDefault();
|
| +
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|