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

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: address comments 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
« no previous file with comments | « no previous file | LayoutTests/geofencing/geofencing-not-implemented-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/geofencing/geofencing-not-implemented.html
diff --git a/LayoutTests/geofencing/geofencing-not-implemented.html b/LayoutTests/geofencing/geofencing-not-implemented.html
index ddfb6f21c5c4d6449eb006d3ae315dc734e171af..bc82d37b69edd31710ce52edf5eaa3c357e07620 100644
--- a/LayoutTests/geofencing/geofencing-not-implemented.html
+++ b/LayoutTests/geofencing/geofencing-not-implemented.html
@@ -1,22 +1,38 @@
<!DOCTYPE html>
-<html>
-<head>
-<script src="../resources/js-test.js"></script>
-</head>
-<body>
+<title>Tests that all geofencing methods always reject.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
<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."); });
+// Copied from http/tests/serviceworker/resources/worker-test-harness.js, can be
+// removed once this makes it into testharness.js itself.
+function promise_test(func, name, properties) {
+ properties = properties || {};
+ var test = async_test(name, properties);
+ Promise.resolve(test.step(func, test, test))
+ .then(function() { test.done(); })
+ .catch(test.step_func(function(value) {
+ throw value;
+ }));
}
-shouldReject(navigator.geofencing.registerRegion(new CircularGeofencingRegion({latitude: 37.421999, longitude: -122.084015})));
-shouldReject(navigator.geofencing.unregisterRegion(""));
-shouldReject(navigator.geofencing.getRegisteredRegions());
+promise_test(function(test) {
+ return navigator.geofencing.registerRegion(
+ new CircularGeofencingRegion({latitude: 37.421999,
+ longitude: -122.084015}))
+ .then(test.unreached_func('Promise should not have resolved'))
+ .catch(function() { });
+ }, 'registerRegion should fail');
+
+promise_test(function(test) {
+ return navigator.geofencing.unregisterRegion("")
+ .then(test.unreached_func('Promise should not have resolved'))
+ .catch(function() { });
+ }, 'unregisterRegion should fail');
+
+promise_test(function(test) {
+ return navigator.geofencing.getRegisteredRegions()
+ .then(test.unreached_func('Promise should not have resolved'))
+ .catch(function() { });
+ }, 'getRegisteredRegions should fail');
+
</script>
-</body>
-</html>
« no previous file with comments | « no previous file | LayoutTests/geofencing/geofencing-not-implemented-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698