Bug 779015 - Make JS_Is*Array() not throw. (r=bhackett)
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -2915,18 +2915,21 @@ JSFunctionSpec _typedArray::jsfuncs[] =
MOZ_ASSERT(byteoffset <= INT32_MAX); \
Rooted<JSObject*> arrayBuffer(cx, arrayBuffer_); \
Rooted<JSObject*> proto(cx, NULL); \
return TypedArrayTemplate<NativeType>::fromBuffer(cx, arrayBuffer, byteoffset, length, \
proto); \
} \
JS_FRIEND_API(JSBool) JS_Is ## Name ## Array(JSObject *obj, JSContext *cx) \
{ \
- if (!(obj = UnwrapObjectChecked(cx, obj))) \
+ MOZ_ASSERT(!cx->isExceptionPending()); \
+ if (!(obj = UnwrapObjectChecked(cx, obj))) { \
+ cx->clearPendingException(); \
return false; \
+ } \
Class *clasp = obj->getClass(); \
return (clasp == &TypedArray::classes[TypedArrayTemplate<NativeType>::ArrayTypeID()]); \
}
IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Int8, int8_t)
IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Uint8, uint8_t)
IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Uint8Clamped, uint8_clamped)
IMPL_TYPED_ARRAY_JSAPI_CONSTRUCTORS(Int16, int16_t)