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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-allowed-for-multiple-requests.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 that when multiple requests are waiting for permission, no ca llbacks are invoked until permission is allowed."); 1 description("Tests that when multiple requests are waiting for permission, no ca llbacks are invoked until permission is allowed.");
2 2
3 if (!window.testRunner || !window.internals) 3 if (!window.testRunner || !window.mojo)
4 debug('This test can not run without testRunner or internals'); 4 debug('This test can not run without testRunner or mojo');
5 5
6 internals.setGeolocationClientMock(document); 6 geolocationServiceMock.then(mock => {
7 internals.setGeolocationPosition(document, 51.478, -0.166, 100); 7 mock.setGeolocationPosition(51.478, -0.166, 100);
8 8
9 var permissionSet = false; 9 var permissionSet = false;
10 10
11 function allowPermission() { 11 function allowPermission() {
12 permissionSet = true; 12 permissionSet = true;
13 internals.setGeolocationPermission(document, true); 13 mock.setGeolocationPermission(true);
14 } 14 }
15 15
16 var watchCallbackInvoked = false; 16 var watchCallbackInvoked = false;
17 var oneShotCallbackInvoked = false; 17 var oneShotCallbackInvoked = false;
18 18
19 navigator.geolocation.watchPosition(function() { 19 navigator.geolocation.watchPosition(function() {
20 if (permissionSet) { 20 if (permissionSet) {
21 testPassed('Success callback invoked'); 21 testPassed('Success callback invoked');
22 watchCallbackInvoked = true; 22 watchCallbackInvoked = true;
23 maybeFinishTest(); 23 maybeFinishTest();
24 return; 24 return;
25 }
26 testFailed('Success callback invoked unexpectedly');
27 finishJSTest();
28 }, function(err) {
29 testFailed('Error callback invoked unexpectedly');
30 finishJSTest();
31 });
32
33 navigator.geolocation.getCurrentPosition(function() {
34 if (permissionSet) {
35 testPassed('Success callback invoked');
36 oneShotCallbackInvoked = true;
37 maybeFinishTest();
38 return;
39 }
40 testFailed('Success callback invoked unexpectedly');
41 finishJSTest();
42 }, function(err) {
43 testFailed('Error callback invoked unexpectedly');
44 finishJSTest();
45 });
46
47 window.setTimeout(allowPermission, 100);
48
49 function maybeFinishTest() {
50 if (watchCallbackInvoked && oneShotCallbackInvoked)
51 finishJSTest();
25 } 52 }
26 testFailed('Success callback invoked unexpectedly');
27 finishJSTest();
28 }, function(err) {
29 testFailed('Error callback invoked unexpectedly');
30 finishJSTest();
31 }); 53 });
32 54
33 navigator.geolocation.getCurrentPosition(function() {
34 if (permissionSet) {
35 testPassed('Success callback invoked');
36 oneShotCallbackInvoked = true;
37 maybeFinishTest();
38 return;
39 }
40 testFailed('Success callback invoked unexpectedly');
41 finishJSTest();
42 }, function(err) {
43 testFailed('Error callback invoked unexpectedly');
44 finishJSTest();
45 });
46
47 window.setTimeout(allowPermission, 100);
48
49 function maybeFinishTest() {
50 if (watchCallbackInvoked && oneShotCallbackInvoked)
51 finishJSTest();
52 }
53
54 window.jsTestIsAsync = true; 55 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698