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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/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 Geolocation error callback using the mock service."); 1 description("Tests Geolocation error callback using the mock service.");
2 2
3 var mockMessage = "debug"; 3 var mockMessage = "debug";
4 4
5 if (!window.testRunner || !window.internals) 5 if (!window.testRunner || !window.mojo)
6 debug('This test can not run without testRunner or internals'); 6 debug('This test can not run without testRunner or mojo');
7
8 internals.setGeolocationClientMock(document);
9 internals.setGeolocationPermission(document, true);
10 internals.setGeolocationPositionUnavailableError(document, mockMessage);
11 7
12 var error; 8 var error;
13 navigator.geolocation.getCurrentPosition(function(p) { 9
10 geolocationServiceMock.then(mock => {
11 mock.setGeolocationPermission(true);
12 mock.setGeolocationPositionUnavailableError(mockMessage);
13
14 navigator.geolocation.getCurrentPosition(function(p) {
14 testFailed('Success callback invoked unexpectedly'); 15 testFailed('Success callback invoked unexpectedly');
15 finishJSTest(); 16 finishJSTest();
16 }, function(e) { 17 }, function(e) {
17 error = e; 18 error = e;
18 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); 19 shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
19 shouldBe('error.message', 'mockMessage'); 20 shouldBe('error.message', 'mockMessage');
20 shouldBe('error.UNKNOWN_ERROR', 'undefined'); 21 shouldBe('error.UNKNOWN_ERROR', 'undefined');
21 shouldBe('error.PERMISSION_DENIED', '1'); 22 shouldBe('error.PERMISSION_DENIED', '1');
22 shouldBe('error.POSITION_UNAVAILABLE', '2'); 23 shouldBe('error.POSITION_UNAVAILABLE', '2');
23 shouldBe('error.TIMEOUT', '3'); 24 shouldBe('error.TIMEOUT', '3');
24 finishJSTest(); 25 finishJSTest();
26 });
25 }); 27 });
26 28
27 window.jsTestIsAsync = true; 29 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698