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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-denied.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 a position is available, no callbacks are invoked u ntil permission is denied."); 1 description("Tests that when a position is available, no callbacks are invoked u ntil permission is denied.");
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
6 internals.setGeolocationClientMock(document);
7 internals.setGeolocationPosition(document, 51.478, -0.166, 100);
8
9 var permissionSet = false;
10
11 function denyPermission() {
12 permissionSet = true;
13 internals.setGeolocationPermission(document, false);
14 }
15 5
16 var error; 6 var error;
17 navigator.geolocation.getCurrentPosition(function() { 7
18 testFailed('Success callback invoked unexpectedly'); 8 geolocationServiceMock.then(mock => {
19 finishJSTest(); 9 mock.setGeolocationPosition(51.478, -0.166, 100);
20 }, function(e) { 10
21 if (permissionSet) { 11 var permissionSet = false;
22 error = e; 12
23 shouldBe('error.code', 'error.PERMISSION_DENIED'); 13 function denyPermission() {
24 shouldBe('error.message', '"User denied Geolocation"'); 14 permissionSet = true;
15 mock.setGeolocationPermission(false);
16 }
17
18 navigator.geolocation.getCurrentPosition(function() {
19 testFailed('Success callback invoked unexpectedly');
25 finishJSTest(); 20 finishJSTest();
26 return; 21 }, function(e) {
27 } 22 if (permissionSet) {
28 testFailed('Error callback invoked unexpectedly'); 23 error = e;
29 finishJSTest(); 24 shouldBe('error.code', 'error.PERMISSION_DENIED');
25 shouldBe('error.message', '"User denied Geolocation"');
26 finishJSTest();
27 return;
28 }
29 testFailed('Error callback invoked unexpectedly');
30 finishJSTest();
31 });
32 window.setTimeout(denyPermission, 100);
30 }); 33 });
31 window.setTimeout(denyPermission, 100);
32 34
33 window.jsTestIsAsync = true; 35 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698