diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -1069,17 +1069,17 @@ nsGeolocation::WatchPosition(nsIDOMGeoPo
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGeolocation::ClearWatch(PRInt32 aWatchId)
 {
   PRUint32 count = mWatchingCallbacks.Length();
-  if (aWatchId < 0 || count == 0 || PRUint32(aWatchId) > count)
+  if (aWatchId < 0 || count == 0 || PRUint32(aWatchId) >= count)
     return NS_OK;
 
   mWatchingCallbacks[aWatchId]->MarkCleared();
   return NS_OK;
 }
 
 PRBool
 nsGeolocation::WindowOwnerStillExists()
diff --git a/dom/tests/mochitest/geolocation/test_clearWatch_invalid.html b/dom/tests/mochitest/geolocation/test_clearWatch_invalid.html
--- a/dom/tests/mochitest/geolocation/test_clearWatch_invalid.html
+++ b/dom/tests/mochitest/geolocation/test_clearWatch_invalid.html
@@ -14,16 +14,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=463039">Mozilla Bug 463039</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
+navigator.geolocation.watchPosition(function(){});
+
 // there are no watches, so this should always throw
 for (x=-10; x<10; x++) {
     navigator.geolocation.clearWatch(x);
     ok(1, "clearWatch should not throw");
 }
 
 // lets try something huge
 navigator.geolocation.clearWatch(Number.MAX_VALUE);
