Bug 1220688 - catch and ignore JS exceptions when working with nsAutoJSString. r=bz

This commit is contained in:
Dave Huseby 2015-11-12 13:12:00 +01:00
parent 0ed99f560f
commit 91ebc31678

View File

@ -260,6 +260,7 @@ nsGeolocationSettings::HandleGeolocationPerOriginSettingsChange(const JS::Value&
// if it is an app that is always precise, skip it
nsAutoJSString origin;
if (!origin.init(cx, id)) {
JS_ClearPendingException(cx); // catch and ignore any exceptions
continue;
}
if (mAlwaysPreciseApps.Contains(origin)) {
@ -268,7 +269,8 @@ nsGeolocationSettings::HandleGeolocationPerOriginSettingsChange(const JS::Value&
// get the app setting object
JS::RootedValue propertyValue(cx);
if (!JS_GetPropertyById(cx, obj, id, &propertyValue) || !propertyValue.isObject()) {
if (!JS_GetPropertyById(cx, obj, id, &propertyValue)) {
JS_ClearPendingException(cx); // catch and ignore any exceptions
continue;
}
JS::RootedObject settingObj(cx, &propertyValue.toObject());
@ -280,6 +282,8 @@ nsGeolocationSettings::HandleGeolocationPerOriginSettingsChange(const JS::Value&
JS::RootedValue fm(cx);
if (JS_GetProperty(cx, settingObj, "type", &fm)) {
settings->HandleTypeChange(fm);
} else {
JS_ClearPendingException(cx); // catch and ignore any exceptions
}
#ifdef MOZ_APPROX_LOCATION
@ -287,6 +291,8 @@ nsGeolocationSettings::HandleGeolocationPerOriginSettingsChange(const JS::Value&
JS::RootedValue distance(cx);
if (JS_GetProperty(cx, settingObj, "distance", &distance)) {
settings->HandleApproxDistanceChange(distance);
} else {
JS_ClearPendingException(cx); // catch and ignore any exceptions
}
#endif
@ -294,6 +300,8 @@ nsGeolocationSettings::HandleGeolocationPerOriginSettingsChange(const JS::Value&
JS::RootedValue coords(cx);
if (JS_GetProperty(cx, settingObj, "coords", &coords)) {
settings->HandleFixedCoordsChange(coords);
} else {
JS_ClearPendingException(cx); // catch and ignore any exceptions
}
// add the per-app setting object to the hashtable
@ -337,11 +345,13 @@ nsGeolocationSettings::HandleGeolocationAlwaysPreciseChange(const JS::Value& aVa
JS::RootedValue value(cx);
if (!JS_GetElement(cx, obj, i, &value) || !value.isString()) {
JS_ClearPendingException(cx); // catch and ignore any exceptions
continue;
}
nsAutoJSString origin;
if (!origin.init(cx, value)) {
JS_ClearPendingException(cx); // catch and ignore any exceptions
continue;
}