blob: 6f0c8c3f0298baacc53ea35be139a9ac351da2a4 [file] [log] [blame]
[email protected]64ad8982010-06-11 08:50:221<!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]64ad8982010-06-11 08:50:229</head>
10<body>
tkent98122ee2017-02-02 07:38:5111<script>
12description("Tests that Geolocation correctly handles multiple concurrent requests.");
13
14var mockLatitude = 51.478;
15var mockLongitude = -0.166;
16var mockAccuracy = 100;
17
18var position;
19var watchCallbackInvoked = false;
20var oneShotCallbackInvoked = false;
21
Reilly Grantbe310ab2017-07-11 01:51:2622let mock = geolocationMock;
23mock.setGeolocationPermission(true);
24mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy);
tkent98122ee2017-02-02 07:38:5125
Reilly Grantbe310ab2017-07-11 01:51:2626navigator.geolocation.watchPosition(function(p) {
27 shouldBeFalse('watchCallbackInvoked');
28 watchCallbackInvoked = true;
29 maybeFinishTest(p);
30}, function() {
31 testFailed('Error callback invoked unexpectedly');
32 finishJSTest();
tkent98122ee2017-02-02 07:38:5133});
34
Reilly Grantbe310ab2017-07-11 01:51:2635navigator.geolocation.getCurrentPosition(function(p) {
36 shouldBeFalse('oneShotCallbackInvoked');
37 oneShotCallbackInvoked = true;
38 maybeFinishTest(p);
39}, function() {
40 testFailed('Error callback invoked unexpectedly');
41 finishJSTest();
42});
43
44function maybeFinishTest(p) {
45 position = p;
46 shouldBe('position.coords.latitude', 'mockLatitude');
47 shouldBe('position.coords.longitude', 'mockLongitude');
48 shouldBe('position.coords.accuracy', 'mockAccuracy');
49 if (watchCallbackInvoked && oneShotCallbackInvoked)
50 finishJSTest();
51}
52
tkent98122ee2017-02-02 07:38:5153window.jsTestIsAsync = true;
54</script>
[email protected]64ad8982010-06-11 08:50:2255</body>
56</html>