Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="../serviceworker/resources/test-helpers.js"></script> | |
|
Peter Beverloo
2014/09/11 16:32:21
This feels really fragile because we don't have ex
| |
| 5 <script> | |
| 6 var test = async_test('Verify geofencing in a Service Worker'); | |
|
Peter Beverloo
2014/09/11 16:32:21
Please clarify the description a bit (verify which
| |
| 7 test.step(function() { | |
| 8 var scope = 'resources/blank.html'; | |
| 9 service_worker_unregister_and_register( | |
| 10 test, 'resources/worker.js', scope) | |
| 11 .then(function(registration) { | |
| 12 return wait_for_update(test, registration); | |
| 13 }) | |
|
Peter Beverloo
2014/09/11 16:32:21
nit: indentation in this block seems to be off. Pl
Marijn Kruisselbrink
2014/09/11 19:11:06
Since I rewrote this code entirely, this exact iss
| |
| 14 .then(onRegister) | |
| 15 .catch(unreached_rejection(test)); | |
| 16 | |
| 17 function onRegister(worker) { | |
| 18 var messageChannel = new MessageChannel(); | |
| 19 messageChannel.port1.onmessage = test.step_func(onMessage); | |
| 20 worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]) ; | |
| 21 } | |
| 22 | |
| 23 var result = []; | |
| 24 var expected = [ | |
| 25 'Rejected', | |
| 26 'Rejected', | |
| 27 'Rejected', | |
| 28 ]; | |
| 29 | |
| 30 function onMessage(e) { | |
| 31 var message = e.data; | |
| 32 if (message == 'quit') { | |
| 33 assert_array_equals(result, expected, 'Worker should post back expec ted values.'); | |
| 34 service_worker_unregister_and_done(test, scope); | |
| 35 } else { | |
| 36 result.push(message); | |
| 37 } | |
| 38 } | |
| 39 }); | |
| 40 </script> | |
| OLD | NEW |