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

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: 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>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../resources/js-test.js"></script> 4 <script src="../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 description("Tests that all geofencing methods always reject."); 8 description("Tests that all geofencing methods always reject.");
9 9
10 function shouldReject(promise) 10 var jsTestIsAsync = true;
11 { 11
12 promise.then( 12 var tests = [
13 function() { testFailed("Promise unexpectedly resolved."); }, 13 function() {
14 function() { testPassed("Promise rejected as expected."); }); 14 return navigator.geofencing.registerRegion(new CircularGeofencingRegion( {latitude: 37.421999, longitude: -122.084015}));
15 },
16 function() {
17 return navigator.geofencing.unregisterRegion("");
18 },
19 function() {
20 return navigator.geofencing.getRegisteredRegions();
21 }
22 ];
23
24 function nextTest() {
Peter Beverloo 2014/09/11 16:32:21 The nextTest() function (lines 24-43) sounds reall
Marijn Kruisselbrink 2014/09/11 19:11:06 I'm now using testharness (and in fact the exact s
25 if (tests.length == 0) {
26 finishJSTest();
27 return;
28 }
29 var test = tests.shift();
30 try {
31 test()
32 .then(function() {
33 testFailed("Promise unexpectedly resolved.");
34 nextTest();
35 }).catch(function(e) {
36 testPassed("Promise rejected as expected.");
37 nextTest();
38 });
39 } catch (e) {
40 testFailed("Unexpected exception.");
41 nextTest();
42 }
15 } 43 }
16 44 nextTest();
17 shouldReject(navigator.geofencing.registerRegion(new CircularRegion({latitude: 3 7.421999, longitude: -122.084015})));
18 shouldReject(navigator.geofencing.unregisterRegion(""));
19 shouldReject(navigator.geofencing.getRegisteredRegions());
20 </script> 45 </script>
21 </body> 46 </body>
22 </html> 47 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698