forked from WebKitNix/webkitnix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeolocation-watchPosition.html
69 lines (65 loc) · 1.58 KB
/
geolocation-watchPosition.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<script src="../http/tests/inspector/inspector-test.js"></script>
<script>
var mockLatitude = 51.478;
var mockLongitude = -0.166;
var mockAccuracy = 100;
if (window.testRunner) {
testRunner.setGeolocationPermission(true);
testRunner.setMockGeolocationPosition(mockLatitude,
mockLongitude,
mockAccuracy);
} else
debug('This test can not be run without the LayoutTestController');
var watch = 0;
function getGeolocation()
{
function printLocation(pos)
{
console.log('lat: ' + pos.coords.latitude + ', long: ' + pos.coords.longitude);
}
function printError(err)
{
console.log('Error: ' + err.code);
}
watch = navigator.geolocation.watchPosition(printLocation, printError, [])
}
function clearWatch()
{
navigator.geolocation.clearWatch(watch);
}
function test()
{
function callbackComplete()
{
InspectorTest.completeTest();
}
function callback()
{
InspectorTest.evaluateInPage("clearWatch()", callbackComplete);
}
function clearData()
{
PageAgent.clearGeolocationOverride();
setTimeout(callback, 1);
}
function setError()
{
PageAgent.setGeolocationOverride();
setTimeout(clearData, 1);
}
function setPosition()
{
PageAgent.setGeolocationOverride(43.476093, -80.540299, 150);
setTimeout(setError, 1);
}
InspectorTest.evaluateInPage("getGeolocation()", setPosition);
}
</script>
</head>
<body onload="runTest()">
<p>
</p>
</body>
</html>