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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-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 reentrant calls to Geolocation methods from the error ca llback due to a PERMISSION_DENIED error are OK."); 1 description("Tests that reentrant calls to Geolocation methods from the error ca llback due to a PERMISSION_DENIED error are OK.");
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.0);
9 5
10 var error; 6 var error;
11 function checkPermissionError(e) {
12 error = e;
13 shouldBe('error.code', 'error.PERMISSION_DENIED');
14 shouldBe('error.message', '"User denied Geolocation"');
15 }
16 7
17 var errorCallbackInvoked = false; 8 geolocationServiceMock.then(mock => {
18 navigator.geolocation.getCurrentPosition(function(p) { 9 mock.setGeolocationPermission(false);
19 testFailed('Success callback invoked unexpectedly'); 10 mock.setGeolocationPosition(51.478, -0.166, 100.0);
20 finishJSTest(); 11
21 }, function(e) { 12 function checkPermissionError(e) {
22 if (errorCallbackInvoked) { 13 error = e;
23 testFailed('Error callback invoked unexpectedly'); 14 shouldBe('error.code', 'error.PERMISSION_DENIED');
24 finishJSTest(); 15 shouldBe('error.message', '"User denied Geolocation"');
25 } 16 }
26 errorCallbackInvoked = true;
27 checkPermissionError(e);
28 continueTest();
29 });
30 17
31 function continueTest() { 18 var errorCallbackInvoked = false;
32 navigator.geolocation.getCurrentPosition(function(p) { 19 navigator.geolocation.getCurrentPosition(function(p) {
33 testFailed('Success callback invoked unexpectedly'); 20 testFailed('Success callback invoked unexpectedly');
34 finishJSTest(); 21 finishJSTest();
35 }, function(e) { 22 }, function(e) {
23 if (errorCallbackInvoked) {
24 testFailed('Error callback invoked unexpectedly');
25 finishJSTest();
26 }
27 errorCallbackInvoked = true;
36 checkPermissionError(e); 28 checkPermissionError(e);
37 finishJSTest(); 29 continueTest();
38 }); 30 });
39 } 31
32 function continueTest() {
33 navigator.geolocation.getCurrentPosition(function(p) {
34 testFailed('Success callback invoked unexpectedly');
35 finishJSTest();
36 }, function(e) {
37 checkPermissionError(e);
38 finishJSTest();
39 });
40 }
41 });
40 42
41 window.jsTestIsAsync = true; 43 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698