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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/geofencing/geofencing-not-implemented.html
diff --git a/LayoutTests/geofencing/geofencing-not-implemented.html b/LayoutTests/geofencing/geofencing-not-implemented.html
index dc44262e096235ffde2c226e0528894523ecea02..bb4f421b914d7bee2f6616653282d2cf8c7931e9 100644
--- a/LayoutTests/geofencing/geofencing-not-implemented.html
+++ b/LayoutTests/geofencing/geofencing-not-implemented.html
@@ -7,16 +7,41 @@
<script>
description("Tests that all geofencing methods always reject.");
-function shouldReject(promise)
-{
- promise.then(
- function() { testFailed("Promise unexpectedly resolved."); },
- function() { testPassed("Promise rejected as expected."); });
-}
+var jsTestIsAsync = true;
+
+var tests = [
+ function() {
+ return navigator.geofencing.registerRegion(new CircularGeofencingRegion({latitude: 37.421999, longitude: -122.084015}));
+ },
+ function() {
+ return navigator.geofencing.unregisterRegion("");
+ },
+ function() {
+ return navigator.geofencing.getRegisteredRegions();
+ }
+];
-shouldReject(navigator.geofencing.registerRegion(new CircularRegion({latitude: 37.421999, longitude: -122.084015})));
-shouldReject(navigator.geofencing.unregisterRegion(""));
-shouldReject(navigator.geofencing.getRegisteredRegions());
+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
+ if (tests.length == 0) {
+ finishJSTest();
+ return;
+ }
+ var test = tests.shift();
+ try {
+ test()
+ .then(function() {
+ testFailed("Promise unexpectedly resolved.");
+ nextTest();
+ }).catch(function(e) {
+ testPassed("Promise rejected as expected.");
+ nextTest();
+ });
+ } catch (e) {
+ testFailed("Unexpected exception.");
+ nextTest();
+ }
+}
+nextTest();
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698