• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1description("Tests that when multiple requests are waiting for permission, no callbacks are invoked until permission is allowed.");
2
3if (window.layoutTestController)
4    window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100);
5
6function allowPermission() {
7    permissionSet = true;
8    if (window.layoutTestController)
9        layoutTestController.setGeolocationPermission(true);
10}
11
12var watchCallbackInvoked = false;
13var oneShotCallbackInvoked = false;
14
15navigator.geolocation.watchPosition(function() {
16    if (permissionSet) {
17        testPassed('Success callback invoked');
18        watchCallbackInvoked = true;
19        maybeFinishTest();
20        return;
21    }
22    testFailed('Success callback invoked unexpectedly');
23    finishJSTest();
24}, function(err) {
25    testFailed('Error callback invoked unexpectedly');
26    finishJSTest();
27});
28
29navigator.geolocation.getCurrentPosition(function() {
30    if (permissionSet) {
31        testPassed('Success callback invoked');
32        oneShotCallbackInvoked = true;
33        maybeFinishTest();
34        return;
35    }
36    testFailed('Success callback invoked unexpectedly');
37    finishJSTest();
38}, function(err) {
39    testFailed('Error callback invoked unexpectedly');
40    finishJSTest();
41});
42
43window.setTimeout(allowPermission, 100);
44
45function maybeFinishTest() {
46    if (watchCallbackInvoked && oneShotCallbackInvoked)
47        finishJSTest();
48}
49
50window.jsTestIsAsync = true;
51window.successfullyParsed = true;
52