blob: d28a66a1a46e83fa38f17f9d86b824a51c224c24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
description("Tests that reentrant calls to Geolocation methods from the error callback are OK.");
var mockCode = 2;
var mockMessage = 'test';
if (window.layoutTestController) {
layoutTestController.setGeolocationPermission(true);
layoutTestController.setMockGeolocationError(mockCode, mockMessage);
} else
debug('This test can not be run without the LayoutTestController');
var error;
var errorCallbackInvoked = false;
navigator.geolocation.getCurrentPosition(function(p) {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
if (errorCallbackInvoked) {
testFailed('Error callback invoked unexpectedly');
finishJSTest();
}
errorCallbackInvoked = true;
error = e;
shouldBe('error.code', 'mockCode');
shouldBe('error.message', 'mockMessage');
debug('');
continueTest();
});
function continueTest() {
mockMessage += ' repeat';
if (window.layoutTestController)
layoutTestController.setMockGeolocationError(mockCode, mockMessage);
navigator.geolocation.getCurrentPosition(function(p) {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
error = e;
shouldBe('error.code', 'mockCode');
shouldBe('error.message', 'mockMessage');
finishJSTest();
});
}
window.jsTestIsAsync = true;
window.successfullyParsed = true;
|