| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title> | |
| 5 hasPermission when called in service worker resolves with default when no perm
ission is set | |
| 6 </title> | |
| 7 <link rel="manifest" href="resources/push_manifest.json"> | |
| 8 <script src="../resources/testharness.js"></script> | |
| 9 <script src="../resources/testharnessreport.js"></script> | |
| 10 <script src="../serviceworker/resources/test-helpers.js"></script> | |
| 11 <script src="../notifications/resources/test-helpers.js"></script> | |
| 12 </head> | |
| 13 <body> | |
| 14 <script> | |
| 15 // This test uses the test runner. If running manually, clear permissions before
running this test. | |
| 16 async_test(function(test) { | |
| 17 if (window.testRunner) | |
| 18 testRunner.setPermission('push-messaging', 'prompt', location.origin, lo
cation.origin); | |
| 19 | |
| 20 var script = 'resources/instrumentation-service-worker.js'; | |
| 21 var scope = 'resources/scope/' + location.pathname; | |
| 22 | |
| 23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(wor
kerInfo) { | |
| 24 workerInfo.port.postMessage({command: 'hasPermission'}); | |
| 25 | |
| 26 workerInfo.port.addEventListener('message', function(event) { | |
| 27 if (typeof event.data != 'object' || !event.data.command) | |
| 28 assert_unreached('Invalid message from the service worker'); | |
| 29 | |
| 30 assert_equals(event.data.command, 'hasPermission'); | |
| 31 assert_true(event.data.success, | |
| 32 'hasPermission should succeed. Error message: ' + event.
data.errorMessage); | |
| 33 assert_equals(event.data.permission, 'default'); | |
| 34 | |
| 35 test.done(); | |
| 36 }); | |
| 37 }).catch(unreached_rejection(test)); | |
| 38 }, 'hasPermission when called in service worker resolves with default when no pe
rmission is set'); | |
| 39 </script> | |
| 40 </body> | |
| 41 </html> | |
| OLD | NEW |