| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>subscribe fails in service worker because the manifest cannot be read</ti
tle> | 4 <title>subscribe fails in service worker because the manifest cannot be read</ti
tle> |
| 5 <link rel="manifest" href="resources/push_manifest.json"> | 5 <link rel="manifest" href="resources/push_manifest.json"> |
| 6 <script src="../resources/testharness.js"></script> | 6 <script src="../resources/testharness.js"></script> |
| 7 <script src="../resources/testharnessreport.js"></script> | 7 <script src="../resources/testharnessreport.js"></script> |
| 8 <script src="../serviceworker/resources/test-helpers.js"></script> | 8 <script src="../serviceworker/resources/test-helpers.js"></script> |
| 9 <script src="../notifications/resources/test-helpers.js"></script> | 9 <script src="../notifications/resources/test-helpers.js"></script> |
| 10 </head> | 10 </head> |
| 11 <body> | 11 <body> |
| 12 <script> | 12 <script> |
| 13 // This test uses the test runner. If running manually, grant permission when pr
ompted. | 13 // This test uses the test runner. If running manually, grant permission when pr
ompted. |
| 14 async_test(function(test) { | 14 async_test(function(test) { |
| 15 if (window.testRunner) | 15 if (window.testRunner) |
| 16 testRunner.setPermission('push-messaging', 'granted', location.origin, l
ocation.origin); | 16 testRunner.setPermission('push-messaging', 'granted', location.origin, l
ocation.origin); |
| 17 | 17 |
| 18 var script = 'resources/instrumentation-service-worker.js'; | 18 var script = 'resources/instrumentation-service-worker.js'; |
| 19 var scope = 'resources/scope/' + location.pathname; | 19 var scope = 'resources/scope/' + location.pathname; |
| 20 | 20 |
| 21 getActiveServiceWorkerWithMessagePort(test, script, scope) | 21 getActiveServiceWorkerWithMessagePort(test, script, scope) |
| 22 .then(function(workerInfo) { | 22 .then(function(workerInfo) { |
| 23 // Call subscribe in service worker context. It will fail because al
though the sender | 23 // Call subscribe in service worker context. It will fail because |
| 24 // id has been specified in the manifest, the manifest cannot be rea
d in a service | 24 // although the sender id has been specified in the manifest, the |
| 25 // worker context, and no previous subscription will exist from a do
cument context. | 25 // manifest cannot be read in a service worker context, and no |
| 26 // previous subscription will exist from a document context. |
| 26 workerInfo.port.postMessage({command: 'subscribe'}); | 27 workerInfo.port.postMessage({command: 'subscribe'}); |
| 27 | 28 |
| 28 workerInfo.port.addEventListener('message', function(event) { | 29 workerInfo.port.addEventListener('message', function(event) { |
| 29 if (typeof event.data != 'object' || !event.data.command) | 30 if (typeof event.data != 'object' || !event.data.command) |
| 30 assert_unreached('Invalid message from the service worker'); | 31 assert_unreached('Invalid message from the service worker'); |
| 31 | 32 |
| 32 assert_equals(event.data.command, 'subscribe'); | 33 assert_equals(event.data.command, 'subscribe'); |
| 33 assert_false(event.data.success, 'subscribe is not expected to s
ucceed.'); | 34 assert_false(event.data.success, 'subscribe is not expected to s
ucceed.'); |
| 34 assert_regexp_match( | 35 assert_regexp_match( |
| 35 event.data.errorMessage, | 36 event.data.errorMessage, |
| 36 /missing applicationServerKey, and gcm_sender_id not found i
n manifest/); | 37 /missing applicationServerKey, and gcm_sender_id not found i
n manifest/); |
| 37 | 38 |
| 38 test.done(); | 39 test.done(); |
| 39 }); | 40 }); |
| 40 }) | 41 }) |
| 41 .catch(unreached_rejection(test)); | 42 .catch(unreached_rejection(test)); |
| 42 }, 'subscribe fails in service worker because the manifest cannot be read'); | 43 }, 'subscribe fails in service worker because the manifest cannot be read'); |
| 43 </script> | 44 </script> |
| 44 </body> | 45 </body> |
| 45 </html> | 46 </html> |
| OLD | NEW |