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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/permission-denied-already-error.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 Geolocation permission has been denied prior to a c all to a Geolocation method, the error callback is invoked with code PERMISSION_ DENIED, when the Geolocation service encounters an error."); 1 description("Tests that when Geolocation permission has been denied prior to a c all to a Geolocation method, the error callback is invoked with code PERMISSION_ DENIED, when the Geolocation service encounters an error.");
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.setGeolocationPermission(document, false);
8 internals.setGeolocationPosition(document, 51.478, -0.166, 100);
9 5
10 var error; 6 var error;
11 navigator.geolocation.getCurrentPosition(function(p) {
12 testFailed('Success callback invoked unexpectedly');
13 finishJSTest();
14 }, function(e) {
15 error = e;
16 shouldBe('error.code', 'error.PERMISSION_DENIED');
17 shouldBe('error.message', '"User denied Geolocation"');
18 debug('');
19 continueTest();
20 });
21 7
22 function continueTest() 8 geolocationServiceMock.then(mock => {
23 { 9 mock.setGeolocationPermission(false);
24 // Make another request, with permission already denied. 10 mock.setGeolocationPosition(51.478, -0.166, 100);
25 internals.setGeolocationPositionUnavailableError(document, 'test');
26 11
27 navigator.geolocation.getCurrentPosition(function(p) { 12 navigator.geolocation.getCurrentPosition(function(p) {
28 testFailed('Success callback invoked unexpectedly'); 13 testFailed('Success callback invoked unexpectedly');
29 finishJSTest(); 14 finishJSTest();
30 }, function(e) { 15 }, function(e) {
31 error = e; 16 error = e;
32 shouldBe('error.code', 'error.PERMISSION_DENIED'); 17 shouldBe('error.code', 'error.PERMISSION_DENIED');
33 shouldBe('error.message', '"User denied Geolocation"'); 18 shouldBe('error.message', '"User denied Geolocation"');
34 finishJSTest(); 19 debug('');
20 continueTest();
35 }); 21 });
36 } 22
23 function continueTest()
24 {
25 // Make another request, with permission already denied.
26 mock.setGeolocationPositionUnavailableError('test');
27
28 navigator.geolocation.getCurrentPosition(function(p) {
29 testFailed('Success callback invoked unexpectedly');
30 finishJSTest();
31 }, function(e) {
32 error = e;
33 shouldBe('error.code', 'error.PERMISSION_DENIED');
34 shouldBe('error.message', '"User denied Geolocation"');
35 finishJSTest();
36 });
37 }
38 });
37 39
38 window.jsTestIsAsync = true; 40 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698