| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Tests that all geofencing methods exposed on a service worker registratio
n always reject.</title> | 2 <title>Tests that all geofencing methods exposed on a service worker registratio
n always reject.</title> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="../resources/testharness-helpers.js"></script> |
| 5 <script src="../serviceworker/resources/test-helpers.js"></script> | 6 <script src="../serviceworker/resources/test-helpers.js"></script> |
| 6 <script> | 7 <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'; | 8 var sw_url = 'resources/emptyworker.js'; |
| 31 var sw_scope = '/service-worker-scope' + window.location.pathname; | 9 var sw_scope = '/service-worker-scope' + window.location.pathname; |
| 32 | 10 |
| 33 promise_test(function(test) { | 11 promise_test(function(test) { |
| 34 return assert_promise_rejects( | 12 return assert_promise_rejects( |
| 35 service_worker_unregister_and_register(test, sw_url, sw_scope + '/register
') | 13 service_worker_unregister_and_register(test, sw_url, sw_scope + '/register
') |
| 36 .then(function(r) { | 14 .then(function(r) { |
| 37 return r.geofencing.registerRegion( | 15 return r.geofencing.registerRegion( |
| 38 new CircularGeofencingRegion({latitude: 37.421999, | 16 new CircularGeofencingRegion({latitude: 37.421999, |
| 39 longitude: -122.084015})); | 17 longitude: -122.084015})); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 return assert_promise_rejects( | 34 return assert_promise_rejects( |
| 57 service_worker_unregister_and_register(test, sw_url, sw_scope + '/getregio
ns') | 35 service_worker_unregister_and_register(test, sw_url, sw_scope + '/getregio
ns') |
| 58 .then(function(r) { | 36 .then(function(r) { |
| 59 return r.geofencing.getRegisteredRegions(); | 37 return r.geofencing.getRegisteredRegions(); |
| 60 }), | 38 }), |
| 61 'AbortError', | 39 'AbortError', |
| 62 'getRegisteredRegions should fail with an AbortError'); | 40 'getRegisteredRegions should fail with an AbortError'); |
| 63 }, 'getRegisteredRegions should fail'); | 41 }, 'getRegisteredRegions should fail'); |
| 64 | 42 |
| 65 </script> | 43 </script> |
| OLD | NEW |