OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Service Worker: postMessage Blob URL</title> |
| 3 <script src="/resources/testharness.js"></script> |
| 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <script src="resources/test-helpers.sub.js"></script> |
| 6 <script> |
| 7 promise_test(t => { |
| 8 let script = 'resources/postmessage-blob-url.js'; |
| 9 let scope = 'resources/blank.html'; |
| 10 let registration; |
| 11 let blobText = 'Blob text'; |
| 12 let blob; |
| 13 let blobUrl; |
| 14 |
| 15 return service_worker_unregister_and_register(t, script, scope) |
| 16 .then(r => { |
| 17 add_completion_callback(() => r.unregister()); |
| 18 registration = r; |
| 19 let worker = registration.installing; |
| 20 blob = new Blob([blobText]); |
| 21 blobUrl = URL.createObjectURL(blob); |
| 22 return new Promise(resolve => { |
| 23 navigator.serviceWorker.onmessage = e => { resolve(e.data); } |
| 24 worker.postMessage(blobUrl); |
| 25 }); |
| 26 }) |
| 27 .then(response => { |
| 28 assert_equals(response, 'Worker reply:' + blobText); |
| 29 URL.revokeObjectURL(blobUrl); |
| 30 return registration.unregister(); |
| 31 }); |
| 32 }, 'postMessage Blob URL to a ServiceWorker'); |
| 33 </script> |
OLD | NEW |