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