Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>getBudget succeeds from a Service Worker</title> | |
| 5 <script src="../resources/testharness.js"></script> | |
| 6 <script src="../resources/testharnessreport.js"></script> | |
| 7 <script src="../serviceworker/resources/test-helpers.js"></script> | |
| 8 <script src="../notifications/resources/test-helpers.js"></script> | |
|
harkness
2016/08/23 16:10:51
I could also copy the helpers from notifications t
| |
| 9 <script src="/js-test-resources/mojo-helpers.js"></script> | |
| 10 <script src="budget-service-mock.js"></script> | |
| 11 </head> | |
| 12 <body> | |
| 13 <script> | |
| 14 async_test(function(test) { | |
| 15 var script = 'resources/instrumentation-service-worker.js'; | |
| 16 var scope = 'resources/scope/' + location.pathname; | |
| 17 var port; | |
| 18 | |
| 19 budgetServiceMock.then(mock => { | |
| 20 getActiveServiceWorkerWithMessagePort(test, script, scope) | |
| 21 .then(function(workerInfo) { | |
| 22 port = workerInfo.port; | |
| 23 port.postMessage({command: 'getBudget'}); | |
| 24 | |
| 25 port.addEventListener('message', function(event) { | |
| 26 if (typeof event.data != 'object' || !event.data.command) | |
| 27 assert_unreached('Invalid message from the service worker'); | |
| 28 | |
| 29 assert_equals(event.data.command, 'getBudget'); | |
| 30 assert_true(event.data.success, | |
| 31 'getBudget should succeed. Error message: ' + event.data.errorMess age); | |
| 32 assert_equals(event.data.budgetAt, TEST_BUDGET_AT); | |
| 33 assert_equals(event.data.time, TEST_BUDGET_TIME); | |
| 34 test.done(); | |
| 35 }); | |
| 36 }) | |
| 37 .catch(unreached_rejection(test)); | |
| 38 }); | |
| 39 }, 'getBudget should succeed from Service Worker'); | |
| 40 </script> | |
| 41 </body> | |
| 42 </html> | |
| OLD | NEW |