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
portedError if userVisibleOnly is not used</title> |
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, |
28 assert_unreached('Invalid message from the service worker'); | 24 'Chrome does not support push subscriptions that do not enable t
he userVisibleOnly option.'); |
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(); | 25 test.done(); |
36 }); | 26 }); |
| 27 |
37 }).catch(unreached_rejection(test)); | 28 }).catch(unreached_rejection(test)); |
38 }, 'permissionState when called in service worker resolves with prompt when no p
ermission is set'); | 29 }, 'Push API: permissionState when called in service worker fails with NotSuppor
tedError if userVisibleOnly is not used'); |
39 </script> | 30 </script> |
40 </body> | 31 </body> |
41 </html> | 32 </html> |
OLD | NEW |