OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title> | 4 <title>Push API: permissionState when called in service worker fails with NotSup ported if userVisible is not used</title> |
Peter Beverloo
2015/05/07 15:28:21
dito re: NotSupported(Error) and userVisible(Only)
Miguel Garcia
2015/05/07 19:40:46
Done.
| |
5 Push API: permissionState when called in service worker resolves with prompt when no permission is set | |
6 </title> | |
7 <link rel="manifest" href="resources/push_manifest.json"> | 5 <link rel="manifest" href="resources/push_manifest.json"> |
8 <script src="../resources/testharness.js"></script> | 6 <script src="../resources/testharness.js"></script> |
9 <script src="../resources/testharnessreport.js"></script> | 7 <script src="../resources/testharnessreport.js"></script> |
10 <script src="../serviceworker/resources/test-helpers.js"></script> | 8 <script src="../serviceworker/resources/test-helpers.js"></script> |
11 <script src="../notifications/resources/test-helpers.js"></script> | 9 <script src="../notifications/resources/test-helpers.js"></script> |
12 </head> | 10 </head> |
13 <body> | 11 <body> |
14 <script> | 12 <script> |
15 // This test uses the test runner. If running manually, clear permissions before running this test. | |
16 async_test(function(test) { | 13 async_test(function(test) { |
17 if (window.testRunner) | 14 if (window.testRunner) |
18 testRunner.setPermission('push-messaging', 'prompt', location.origin, lo cation.origin); | 15 testRunner.setPermission('push-messaging', 'prompt', location.origin, lo cation.origin); |
19 | 16 |
20 var script = 'resources/instrumentation-service-worker.js'; | 17 var script = 'resources/instrumentation-service-worker.js'; |
21 var scope = 'resources/scope/' + location.pathname; | 18 var scope = 'resources/scope/' + location.pathname; |
22 | 19 |
23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(wor kerInfo) { | 20 getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(wor kerInfo) { |
24 workerInfo.port.postMessage({command: 'permissionState'}); | 21 workerInfo.port.postMessage({command: 'permissionState'}); |
25 | |
26 workerInfo.port.addEventListener('message', function(event) { | 22 workerInfo.port.addEventListener('message', function(event) { |
27 if (typeof event.data != 'object' || !event.data.command) | 23 assert_equals(event.data.errorMessage, "non-visible push messages ar e not supported."); |
28 assert_unreached('Invalid message from the service worker'); | |
29 | |
30 assert_equals(event.data.command, 'permissionState'); | |
31 assert_true(event.data.success, | |
32 'permissionState should succeed. Error message: ' + even t.data.errorMessage); | |
33 assert_equals(event.data.permission, 'prompt'); | |
34 | |
35 test.done(); | 24 test.done(); |
36 }); | 25 }); |
26 | |
37 }).catch(unreached_rejection(test)); | 27 }).catch(unreached_rejection(test)); |
38 }, 'permissionState when called in service worker resolves with prompt when no p ermission is set'); | 28 }, 'Push API: permissionState when called in service worker fails with NotSuppor ted if userVisible is not used'); |
39 </script> | 29 </script> |
40 </body> | 30 </body> |
41 </html> | 31 </html> |
OLD | NEW |