OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../http/tests/inspector/inspector-test.js"></script> |
4 <script> | 4 <script> |
5 | 5 |
6 function overrideGeolocation() | 6 function overrideGeolocation() |
7 { | 7 { |
8 function testSuccess(position) | 8 function testSuccess(position) |
9 { | 9 { |
10 if (position && position.coords) | 10 if (position && position.coords) |
11 console.log("Latitude: " + position.coords.latitude + " Longitude: "
+ position.coords.longitude); | 11 console.log("Latitude: " + position.coords.latitude + " Longitude: "
+ position.coords.longitude); |
12 else | 12 else |
13 console.log("Unexpected error occured. Test failed."); | 13 console.log("Unexpected error occured. Test failed."); |
14 } | 14 } |
15 | 15 |
16 function testFailed(error) | 16 function testFailed(error) |
17 { | 17 { |
18 console.log(error.message); | 18 console.log(error.message); |
19 } | 19 } |
20 | 20 |
21 var mockLatitude = 100; | 21 navigator.geolocation.getCurrentPosition(testSuccess, testFailed); |
22 var mockLongitude = 200; | 22 } |
23 var mockAccuracy = 94; | |
24 | 23 |
25 if (window.internals) | 24 function overridenTimestampGeolocation() |
26 internals.setGeolocationPosition(document, mockLatitude, mockLongitude,
mockAccuracy); | 25 { |
| 26 function testSuccess(position) |
| 27 { |
| 28 if ((new Date(position.timestamp)).toDateString() == (new Date()).toDate
String()) |
| 29 console.log("PASSED"); |
| 30 else |
| 31 console.log("Unexpected error occured. Test failed."); |
| 32 } |
| 33 |
| 34 function testFailed(error) |
| 35 { |
| 36 console.log(error.message); |
| 37 } |
27 | 38 |
28 navigator.geolocation.getCurrentPosition(testSuccess, testFailed); | 39 navigator.geolocation.getCurrentPosition(testSuccess, testFailed); |
29 } | 40 } |
30 | 41 |
31 function setup() | 42 function setup() |
32 { | 43 { |
| 44 var mockLatitude = 100; |
| 45 var mockLongitude = 200; |
| 46 var mockAccuracy = 94; |
| 47 |
33 if (window.internals) { | 48 if (window.internals) { |
34 internals.setGeolocationClientMock(document); | 49 internals.setGeolocationClientMock(document); |
35 internals.setGeolocationPermission(document, true); | 50 internals.setGeolocationPermission(document, true); |
| 51 internals.setGeolocationPosition(document, mockLatitude, mockLongitude,
mockAccuracy); |
36 } | 52 } |
37 } | 53 } |
38 | 54 |
39 function test() | 55 function test() |
40 { | 56 { |
41 InspectorTest.runTestSuite([ | 57 InspectorTest.runTestSuite([ |
42 function setUp(next) | 58 function setUp(next) |
43 { | 59 { |
44 InspectorTest.evaluateInPage("setup()", next); | 60 InspectorTest.evaluateInPage("setup()", next); |
45 }, | 61 }, |
(...skipping 17 matching lines...) Expand all Loading... |
63 GeolocationAgent.setGeolocationOverride(-510, 500, 100); | 79 GeolocationAgent.setGeolocationOverride(-510, 500, 100); |
64 GeolocationAgent.clearGeolocationOverride(); | 80 GeolocationAgent.clearGeolocationOverride(); |
65 InspectorTest.addConsoleSniffer(next); | 81 InspectorTest.addConsoleSniffer(next); |
66 InspectorTest.evaluateInPage("overrideGeolocation()"); | 82 InspectorTest.evaluateInPage("overrideGeolocation()"); |
67 }, | 83 }, |
68 | 84 |
69 function testInvalidParam(next) | 85 function testInvalidParam(next) |
70 { | 86 { |
71 GeolocationAgent.setGeolocationOverride(true, 500, 100); | 87 GeolocationAgent.setGeolocationOverride(true, 500, 100); |
72 next(); | 88 next(); |
| 89 }, |
| 90 |
| 91 function testTimestampOfOverridenPosition(next) |
| 92 { |
| 93 GeolocationAgent.setGeolocationOverride(-510, 500, 100); |
| 94 InspectorTest.addConsoleSniffer(next); |
| 95 InspectorTest.evaluateInPage("overridenTimestampGeolocation()"); |
73 } | 96 } |
74 ]); | 97 ]); |
75 } | 98 } |
76 </script> | 99 </script> |
77 </head> | 100 </head> |
78 <body onload="runTest()"> | 101 <body onload="runTest()"> |
79 <p> | 102 <p> |
80 Tests that geolocation emulation with latitude and longitude works as expected. | 103 Tests that geolocation emulation with latitude and longitude works as expected. |
81 </p> | 104 </p> |
82 </body> | 105 </body> |
83 </html> | 106 </html> |
OLD | NEW |