| <!DOCTYPE html> |
| <title>ServiceWorkerGlobalScope: ExtendableMessageEvent</title> |
| <script src='../../resources/testharness.js'></script> |
| <script src='../../resources/testharnessreport.js'></script> |
| <script src='../resources/test-helpers.js'></script> |
| <script> |
| |
| // This test should be in chromium/ because the spec does not define behavior in |
| // the case where postMessage() is called from a detached client. |
| promise_test(function(t) { |
| var script = 'resources/empty-worker.js'; |
| var scope = 'resources/scope/extendable-message-event-from-detached'; |
| |
| return service_worker_unregister_and_register(t, script, scope) |
| .then(function(registration) { |
| add_completion_callback(function() { registration.unregister(); }); |
| return wait_for_state(t, registration.installing, 'activated'); |
| }) |
| .then(function() { return with_iframe(scope); }) |
| .then(function(frame) { |
| var worker = frame.contentWindow.navigator.serviceWorker.controller; |
| frame.remove(); |
| assert_throws( |
| { name: 'InvalidStateError' }, |
| function() { worker.postMessage(''); }, |
| 'postMessage on a detached client should throw an exception.'); |
| }); |
| }, 'Post an extendable message from a detached client'); |
| |
| </script> |