OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src='../resources/js-test.js'></script> | |
Michael van Ouwerkerk
2014/10/24 12:53:01
nit: double quotes for html attributes please
Miguel Garcia
2014/10/31 17:04:47
Done.
| |
5 </head> | |
6 <body> | |
7 <script> | |
8 description('Tests for the Push API has permission method.'); | |
Michael van Ouwerkerk
2014/10/24 12:53:01
hasPermission
Miguel Garcia
2014/10/31 17:04:47
Done.
| |
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; | |
Peter Beverloo
2014/10/24 13:03:24
nit: double space before the =
Miguel Garcia
2014/10/31 17:04:47
Done.
| |
33 shouldBeEqualToString('status', expectedStatus); | |
Peter Beverloo
2014/10/24 13:03:24
shouldBeEqualToString('status', 'expectedStatus')
Miguel Garcia
2014/10/31 17:04:47
Oh, here it still matters, see previous comment.
| |
34 if (runNext) | |
35 runNext(); | |
36 else | |
37 finishJSTest(); | |
38 }, function() { | |
39 testFailed('Error callback invoked unexpectedly.'); | |
Peter Beverloo
2014/10/24 13:03:24
s/Error callback invoked/Promise rejected/.
Miguel Garcia
2014/10/31 17:04:47
Done
| |
40 finishJSTest(); | |
41 }); | |
42 } | |
43 | |
44 testPushHasPermissionDefault(); | |
45 | |
46 </script> | |
47 </body> | |
48 </html> | |
OLD | NEW |