blob: 3cbc2e0d318c6039e7d02ebf89dff65c2cfcaa11 [file] [log] [blame]
[email protected]df7846b2009-09-09 16:27:321<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html>
3<head>
tkentc5e88f02017-02-06 22:47:314<script src="../resources/js-test.js"></script>
Reilly Grantbe310ab2017-07-11 01:51:265<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
6<script src="file:///gen/device/geolocation/public/interfaces/geolocation.mojom.js"></script>
7<script src="file:///gen/third_party/WebKit/public/platform/modules/permissions/permission.mojom.js"></script>
sammce6687802016-05-13 04:06:578<script src="resources/geolocation-mock.js"></script>
[email protected]df7846b2009-09-09 16:27:329</head>
10<body>
tkent98122ee2017-02-02 07:38:5111<script>
12description("Tests that when an exception is thrown in the success callback, the error callback is not invoked. Note that this test throws an exception which is not caught.");
13
14var mockLatitude = 51.478;
15var mockLongitude = -0.166;
16var mockAccuracy = 100;
17
18var position;
19
Reilly Grantbe310ab2017-07-11 01:51:2620let mock = geolocationMock;
21mock.setGeolocationPermission(true);
22mock.setGeolocationPosition(mockLatitude,
23 mockLongitude,
24 mockAccuracy);
25navigator.geolocation.getCurrentPosition(function(p) {
26 position = p;
27 shouldBe('position.coords.latitude', 'mockLatitude');
28 shouldBe('position.coords.longitude', 'mockLongitude');
29 shouldBe('position.coords.accuracy', 'mockAccuracy');
tkent98122ee2017-02-02 07:38:5130
Reilly Grantbe310ab2017-07-11 01:51:2631 // Yield to allow for the error callback to be invoked. The timer
32 // must be started before the exception is thrown.
33 window.setTimeout(assertWeGotException, 0);
34 expectError();
tkent98122ee2017-02-02 07:38:5135
Reilly Grantbe310ab2017-07-11 01:51:2636 throw new Error('Exception in success callback');
37}, function(e) {
38 testFailed('Error callback invoked unexpectedly');
39 finishJSTest();
tkent98122ee2017-02-02 07:38:5140});
41
42function assertWeGotException()
43{
44 shouldHaveHadError();
45 finishJSTest();
46}
47
48window.jsTestIsAsync = true;
49</script>
[email protected]df7846b2009-09-09 16:27:3250</body>
51</html>