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

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

Issue 2667393002: Stop using script-tests in fast/dom/. (Closed)
Patch Set: . Created 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 description('Tests that when a cached position is available the callback for get CurrentPosition is called only once. This is a regression test for http://crbug. com/311876 .');
2
3 // Only one success callback should be reported per call to getCurrentPosition.
4 var reportCount = 0;
5 var isSuccess;
6
7 function reportCallback(success, id) {
8 isSuccess = success;
9 shouldBeTrue('isSuccess');
10 getCurrentPositionCallId = id;
11 shouldBe('getCurrentPositionCallId', 'reportCount');
12 if (++reportCount >= 3)
13 finishJSTest();
14 }
15
16 var getCurrentPositionCall = 0;
17 function getPosition(milliseconds) {
18 var id = getCurrentPositionCall++;
19 var fn = function() {
20 navigator.geolocation.getCurrentPosition(
21 function(position) {
22 reportCallback(true, id);
23 },
24 function(error) {
25 reportCallback(false, id);
26 },
27 { maximumAge:600000, timeout:0 });
28 };
29 setTimeout(fn, milliseconds);
30 }
31
32 geolocationServiceMock.then(mock => {
33 mock.setGeolocationPosition(31.478, -0.166, 100);
34 mock.setGeolocationPermission(true);
35
36 // Make a geolocation request to populate the cached value so requests with a
37 // timeout of 0 can succeed.
38 navigator.geolocation.getCurrentPosition(function(position) {
39 // The test terminates at the 3rd reported callback. If the bug still ex ists
40 // this happens after the 2nd call to getCurrentPosition, one of them is a
41 // repeat of the first.
42 getPosition(0);
43 getPosition(100);
44 getPosition(200);
45 }, function(error) {
46 testFailed('Error callback invoked unexpectedly');
47 });
48 });
49
50 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698