Bug 463039 - validate values that get passed to clearWatch. r/sr=jst

This commit is contained in:
Doug Turner 2008-11-12 08:01:40 -08:00
Родитель c7b1ce70c1
Коммит 16813833d1
3 изменённых файлов: 13 добавлений и 7 удалений

Просмотреть файл

@ -41,7 +41,7 @@ interface nsIDOMGeoPositionOptions;
interface nsIDOMGeoPositionCallback;
interface nsIDOMGeoPositionErrorCallback;
[scriptable, function, uuid(CE495440-C8B9-42DE-B67C-60E6928C0F40)]
[scriptable, function, uuid(0EC70F3F-7E15-45E0-84E9-CDE078CB150A)]
interface nsIDOMGeoGeolocation : nsISupports
{
readonly attribute nsIDOMGeoPosition lastPosition;
@ -50,9 +50,9 @@ interface nsIDOMGeoGeolocation : nsISupports
[optional] in nsIDOMGeoPositionErrorCallback errorCallback,
[optional] in nsIDOMGeoPositionOptions options);
unsigned short watchPosition(in nsIDOMGeoPositionCallback successCallback,
[optional] in nsIDOMGeoPositionErrorCallback errorCallback,
[optional] in nsIDOMGeoPositionOptions options);
long watchPosition(in nsIDOMGeoPositionCallback successCallback,
[optional] in nsIDOMGeoPositionErrorCallback errorCallback,
[optional] in nsIDOMGeoPositionOptions options);
void clearWatch(in unsigned short watchId);
void clearWatch(in long watchId);
};

Просмотреть файл

@ -753,7 +753,7 @@ NS_IMETHODIMP
nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback,
nsIDOMGeoPositionErrorCallback *aErrorCallback,
nsIDOMGeoPositionOptions *aOptions,
PRUint16 *_retval NS_OUTPARAM)
PRInt32 *_retval NS_OUTPARAM)
{
nsCOMPtr<nsIGeolocationPrompt> prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID);
if (prompt == nsnull)
@ -778,8 +778,13 @@ nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback,
}
NS_IMETHODIMP
nsGeolocation::ClearWatch(PRUint16 aWatchId)
nsGeolocation::ClearWatch(PRInt32 aWatchId)
{
PRUint32 count = mWatchingCallbacks.Length();
if (aWatchId < 0 || count == 0 || aWatchId > count + 1)
return NS_ERROR_FAILURE;
mWatchingCallbacks[aWatchId]->MarkCleared();
return NS_OK;
}

Просмотреть файл

@ -52,6 +52,7 @@ _TEST_FILES = \
test_cancelCurrent.html \
test_cancelWatch.html \
test_clearWatch.html \
test_clearWatch_invalid.html \
test_geoPrompt.html \
test_timeoutWatch.html \
prompt_common.js \