| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <title>Service Worker: registration events</title> | |
| 3 <script src="../resources/testharness.js"></script> | |
| 4 <script src="../resources/testharnessreport.js"></script> | |
| 5 <script src="resources/test-helpers.js"></script> | |
| 6 <script> | |
| 7 var t = async_test('Registration: events'); | |
| 8 t.step(function() { | |
| 9 var scope = 'resources/in-scope/'; | |
| 10 service_worker_unregister_and_register( | |
| 11 t, 'resources/events-worker.js', scope) | |
| 12 .then(t.step_func(function(registration) { | |
| 13 onRegister(registration.installing); | |
| 14 })) | |
| 15 .catch(unreached_rejection(t)); | |
| 16 | |
| 17 function sendMessagePort(worker, from) { | |
| 18 var messageChannel = new MessageChannel(); | |
| 19 worker.postMessage({from:from, port:messageChannel.port2}, [messageChann
el.port2]); | |
| 20 return messageChannel.port1; | |
| 21 } | |
| 22 | |
| 23 function onRegister(sw) { | |
| 24 sw.onstatechange = t.step_func(function() { | |
| 25 if (sw.state !== 'activated') | |
| 26 return; | |
| 27 | |
| 28 sendMessagePort(sw, 'registering doc').onmessage = t.step_func(funct
ion (e) { | |
| 29 assert_array_equals(e.data.events, | |
| 30 ['install', 'activate'], | |
| 31 'Worker should see install then activate even
ts'); | |
| 32 service_worker_unregister_and_done(t, scope); | |
| 33 }); | |
| 34 }); | |
| 35 } | |
| 36 }); | |
| 37 </script> | |
| OLD | NEW |