OLD | NEW |
---|---|
(Empty) | |
1 <html> | |
2 <head> | |
3 <script src="../http/tests/inspector/inspector-test.js"></script> | |
4 <script> | |
5 | |
6 function overrideGeolocation() | |
7 { | |
8 function testSuccess(position) | |
9 { | |
10 if (position && position.coords) | |
11 console.log("Latitude: " + position.coords.latitude + " Longitude: " + position.coords.longitude); | |
12 else | |
13 console.log("Unexpected error occured. Test failed."); | |
14 } | |
15 | |
16 function testFailed(error) | |
17 { | |
18 console.log(error.message); | |
19 } | |
20 | |
21 var mockLatitude = 100; | |
22 var mockLongitude = 200; | |
23 var mockAccuracy = 94; | |
24 | |
25 if (window.internals) | |
26 internals.setGeolocationPosition(document, mockLatitude, mockLongitude, mockAccuracy); | |
27 | |
28 navigator.geolocation.getCurrentPosition(testSuccess, testFailed); | |
29 } | |
30 | |
31 function setup() | |
32 { | |
33 if (window.internals) { | |
34 internals.setGeolocationClientMock(document); | |
35 internals.setGeolocationPermission(document, true); | |
36 } | |
37 } | |
38 | |
39 function test() | |
40 { | |
41 InspectorTest.runTestSuite([ | |
42 function setUp(next) | |
43 { | |
44 InspectorTest.addConsoleSniffer(next); | |
45 InspectorTest.evaluateInPage("setup()", next); | |
46 }, | |
47 | |
48 function testGeolocationUnavailable(next) | |
49 { | |
50 GeolocationAgent.setGeolocationOverride(); | |
51 InspectorTest.evaluateInPage("overrideGeolocation()", next); | |
52 }, | |
53 | |
54 function testOverridenGeolocation(next) | |
55 { | |
56 GeolocationAgent.setGeolocationOverride(-510, 500, 100); | |
57 InspectorTest.evaluateInPage("overrideGeolocation()", next); | |
58 }, | |
59 | |
60 function testClearOverridenGeolocation(next) | |
61 { | |
62 GeolocationAgent.setGeolocationOverride(-510, 500, 100); | |
63 GeolocationAgent.clearGeolocationOverride(); | |
64 InspectorTest.evaluateInPage("overrideGeolocation()", next); | |
65 }, | |
66 | |
67 function testInvalidParam(next) | |
68 { | |
69 GeolocationAgent.setGeolocationOverride(true, 500, 100); | |
pfeldman
2014/02/21 08:59:05
You are not calling next in the end of this sectio
| |
70 } | |
71 ]); | |
72 } | |
73 </script> | |
74 </head> | |
75 <body onload="runTest()"> | |
76 <p> | |
77 Tests that geolocation emulation with latitude and longitude works as expected. | |
78 </p> | |
79 </body> | |
80 </html> | |
OLD | NEW |