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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-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 reentrant calls to Geolocation methods from the error ca llback are OK."); 1 description("Tests that reentrant calls to Geolocation methods from the error ca llback are OK.");
2 2
3 var mockMessage = 'test'; 3 var mockMessage = 'test';
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 var errorCallbackInvoked = false;
14 navigator.geolocation.getCurrentPosition(function(p) {
15 testFailed('Success callback invoked unexpectedly');
16 finishJSTest();
17 }, function(e) {
18 if (errorCallbackInvoked) {
19 testFailed('Error callback invoked unexpectedly');
20 finishJSTest();
21 }
22 errorCallbackInvoked = true;
23 9
24 error = e; 10 geolocationServiceMock.then(mock => {
25 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); 11 mock.setGeolocationPermission(true);
26 shouldBe('error.message', 'mockMessage'); 12 mock.setGeolocationPositionUnavailableError(mockMessage);
27 debug('');
28 continueTest();
29 });
30 13
31 function continueTest() { 14 var errorCallbackInvoked = false;
32 mockMessage += ' repeat';
33
34 internals.setGeolocationPositionUnavailableError(document, mockMessage);
35
36 navigator.geolocation.getCurrentPosition(function(p) { 15 navigator.geolocation.getCurrentPosition(function(p) {
37 testFailed('Success callback invoked unexpectedly'); 16 testFailed('Success callback invoked unexpectedly');
38 finishJSTest(); 17 finishJSTest();
39 }, function(e) { 18 }, function(e) {
19 if (errorCallbackInvoked) {
20 testFailed('Error callback invoked unexpectedly');
21 finishJSTest();
22 }
23 errorCallbackInvoked = true;
24
40 error = e; 25 error = e;
41 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); 26 shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
42 shouldBe('error.message', 'mockMessage'); 27 shouldBe('error.message', 'mockMessage');
43 finishJSTest(); 28 debug('');
29 continueTest();
44 }); 30 });
45 } 31
32 function continueTest() {
33 mockMessage += ' repeat';
34
35 mock.setGeolocationPositionUnavailableError(mockMessage);
36
37 navigator.geolocation.getCurrentPosition(function(p) {
38 testFailed('Success callback invoked unexpectedly');
39 finishJSTest();
40 }, function(e) {
41 error = e;
42 shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
43 shouldBe('error.message', 'mockMessage');
44 finishJSTest();
45 });
46 }
47 });
46 48
47 window.jsTestIsAsync = true; 49 window.jsTestIsAsync = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698