diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 9d1f0e9f88d1..fe2b1570cbb1 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -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; }