Index: LayoutTests/http/tests/geofencing/service-worker.html |
diff --git a/LayoutTests/http/tests/geofencing/service-worker.html b/LayoutTests/http/tests/geofencing/service-worker.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..faede801ade47c82dfed0a4497b936f590862a08 |
--- /dev/null |
+++ b/LayoutTests/http/tests/geofencing/service-worker.html |
@@ -0,0 +1,40 @@ |
+<!DOCTYPE html> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<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
|
+<script> |
+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
|
+test.step(function() { |
+ var scope = 'resources/blank.html'; |
+ service_worker_unregister_and_register( |
+ test, 'resources/worker.js', scope) |
+ .then(function(registration) { |
+ return wait_for_update(test, registration); |
+ }) |
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
|
+ .then(onRegister) |
+ .catch(unreached_rejection(test)); |
+ |
+ function onRegister(worker) { |
+ var messageChannel = new MessageChannel(); |
+ messageChannel.port1.onmessage = test.step_func(onMessage); |
+ worker.postMessage({port: messageChannel.port2}, [messageChannel.port2]); |
+ } |
+ |
+ var result = []; |
+ var expected = [ |
+ 'Rejected', |
+ 'Rejected', |
+ 'Rejected', |
+ ]; |
+ |
+ function onMessage(e) { |
+ var message = e.data; |
+ if (message == 'quit') { |
+ assert_array_equals(result, expected, 'Worker should post back expected values.'); |
+ service_worker_unregister_and_done(test, scope); |
+ } else { |
+ result.push(message); |
+ } |
+ } |
+}); |
+</script> |