OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests that all geofencing methods always reject.</title> |
3 <head> | 3 <script src="../resources/testharness.js"></script> |
4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
5 </head> | |
6 <body> | |
7 <script> | 5 <script> |
8 description("Tests that all geofencing methods always reject."); | 6 // Copied from http/tests/serviceworker/resources/worker-test-harness.js, can be |
9 | 7 // removed once this makes it into testharness.js itself. |
10 function shouldReject(promise) | 8 function promise_test(func, name, properties) { |
11 { | 9 properties = properties || {}; |
12 promise.then( | 10 var test = async_test(name, properties); |
13 function() { testFailed("Promise unexpectedly resolved."); }, | 11 Promise.resolve(test.step(func, test, test)) |
14 function() { testPassed("Promise rejected as expected."); }); | 12 .then(function() { test.done(); }) |
| 13 .catch(test.step_func(function(value) { |
| 14 throw value; |
| 15 })); |
15 } | 16 } |
16 | 17 |
17 shouldReject(navigator.geofencing.registerRegion(new CircularGeofencingRegion({l
atitude: 37.421999, longitude: -122.084015}))); | 18 promise_test(function(test) { |
18 shouldReject(navigator.geofencing.unregisterRegion("")); | 19 return navigator.geofencing.registerRegion( |
19 shouldReject(navigator.geofencing.getRegisteredRegions()); | 20 new CircularGeofencingRegion({latitude: 37.421999, |
| 21 longitude: -122.084015})) |
| 22 .then(test.unreached_func('Promise should not have resolved')) |
| 23 .catch(function() { }); |
| 24 }, 'registerRegion should fail'); |
| 25 |
| 26 promise_test(function(test) { |
| 27 return navigator.geofencing.unregisterRegion("") |
| 28 .then(test.unreached_func('Promise should not have resolved')) |
| 29 .catch(function() { }); |
| 30 }, 'unregisterRegion should fail'); |
| 31 |
| 32 promise_test(function(test) { |
| 33 return navigator.geofencing.getRegisteredRegions() |
| 34 .then(test.unreached_func('Promise should not have resolved')) |
| 35 .catch(function() { }); |
| 36 }, 'getRegisteredRegions should fail'); |
| 37 |
20 </script> | 38 </script> |
21 </body> | |
22 </html> | |
OLD | NEW |