dom/tests/mochitest/geolocation/test_clearWatch.html

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:8e681b4dc6e8
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=478911
5 -->
6 <head>
7 <title>Test for watchPosition and clearWatch</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="text/javascript" src="geolocation_common.js"></script>
10
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
12 </head>
13 <body>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=478911">Mozilla Bug 478911</a>
15 <p id="display"></p>
16 <div id="content" style="display: none">
17
18 </div>
19 <pre id="test">
20 <script class="testbody" type="text/javascript">
21
22 SimpleTest.waitForExplicitFinish();
23
24 resume_geolocationProvider(function() {
25 force_prompt(true, test1);
26 });
27
28 var hasBeenCleared = false;
29 var successWasCalledAfterClear = false;
30 var firstCallback = true;
31
32 function failureCallback(error)
33 {
34 ok(0, "we should not be seeing failures from this watchPosition");
35 }
36
37 function successCallback(position) {
38 ok(true, "successCallback was called, hasBeenCleared=" + hasBeenCleared +
39 ", successWasCalledAfterClear=" + successWasCalledAfterClear);
40 if (hasBeenCleared == true) {
41 successWasCalledAfterClear = true;
42 }
43 if (firstCallback) {
44 SimpleTest.executeSoon(clearWatch);
45 firstCallback = false;
46 }
47 }
48
49 function clearWatch() {
50 ok(true, "clearWatch was called, hasBeenCleared=" + hasBeenCleared +
51 ", successWasCalledAfterClear=" + successWasCalledAfterClear);
52 navigator.geolocation.clearWatch(watchID);
53 hasBeenCleared = true;
54 SimpleTest.executeSoon(testAccepted);
55 }
56
57 function testAccepted() {
58 ok(true, "testAccepted was called, hasBeenCleared=" + hasBeenCleared +
59 ", successWasCalledAfterClear=" + successWasCalledAfterClear);
60 ok(!successWasCalledAfterClear, "The successCallback should not be called after clear");
61 SimpleTest.finish();
62 }
63
64 function test1() {
65 ok(true, "Getting the watchPosition");
66 watchID = navigator.geolocation.watchPosition(successCallback, failureCallback, null);
67 ok(true, "Waiting");
68 }
69 </script>
70 </pre>
71 </body>
72 </html>

mercurial