Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: LayoutTests/inspector/geolocation-emulation-tests.html

Issue 172393006: LayoutTest emulating geolocation with inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add sniffer code back Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/inspector/geolocation-emulation-tests-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | LayoutTests/inspector/geolocation-emulation-tests-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698