OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Service Worker: postMessage</title> | 2 <title>Service Worker: postMessage</title> |
3 <script src="/resources/testharness.js"></script> | 3 <script src="/resources/testharness.js"></script> |
4 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
5 <script src="resources/test-helpers.sub.js"></script> | 5 <script src="resources/test-helpers.sub.js"></script> |
6 <script> | 6 <script> |
7 async_test(function(t) { | 7 async_test(function(t) { |
8 var scope = 'resources/blank.html'; | 8 var scope = 'resources/blank.html'; |
9 var registration; | 9 var registration; |
10 var worker; | 10 var worker; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 assert_throws( | 50 assert_throws( |
51 {name:'InvalidStateError'}, | 51 {name:'InvalidStateError'}, |
52 function() { worker.postMessage(''); }, | 52 function() { worker.postMessage(''); }, |
53 'Calling postMessage on a redundant ServiceWorker should ' + | 53 'Calling postMessage on a redundant ServiceWorker should ' + |
54 'throw InvalidStateError.'); | 54 'throw InvalidStateError.'); |
55 t.done(); | 55 t.done(); |
56 }) | 56 }) |
57 .catch(unreached_rejection(t)); | 57 .catch(unreached_rejection(t)); |
58 } | 58 } |
59 }, 'postMessage to a ServiceWorker (and back via MessagePort)'); | 59 }, 'postMessage to a ServiceWorker (and back via MessagePort)'); |
60 | |
Marijn Kruisselbrink
2017/05/30 19:24:41
did you intend to have this as part of this change
mike3
2017/05/30 21:22:32
No, I did not. This was part of my research regard
| |
61 | |
62 promise_test(function(t) { | |
63 var scope = 'resources/blank.html'; | |
64 var worker; | |
65 | |
66 return service_worker_unregister_and_register( | |
67 t, 'resources/postmessage-worker.js', scope) | |
68 .then(function(registration) { | |
69 worker = registration.installing; | |
70 return new Promise(function(resolve) { | |
71 worker.addEventListener('statechange', function(event) { | |
72 if (event.target.state === 'activated') { | |
73 resolve(registration); | |
74 } | |
75 }); | |
76 }); | |
77 }) | |
78 .then(function(registration) { | |
79 return registration.unregister(); | |
80 }) | |
81 .then(function() { | |
82 assert_throws({ name: 'InvalidStateError' }, function() { | |
83 worker.postMessage({}); | |
84 }); | |
85 }); | |
86 }, 'invoked on a redundant worker'); | |
60 </script> | 87 </script> |
OLD | NEW |