|
| 1 | +<!DOCTYPE html> |
| 2 | +<meta charset="utf-8"/> |
| 3 | +<script src="/resources/testharness.js"></script> |
| 4 | +<script src="/resources/testharnessreport.js"></script> |
| 5 | +<script src="/resources/testdriver.js?feature=bidi"></script> |
| 6 | +<script src="/resources/testdriver-vendor.js"></script> |
| 7 | + |
| 8 | +<script> |
| 9 | + promise_setup(async () => { |
| 10 | + // Ensure permission is granted before proceeding. |
| 11 | + await test_driver.bidi.permissions.set_permission({ |
| 12 | + descriptor: {name: "geolocation"}, |
| 13 | + state: "granted", |
| 14 | + }); |
| 15 | + }); |
| 16 | + |
| 17 | + promise_test(async (t) => { |
| 18 | + t.add_cleanup(async () => { |
| 19 | + await test_driver.bidi.emulation.set_geolocation_override( |
| 20 | + {coordinates: null}); |
| 21 | + }); |
| 22 | + |
| 23 | + await test_driver.bidi.emulation.set_geolocation_override({ |
| 24 | + error: {type: "positionUnavailable"} |
| 25 | + }); |
| 26 | + |
| 27 | + const error = await new Promise( |
| 28 | + (resolve, reject) => |
| 29 | + window.navigator.geolocation.getCurrentPosition( |
| 30 | + () => reject("Unexpected success callback"), |
| 31 | + error => resolve({ |
| 32 | + code: error.code, |
| 33 | + message: error.message, |
| 34 | + PERMISSION_DENIED: error.PERMISSION_DENIED, |
| 35 | + POSITION_UNAVAILABLE: error.POSITION_UNAVAILABLE, |
| 36 | + TIMEOUT: error.TIMEOUT |
| 37 | + }), |
| 38 | + {timeout: 1000} |
| 39 | + )); |
| 40 | + |
| 41 | + assert_equals(error.code, 2); |
| 42 | + // The message value is not specified. |
| 43 | + assert_not_equals(error.message, undefined); |
| 44 | + assert_equals(error.PERMISSION_DENIED, 1); |
| 45 | + assert_equals(error.POSITION_UNAVAILABLE, 2); |
| 46 | + assert_equals(error.TIMEOUT, 3); |
| 47 | + }, "Tests Geolocation error callback"); |
| 48 | +</script> |
0 commit comments