зеркало из https://github.com/mozilla/pjs.git
Fix for bug 231870 (instanceof Event (well, any dom object) is broken - throws instead of returning false). r/sr=jst.
This commit is contained in:
Родитель
c70f5ead31
Коммит
f3d91830fd
|
@ -3423,18 +3423,14 @@ DOMJSClass_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
DOMJSClass_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
||||
{
|
||||
JSObject *dom_obj;
|
||||
if (!::JS_ValueToObject(cx, v, &dom_obj)) {
|
||||
NS_ERROR("DOMJSClass_HasInstance called on non-object");
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!dom_obj) {
|
||||
// No need to look these up in the hash.
|
||||
if (JSVAL_IS_PRIMITIVE(v)) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSObject *dom_obj = JSVAL_TO_OBJECT(v);
|
||||
NS_ASSERTION(dom_obj, "DOMJSClass_HasInstance couldn't get object");
|
||||
|
||||
JSClass *dom_class = JS_GET_CLASS(cx, dom_obj);
|
||||
if (!dom_class) {
|
||||
NS_ERROR("DOMJSClass_HasInstance can't get class.");
|
||||
|
@ -3456,10 +3452,8 @@ DOMJSClass_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
|||
gNameSpaceManager->LookupName(NS_ConvertASCIItoUCS2(dom_class->name),
|
||||
&name_struct);
|
||||
if (!name_struct) {
|
||||
NS_ERROR("Name isn't in hash.");
|
||||
nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return JS_FALSE;
|
||||
// Name isn't in hash, not a DOM object.
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
||||
|
|
Загрузка…
Ссылка в новой задаче