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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/position-string.js

Issue 1948033003: Convert most geolocation layout tests to use a JS mock implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-disconnect
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 description("Tests formatting of position.toString()."); 1 description("Tests formatting of position.toString().");
2 2
3 var mockLatitude = 51.478; 3 var mockLatitude = 51.478;
4 var mockLongitude = -0.166; 4 var mockLongitude = -0.166;
5 var mockAccuracy = 100.0; 5 var mockAccuracy = 100.0;
6 6
7 if (!window.testRunner || !window.internals) 7 if (!window.testRunner || !window.mojo)
8 debug('This test can not run without testRunner or internals'); 8 debug('This test can not run without testRunner or mojo');
9
10 internals.setGeolocationClientMock(document);
11 internals.setGeolocationPermission(document, true);
12 internals.setGeolocationPosition(document,
13 mockLatitude,
14 mockLongitude,
15 mockAccuracy);
16 9
17 var position; 10 var position;
18 navigator.geolocation.getCurrentPosition(function(p) { 11
19 // shouldBe can't use local variables yet. 12 geolocationServiceMock.then(mock => {
20 position = p; 13 mock.setGeolocationPermission(true);
21 shouldBe('position.coords.latitude', 'mockLatitude'); 14 mock.setGeolocationPosition(mockLatitude,
22 shouldBe('position.coords.longitude', 'mockLongitude'); 15 mockLongitude,
23 shouldBe('position.coords.accuracy', 'mockAccuracy'); 16 mockAccuracy);
24 shouldBe('position.toString()', '"[object Geoposition]"'); 17
25 shouldBe('position.coords.toString()', '"[object Coordinates]"'); 18 navigator.geolocation.getCurrentPosition(function(p) {
26 finishJSTest(); 19 // shouldBe can't use local variables yet.
27 }, function(e) { 20 position = p;
28 testFailed('Error callback invoked unexpectedly'); 21 shouldBe('position.coords.latitude', 'mockLatitude');
29 finishJSTest(); 22 shouldBe('position.coords.longitude', 'mockLongitude');
23 shouldBe('position.coords.accuracy', 'mockAccuracy');
24 shouldBe('position.toString()', '"[object Geoposition]"');
25 shouldBe('position.coords.toString()', '"[object Coordinates]"');
26 finishJSTest();
27 }, function(e) {
28 testFailed('Error callback invoked unexpectedly');
29 finishJSTest();
30 });
30 }); 31 });
31 32
32 window.jsTestIsAsync = true; 33 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698