| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script> | |
| 8 description('Tests for the Push API hasPermission method.'); | |
| 9 | |
| 10 if (!window.testRunner) | |
| 11 debug('This test can not run without testRunner'); | |
| 12 | |
| 13 window.jsTestIsAsync = true; | |
| 14 | |
| 15 function testPushHasPermissionDefault() { | |
| 16 window.testRunner.setMockPushClientError('permission_default'); | |
| 17 testPushHasPermission('default', testPushHasPermissionDenied); | |
| 18 } | |
| 19 | |
| 20 function testPushHasPermissionDenied() { | |
| 21 window.testRunner.setMockPushClientError('deny_permission'); | |
| 22 testPushHasPermission('denied', testPushHasPermissionGranted); | |
| 23 } | |
| 24 | |
| 25 function testPushHasPermissionGranted() { | |
| 26 window.testRunner.setMockPushClientSuccess('endpoint', 'registrationId'); | |
| 27 testPushHasPermission('granted'); | |
| 28 } | |
| 29 | |
| 30 function testPushHasPermission(expectedStatus, runNext) { | |
| 31 navigator.push.hasPermission().then(function(permissionStatus) { | |
| 32 status = permissionStatus; | |
| 33 shouldBeEqualToString('status', expectedStatus); | |
| 34 if (runNext) | |
| 35 runNext(); | |
| 36 else | |
| 37 finishJSTest(); | |
| 38 }, function() { | |
| 39 testFailed('Promise rejected unexpectedly.'); | |
| 40 finishJSTest(); | |
| 41 }); | |
| 42 } | |
| 43 | |
| 44 testPushHasPermissionDefault(); | |
| 45 | |
| 46 </script> | |
| 47 </body> | |
| 48 </html> | |
| OLD | NEW |