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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/permission-denied-stops-watches.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 is denied, watches are stopp ed, as well as one-shots."); 1 description("Tests that when Geolocation permission is denied, watches are stopp ed, as well as one-shots.");
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
8 // Configure the mock Geolocation service to report a position to cause permissi on
9 // to be requested, then deny it.
10 internals.setGeolocationPermission(document, false);
11 internals.setGeolocationPosition(document, 51.478, -0.166, 100.0);
12 5
13 var error; 6 var error;
14 var errorCallbackInvoked = false; 7
15 navigator.geolocation.watchPosition(function(p) { 8 geolocationServiceMock.then(mock => {
16 testFailed('Success callback invoked unexpectedly'); 9
17 finishJSTest(); 10 // Configure the mock Geolocation service to report a position to cause perm ission
18 }, function(e) { 11 // to be requested, then deny it.
19 if (errorCallbackInvoked) { 12 mock.setGeolocationPermission(false);
20 testFailed('Error callback invoked unexpectedly : ' + error.message); 13 mock.setGeolocationPosition(51.478, -0.166, 100.0);
14
15 var errorCallbackInvoked = false;
16 navigator.geolocation.watchPosition(function(p) {
17 testFailed('Success callback invoked unexpectedly');
21 finishJSTest(); 18 finishJSTest();
22 } 19 }, function(e) {
23 errorCallbackInvoked = true; 20 if (errorCallbackInvoked) {
21 testFailed('Error callback invoked unexpectedly : ' + error.message) ;
22 finishJSTest();
23 }
24 errorCallbackInvoked = true;
24 25
25 error = e; 26 error = e;
26 shouldBe('error.code', 'error.PERMISSION_DENIED'); 27 shouldBe('error.code', 'error.PERMISSION_DENIED');
27 shouldBe('error.message', '"User denied Geolocation"'); 28 shouldBe('error.message', '"User denied Geolocation"');
28 29
29 // Update the mock Geolocation service to report a new position, then 30 // Update the mock Geolocation service to report a new position, then
30 // yield to allow a chance for the success callback to be invoked. 31 // yield to allow a chance for the success callback to be invoked.
31 internals.setGeolocationPosition(document, 55.478, -0.166, 100); 32 mock.setGeolocationPosition(55.478, -0.166, 100);
32 window.setTimeout(finishJSTest, 0); 33 window.setTimeout(finishJSTest, 0);
34 });
33 }); 35 });
34 36
35
36 window.jsTestIsAsync = true; 37 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698