Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: LayoutTests/geofencing/geofencing-not-implemented.html

Issue 543203003: Fix the geofencing test to not break if the promises resolve asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: cleaner code Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698