Fix for bug 741367 (Creating second XMLHttpRequest via Components.Constructor throws NS_ERROR_FAILURE): don't overwrite content-defined properties. r=bz.

--HG--
extra : rebase_source : f9c7fe34d4cde28cafea0536e305704e2dc04ff7
This commit is contained in:
Peter Van der Beken 2012-04-27 09:57:09 +02:00
parent 7eb62e9704
commit ed885d50a9

View File

@ -146,8 +146,14 @@ CreateInterfaceObject(JSContext* cx, JSObject* global, JSObject* receiver,
return NULL;
}
JSBool alreadyDefined;
if (!JS_AlreadyHasOwnProperty(cx, receiver, name, &alreadyDefined)) {
return NULL;
}
// This is Enumerable: False per spec.
if (!JS_DefineProperty(cx, receiver, name, OBJECT_TO_JSVAL(constructor), NULL,
if (!alreadyDefined &&
!JS_DefineProperty(cx, receiver, name, OBJECT_TO_JSVAL(constructor), NULL,
NULL, 0)) {
return NULL;
}