OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Tests that all geofencing methods exposed on a service worker registratio
n always reject.</title> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="../serviceworker/resources/test-helpers.js"></script> |
| 6 <script> |
| 7 // Copied from http/tests/serviceworker/resources/worker-test-harness.js, can be |
| 8 // removed once this makes it into testharness.js itself. |
| 9 function promise_test(func, name, properties) { |
| 10 properties = properties || {}; |
| 11 var test = async_test(name, properties); |
| 12 Promise.resolve(test.step(func, test, test)) |
| 13 .then(function() { test.done(); }) |
| 14 .catch(test.step_func(function(value) { |
| 15 throw value; |
| 16 })); |
| 17 } |
| 18 function assert_promise_rejects(promise, code, description) { |
| 19 return promise.then( |
| 20 function() { |
| 21 throw 'assert_promise_rejects: ' + description + ' Promise did not throw.'
; |
| 22 }, |
| 23 function(e) { |
| 24 if (code !== undefined) { |
| 25 assert_throws(code, function() { throw e; }, description); |
| 26 } |
| 27 }); |
| 28 } |
| 29 |
| 30 var sw_url = 'resources/emptyworker.js'; |
| 31 var sw_scope = '/service-worker-scope' + window.location.pathname; |
| 32 |
| 33 promise_test(function(test) { |
| 34 return assert_promise_rejects( |
| 35 service_worker_unregister_and_register(test, sw_url, sw_scope + '/register
') |
| 36 .then(function(r) { |
| 37 return r.geofencing.registerRegion( |
| 38 new CircularGeofencingRegion({latitude: 37.421999, |
| 39 longitude: -122.084015})); |
| 40 }), |
| 41 'AbortError', |
| 42 'registerRegion should fail with an AbortError'); |
| 43 }, 'registerRegion should fail'); |
| 44 |
| 45 promise_test(function(test) { |
| 46 return assert_promise_rejects( |
| 47 service_worker_unregister_and_register(test, sw_url, sw_scope + '/unregist
er') |
| 48 .then(function(r) { |
| 49 return r.geofencing.unregisterRegion(''); |
| 50 }), |
| 51 'AbortError', |
| 52 'unregisterRegion should fail with an AbortError'); |
| 53 }, 'unregisterRegion should fail'); |
| 54 |
| 55 promise_test(function(test) { |
| 56 return assert_promise_rejects( |
| 57 service_worker_unregister_and_register(test, sw_url, sw_scope + '/getregio
ns') |
| 58 .then(function(r) { |
| 59 return r.geofencing.getRegisteredRegions(); |
| 60 }), |
| 61 'AbortError', |
| 62 'getRegisteredRegions should fail with an AbortError'); |
| 63 }, 'getRegisteredRegions should fail'); |
| 64 |
| 65 </script> |
OLD | NEW |