Bug 460063 - Test case fixes for Geolocation prompt should not appear if there are no providers installed
authorDoug Turner <dougt@meer.net>
Wed, 12 Nov 2008 14:52:56 -0800
changeset 21631 d21ca3cce0ec8a020152f9d36393d09dd987c92a
parent 21630 c9db688f2a424ea4270b69199c38edb3de765744
child 21632 a1364547a182263c2f8b83742af1a9a2d86113a0
push id3624
push userdougt@mozilla.com
push dateThu, 13 Nov 2008 19:59:44 +0000
treeherdermozilla-central@a1364547a182 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs460063
milestone1.9.1b2pre
Bug 460063 - Test case fixes for Geolocation prompt should not appear if there are no providers installed
dom/tests/mochitest/geolocation/test_allowWatch.html
dom/tests/mochitest/geolocation/test_cancelCurrent.html
dom/tests/mochitest/geolocation/test_cancelWatch.html
dom/tests/mochitest/geolocation/test_clearWatch.html
--- a/dom/tests/mochitest/geolocation/test_allowWatch.html
+++ b/dom/tests/mochitest/geolocation/test_allowWatch.html
@@ -20,29 +20,37 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var numCallbacks = 5;
 var callbackCounter = new Array(numCallbacks);
 var watchID = new Array(numCallbacks);
 
+function failureCallback(error)
+{
+  ok(error.code == 2, "Failure was something other than position unavailable");
+  removePrompt();
+  SimpleTest.finish();
+}
+
+
 // define success callbacks
 for(var i = 0; i < numCallbacks; i++) {
   eval("function successCallback" + i + "(position) {" +
           "callbackCounter[" + i + "]++;" +
           "success_callback(position);" +
        "}"
   );
 }
 
 function registerWatches() {
   for(var i = 0; i < numCallbacks; i++) {
     watchID[i] = eval("navigator.geolocation.watchPosition(successCallback"
-                       + i + ", null, null);"
+                       + i + ", failureCallback, null);"
     );
   }
 }
 
 function clearWatches() {
   for(var i = 0; i < numCallbacks; i++)
     navigator.geolocation.clearWatch(watchID[i]);
 }
--- a/dom/tests/mochitest/geolocation/test_cancelCurrent.html
+++ b/dom/tests/mochitest/geolocation/test_cancelCurrent.html
@@ -19,16 +19,23 @@ https://bugzilla.mozilla.org/show_bug.cg
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var numCallbacks = 5;
 var callbackCounter = new Array(numCallbacks);
 
+function failureCallback(error)
+{
+  ok(error.code == 2, "Failure was something other than position unavailable");
+  removePrompt();
+  SimpleTest.finish();
+}
+
 // define success callbacks
 for(var i = 0; i < numCallbacks; i++) {
   eval("function successCallback" + i + "(position) {" +
           "callbackCounter[" + i + "]++;" +
           "success_callback(position);" +
        "}"
   );
 }
@@ -45,17 +52,17 @@ SimpleTest.waitForExplicitFinish();
 attachPrompt();
 
 ok(navigator.geolocation, "Ensure that the geolocation object is present");
 
 promptOption = DECLINE;
 
 // one-shot position requests
 for(var i = 0; i < numCallbacks; i++) {
-  eval("navigator.geolocation.getCurrentPosition(successCallback" + i + ", null, null);");
+  eval("navigator.geolocation.getCurrentPosition(successCallback" + i + ", failureCallback, null);");
 }
 
 // wait for position change
 setTimeout(testDeclined, timeout);
 
 </script>
 </pre>
 </body>
--- a/dom/tests/mochitest/geolocation/test_cancelWatch.html
+++ b/dom/tests/mochitest/geolocation/test_cancelWatch.html
@@ -20,29 +20,36 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var numCallbacks = 5;
 var callbackCounter = new Array(numCallbacks);
 var watchID = new Array(numCallbacks);
 
+function failureCallback(error)
+{
+  ok(error.code == 2, "Failure was something other than position unavailable");
+  removePrompt();
+  SimpleTest.finish();
+}
+
 // define success callbacks
 for(var i = 0; i < numCallbacks; i++) {
   eval("function successCallback" + i + "(position) {" +
           "callbackCounter[" + i + "]++;" +
           "success_callback(position);" +
        "}"
   );
 }
 
 function registerWatches() {
   for(var i = 0; i < numCallbacks; i++) {
     watchID[i] = eval("navigator.geolocation.watchPosition(successCallback"
-                       + i + ", null, null);"
+                       + i + ", failureCallback, null);"
     );
   }
 }
 
 function clearWatches() {
   for(var i = 0; i < numCallbacks; i++)
     navigator.geolocation.clearWatch(watchID[i]);
 }
--- a/dom/tests/mochitest/geolocation/test_clearWatch.html
+++ b/dom/tests/mochitest/geolocation/test_clearWatch.html
@@ -20,29 +20,36 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var numCallbacks = 5;
 var callbackCounter = new Array(numCallbacks);
 var watchID = new Array(numCallbacks);
 
+function failureCallback(error)
+{
+  ok(error.code == 2, "Failure was something other than position unavailable");
+  removePrompt();
+  SimpleTest.finish();
+}
+
 // define success callbacks
 for(var i = 0; i < numCallbacks; i++) {
   eval("function successCallback" + i + "(position) {" +
           "callbackCounter[" + i + "]++;" +
           "success_callback(position);" +
        "}"
   );
 }
 
 function registerWatches() {
   for(var i = 0; i < numCallbacks; i++) {
     watchID[i] = eval("navigator.geolocation.watchPosition(successCallback"
-                       + i + ", null, null);"
+                       + i + ", failureCallback, null);"
     );
   }
 }
 
 function clearWatches() {
   for(var i = 0; i < numCallbacks; i++)
     navigator.geolocation.clearWatch(watchID[i]);
 }