Index: LayoutTests/inspector/geolocation-emulation-tests.html |
diff --git a/LayoutTests/inspector/geolocation-emulation-tests.html b/LayoutTests/inspector/geolocation-emulation-tests.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3efa4c5a115c0cdf417a96ce8cb240cb9335b764 |
--- /dev/null |
+++ b/LayoutTests/inspector/geolocation-emulation-tests.html |
@@ -0,0 +1,83 @@ |
+<html> |
+<head> |
+<script src="../http/tests/inspector/inspector-test.js"></script> |
+<script> |
+ |
+function overrideGeolocation() |
+{ |
+ function testSuccess(position) |
+ { |
+ if (position && position.coords) |
+ console.log("Latitude: " + position.coords.latitude + " Longitude: " + position.coords.longitude); |
+ else |
+ console.log("Unexpected error occured. Test failed."); |
+ } |
+ |
+ function testFailed(error) |
+ { |
+ console.log(error.message); |
+ } |
+ |
+ var mockLatitude = 100; |
+ var mockLongitude = 200; |
+ var mockAccuracy = 94; |
+ |
+ if (window.internals) |
+ internals.setGeolocationPosition(document, mockLatitude, mockLongitude, mockAccuracy); |
+ |
+ navigator.geolocation.getCurrentPosition(testSuccess, testFailed); |
+} |
+ |
+function setup() |
+{ |
+ if (window.internals) { |
+ internals.setGeolocationClientMock(document); |
+ internals.setGeolocationPermission(document, true); |
+ } |
+} |
+ |
+function test() |
+{ |
+ InspectorTest.runTestSuite([ |
+ function setUp(next) |
+ { |
+ InspectorTest.evaluateInPage("setup()", next); |
+ }, |
+ |
+ function testGeolocationUnavailable(next) |
+ { |
+ GeolocationAgent.setGeolocationOverride(); |
+ InspectorTest.addConsoleSniffer(next); |
+ InspectorTest.evaluateInPage("overrideGeolocation()"); |
+ }, |
+ |
+ function testOverridenGeolocation(next) |
+ { |
+ GeolocationAgent.setGeolocationOverride(-510, 500, 100); |
+ InspectorTest.addConsoleSniffer(next); |
+ InspectorTest.evaluateInPage("overrideGeolocation()"); |
+ }, |
+ |
+ function testClearOverridenGeolocation(next) |
+ { |
+ GeolocationAgent.setGeolocationOverride(-510, 500, 100); |
+ GeolocationAgent.clearGeolocationOverride(); |
+ InspectorTest.addConsoleSniffer(next); |
+ InspectorTest.evaluateInPage("overrideGeolocation()"); |
+ }, |
+ |
+ function testInvalidParam(next) |
+ { |
+ GeolocationAgent.setGeolocationOverride(true, 500, 100); |
+ next(); |
+ } |
+ ]); |
+} |
+</script> |
+</head> |
+<body onload="runTest()"> |
+<p> |
+Tests that geolocation emulation with latitude and longitude works as expected. |
+</p> |
+</body> |
+</html> |