2 <script src=
"../resources/testharness.js"></script>
3 <script src=
"../resources/testharness-helpers.js"></script>
4 <script src=
"../resources/testharnessreport.js"></script>
5 <script src=
"resources/test-helpers.js"></script>
7 promise_test(function(t
) {
8 var script
= 'resources/fetch-event-async-respond-with-worker.js';
9 var scope
= 'resources/simple.html';
11 return service_worker_unregister_and_register(t
, script
, scope
)
12 .then(function(registration
) {
13 return wait_for_state(t
, registration
.installing
, 'activated');
16 return with_iframe(scope
);
18 .then(function(frame
) {
19 var channel
= new MessageChannel();
20 var saw_message
= new Promise(function(resolve
) {
21 channel
.port1
.onmessage = function(e
) { resolve(e
.data
); }
23 var worker
= frame
.contentWindow
.navigator
.serviceWorker
.controller
;
26 worker
.postMessage({port
: channel
.port2
}, [channel
.port2
]);
29 .then(function(message
) {
30 assert_equals(message
, 'PASS');
31 return service_worker_unregister_and_done(t
, scope
);
33 }, 'Calling respondWith asynchronously throws an exception');