diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index fc848ce7ff47..504917647f03 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -3620,7 +3620,7 @@ nsGenericArraySH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, nsresult nsGenericArraySH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx, - JSObject *obj, uint32_t *length) + JS::Handle obj, uint32_t *length) { *length = 0; @@ -3995,7 +3995,7 @@ nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp) // If we are called via document.all(id) instead of document.all.item(i) or // another method, use the document.all callee object as self. - JSObject *self; + JS::Rooted self(cx); if (args.calleev().isObject() && JS_GetClass(&args.calleev().toObject()) == &sHTMLDocumentAllClass) { self = &args.calleev().toObject(); diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h index 70beca7a75d8..5ea831c1751b 100644 --- a/dom/base/nsDOMClassInfo.h +++ b/dom/base/nsDOMClassInfo.h @@ -328,16 +328,16 @@ protected: virtual ~nsGenericArraySH() { } - + public: NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSObject *obj, jsid id, uint32_t flags, JSObject **objp, bool *_retval) MOZ_OVERRIDE; NS_IMETHOD Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSObject *obj, bool *_retval) MOZ_OVERRIDE; - + virtual nsresult GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx, - JSObject *obj, uint32_t *length); + JS::Handle obj, uint32_t *length); static nsIClassInfo *doCreate(nsDOMClassInfoData* aData) { diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index b23d5bfe0097..e35893cac867 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -2427,7 +2427,6 @@ class InternedStringId InternedStringId() : id(JSID_VOID) {} bool init(JSContext *cx, const char *string) { - MOZ_ASSERT(id == JSID_VOID); JSString* str = JS_InternString(cx, string); if (!str) return false; diff --git a/dom/bindings/CallbackInterface.cpp b/dom/bindings/CallbackInterface.cpp index b07689ccc4db..88b976470320 100644 --- a/dom/bindings/CallbackInterface.cpp +++ b/dom/bindings/CallbackInterface.cpp @@ -16,7 +16,7 @@ bool CallbackInterface::GetCallableProperty(JSContext* cx, const char* aPropName, JS::MutableHandle aCallable) { - if (!JS_GetProperty(cx, mCallback, aPropName, aCallable)) { + if (!JS_GetProperty(cx, CallbackPreserveColor(), aPropName, aCallable)) { return false; } if (!aCallable.isObject() || diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 83e6de958c39..76d8bc62b3b1 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -9105,9 +9105,11 @@ if (cx) { if memberInits: body += ( "bool isNull = val.isNullOrUndefined();\n" - "// We only need |temp| if !isNull, in which case we have |cx|.\n" + "// We only need these if !isNull, in which case we have |cx|.\n" + "Maybe > object;\n" "Maybe > temp;\n" "if (!isNull) {\n" + " object.construct(cx, &val.toObject());\n" " temp.construct(cx);\n" "}\n") body += "\n\n".join(memberInits) + "\n" @@ -9173,7 +9175,7 @@ if (!*reinterpret_cast(atomsCache) && !InitIds(cx, atomsCache)) { def initIdsMethod(self): assert self.needToInitIds - idinit = [CGGeneric('!InternJSString(cx, atomsCache->%s, "%s")' % + idinit = [CGGeneric('!atomsCache->%s.init(cx, "%s")' % (m.identifier.name + "_id", m.identifier.name)) for m in self.dictionary.members] idinit.reverse(); @@ -9358,7 +9360,7 @@ if (""", replacements["haveValue"] = "!isNull && !temp.ref().isUndefined()" propId = self.makeIdName(member.identifier.name); - propGet = ("JS_GetPropertyById(cx, &val.toObject(), atomsCache->%s, &temp.ref())" % + propGet = ("JS_GetPropertyById(cx, object.ref(), atomsCache->%s, &temp.ref())" % propId) conversionReplacements = { @@ -11435,7 +11437,8 @@ class CallbackGetter(CallbackAccessor): self.attrName) } return string.Template( - 'if (!JS_GetProperty(cx, mCallback, "${attrName}", &rval)) {\n' + 'JS::Rooted callback(cx, mCallback);\n' + 'if (!JS_GetProperty(cx, callback, "${attrName}", &rval)) {\n' ' aRv.Throw(NS_ERROR_UNEXPECTED);\n' ' return${errorReturn};\n' '}\n').substitute(replacements); @@ -11502,9 +11505,8 @@ class GlobalGenRoots(): continue classMembers = [ClassMember(m.identifier.name + "_id", - "jsid", - visibility="public", - body="JSID_VOID") for m in dictMembers] + "InternedStringId", + visibility="public") for m in dictMembers] structName = dict.identifier.name + "Atoms" structs.append((structName, @@ -11528,6 +11530,11 @@ class GlobalGenRoots(): CGWrapper(structs, pre='\n')) curr = CGWrapper(curr, post='\n') + # Add include statement for InternedStringId. + declareIncludes = ['mozilla/dom/BindingUtils.h'] + curr = CGHeaders([], [], [], [], declareIncludes, [], 'GeneratedAtomList', + curr) + # Add include guards. curr = CGIncludeGuard('GeneratedAtomList', curr) diff --git a/dom/bluetooth/BluetoothService.cpp b/dom/bluetooth/BluetoothService.cpp index 749ce264ea3b..9a2211a38a66 100644 --- a/dom/bluetooth/BluetoothService.cpp +++ b/dom/bluetooth/BluetoothService.cpp @@ -605,10 +605,10 @@ BluetoothService::HandleSettingsChanged(const nsAString& aData) return NS_OK; } - JSObject& obj(val.toObject()); + JS::Rooted obj(cx, &val.toObject()); JS::Rooted key(cx); - if (!JS_GetProperty(cx, &obj, "key", &key)) { + if (!JS_GetProperty(cx, obj, "key", &key)) { MOZ_ASSERT(!JS_IsExceptionPending(cx)); return NS_ERROR_OUT_OF_MEMORY; } @@ -626,7 +626,7 @@ BluetoothService::HandleSettingsChanged(const nsAString& aData) if (match) { JS::Rooted value(cx); - if (!JS_GetProperty(cx, &obj, "value", &value)) { + if (!JS_GetProperty(cx, obj, "value", &value)) { MOZ_ASSERT(!JS_IsExceptionPending(cx)); return NS_ERROR_OUT_OF_MEMORY; } @@ -649,7 +649,7 @@ BluetoothService::HandleSettingsChanged(const nsAString& aData) if (match) { JS::Rooted value(cx); - if (!JS_GetProperty(cx, &obj, "value", &value)) { + if (!JS_GetProperty(cx, obj, "value", &value)) { MOZ_ASSERT(!JS_IsExceptionPending(cx)); return NS_ERROR_OUT_OF_MEMORY; } diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 71e0fa5df6e3..b461811d4c34 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -98,7 +98,8 @@ static nsresult CompareDictionaries(JSContext* aCx, JSObject *aA, for (size_t i = 0; i < props.length(); i++) { JS::Rooted bprop(aCx); - if (!JS_GetPropertyById(aCx, b, props[i], &bprop)) { + JS::Rooted id(aCx, props[i]); + if (!JS_GetPropertyById(aCx, b, id, &bprop)) { LOG(("Error parsing dictionary!\n")); return NS_ERROR_UNEXPECTED; } diff --git a/dom/network/src/TCPSocketParent.cpp b/dom/network/src/TCPSocketParent.cpp index 9cb402f128d0..713090ac2844 100644 --- a/dom/network/src/TCPSocketParent.cpp +++ b/dom/network/src/TCPSocketParent.cpp @@ -217,7 +217,7 @@ TCPSocketParent::SendEvent(const nsAString& aType, JS::Handle aDataVa data = mozilla::void_t(); } else if (aDataVal.isObject()) { - JSObject* obj = &aDataVal.toObject(); + JS::Rooted obj(aCx, &aDataVal.toObject()); if (JS_IsArrayBufferObject(obj)) { uint32_t nbytes = JS_GetArrayBufferByteLength(obj); uint8_t* buffer = JS_GetArrayBufferData(obj); diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index 565586d48f91..b628b5066461 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -557,11 +557,13 @@ nsJSObjWrapper::NP_Invalidate(NPObject *npobj) } static bool -GetProperty(JSContext *cx, JSObject *obj, NPIdentifier id, JS::MutableHandle rval) +GetProperty(JSContext *cx, JSObject *objArg, NPIdentifier npid, JS::MutableHandle rval) { - NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id), + NS_ASSERTION(NPIdentifierIsInt(npid) || NPIdentifierIsString(npid), "id must be either string or int!\n"); - return ::JS_GetPropertyById(cx, obj, NPIdentifierToJSId(id), rval); + JS::Rooted obj(cx, objArg); + JS::Rooted id(cx, NPIdentifierToJSId(npid)); + return ::JS_GetPropertyById(cx, obj, id, rval); } // static diff --git a/dom/system/gonk/AutoMounterSetting.cpp b/dom/system/gonk/AutoMounterSetting.cpp index ed5bc51588e3..282455e9443f 100644 --- a/dom/system/gonk/AutoMounterSetting.cpp +++ b/dom/system/gonk/AutoMounterSetting.cpp @@ -242,9 +242,9 @@ AutoMounterSetting::Observe(nsISupports* aSubject, !val.isObject()) { return NS_OK; } - JSObject& obj(val.toObject()); + JS::Rooted obj(cx, &val.toObject()); JS::Rooted key(cx); - if (!JS_GetProperty(cx, &obj, "key", &key) || + if (!JS_GetProperty(cx, obj, "key", &key) || !key.isString()) { return NS_OK; } @@ -256,7 +256,7 @@ AutoMounterSetting::Observe(nsISupports* aSubject, } JS::Rooted value(cx); - if (!JS_GetProperty(cx, &obj, "value", &value)) { + if (!JS_GetProperty(cx, obj, "value", &value)) { return NS_OK; } diff --git a/dom/system/gonk/TimeZoneSettingObserver.cpp b/dom/system/gonk/TimeZoneSettingObserver.cpp index 908ab8c12205..69cb05c479a7 100644 --- a/dom/system/gonk/TimeZoneSettingObserver.cpp +++ b/dom/system/gonk/TimeZoneSettingObserver.cpp @@ -209,9 +209,9 @@ TimeZoneSettingObserver::Observe(nsISupports *aSubject, } // Get the key, which should be the JS string "time.timezone". - JSObject &obj(val.toObject()); + JS::Rooted obj(cx, &val.toObject()); JS::Rooted key(cx); - if (!JS_GetProperty(cx, &obj, "key", &key) || + if (!JS_GetProperty(cx, obj, "key", &key) || !key.isString()) { return NS_OK; } @@ -223,7 +223,7 @@ TimeZoneSettingObserver::Observe(nsISupports *aSubject, // Get the value, which should be a JS string like "America/Chicago". JS::Rooted value(cx); - if (!JS_GetProperty(cx, &obj, "value", &value) || + if (!JS_GetProperty(cx, obj, "value", &value) || !value.isString()) { return NS_OK; } diff --git a/js/src/jsapi-tests/testException.cpp b/js/src/jsapi-tests/testException.cpp index 6f0226e702bd..846a6b7c6016 100644 --- a/js/src/jsapi-tests/testException.cpp +++ b/js/src/jsapi-tests/testException.cpp @@ -17,8 +17,9 @@ BEGIN_TEST(testException_bug860435) JS::RootedValue v(cx); JS_CallFunctionValue(cx, global, fun, 0, v.address(), v.address()); CHECK(v.isObject()); + JS::RootedObject obj(cx, &v.toObject()); - JS_GetProperty(cx, &v.toObject(), "stack", &v); + JS_GetProperty(cx, obj, "stack", &v); CHECK(v.isString()); return true; } diff --git a/js/src/jsapi-tests/testStructuredClone.cpp b/js/src/jsapi-tests/testStructuredClone.cpp index 8ddccc12596e..1d214f2c54b3 100644 --- a/js/src/jsapi-tests/testStructuredClone.cpp +++ b/js/src/jsapi-tests/testStructuredClone.cpp @@ -31,11 +31,12 @@ BEGIN_TEST(testStructuredClone_object) CHECK(JS_StructuredClone(cx, v1, &v2, nullptr, nullptr)); CHECK(v2.isObject()); + JS::RootedObject obj(cx, &v2.toObject()); JS::RootedValue prop(cx); - CHECK(JS_GetProperty(cx, &v2.toObject(), "prop", &prop)); + CHECK(JS_GetProperty(cx, obj, "prop", &prop)); CHECK(prop.isInt32()); - CHECK(&v1.toObject() != &v2.toObject()); + CHECK(&v1.toObject() != obj); CHECK_EQUAL(prop.toInt32(), 1337); } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 58501dbd3d26..2529eafa3bb8 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -3332,11 +3332,8 @@ JS_GetPropertyDescriptor(JSContext *cx, JSObject *objArg, const char *name, unsi } JS_PUBLIC_API(bool) -JS_GetPropertyById(JSContext *cx, JSObject *objArg, jsid idArg, MutableHandleValue vp) +JS_GetPropertyById(JSContext *cx, HandleObject obj, HandleId id, MutableHandleValue vp) { - RootedObject obj(cx, objArg); - RootedId id(cx, idArg); - return JS_ForwardGetPropertyTo(cx, obj, id, obj, vp); } @@ -3354,7 +3351,7 @@ JS_ForwardGetPropertyTo(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS } JS_PUBLIC_API(bool) -JS_GetElement(JSContext *cx, JSObject *objArg, uint32_t index, MutableHandleValue vp) +JS_GetElement(JSContext *cx, HandleObject objArg, uint32_t index, MutableHandleValue vp) { return JS_ForwardGetElementTo(cx, objArg, index, objArg, vp); } @@ -3374,20 +3371,24 @@ JS_ForwardGetElementTo(JSContext *cx, JSObject *objArg, uint32_t index, JSObject } JS_PUBLIC_API(bool) -JS_GetProperty(JSContext *cx, JSObject *objArg, const char *name, MutableHandleValue vp) +JS_GetProperty(JSContext *cx, HandleObject obj, const char *name, MutableHandleValue vp) { - RootedObject obj(cx, objArg); JSAtom *atom = Atomize(cx, name, strlen(name)); - return atom && JS_GetPropertyById(cx, obj, AtomToId(atom), vp); + if (!atom) + return false; + RootedId id(cx, AtomToId(atom)); + return JS_GetPropertyById(cx, obj, id, vp); } JS_PUBLIC_API(bool) -JS_GetUCProperty(JSContext *cx, JSObject *objArg, const jschar *name, size_t namelen, +JS_GetUCProperty(JSContext *cx, HandleObject obj, const jschar *name, size_t namelen, MutableHandleValue vp) { - RootedObject obj(cx, objArg); JSAtom *atom = AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen)); - return atom && JS_GetPropertyById(cx, obj, AtomToId(atom), vp); + if (!atom) + return false; + RootedId id(cx, AtomToId(atom)); + return JS_GetPropertyById(cx, obj, id, vp); } JS_PUBLIC_API(bool) @@ -3516,10 +3517,9 @@ JS_DeleteProperty2(JSContext *cx, HandleObject obj, const char *name, bool *resu } JS_PUBLIC_API(bool) -JS_DeleteUCProperty2(JSContext *cx, JSObject *objArg, const jschar *name, size_t namelen, +JS_DeleteUCProperty2(JSContext *cx, HandleObject obj, const jschar *name, size_t namelen, bool *result) { - RootedObject obj(cx, objArg); CHECK_REQUEST(cx); assertSameCompartment(cx, obj); JSAutoResolveFlags rf(cx, 0); diff --git a/js/src/jsapi.h b/js/src/jsapi.h index f4c15722991f..1ba124c47b0a 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3027,10 +3027,10 @@ JS_GetPropertyDescriptor(JSContext *cx, JSObject *obj, const char *name, unsigne JS::MutableHandle desc); extern JS_PUBLIC_API(bool) -JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, JS::MutableHandleValue vp); +JS_GetProperty(JSContext *cx, JS::HandleObject obj, const char *name, JS::MutableHandleValue vp); extern JS_PUBLIC_API(bool) -JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::MutableHandleValue vp); +JS_GetPropertyById(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp); extern JS_PUBLIC_API(bool) JS_ForwardGetPropertyTo(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject onBehalfOf, @@ -3082,7 +3082,7 @@ JS_LookupUCProperty(JSContext *cx, JS::HandleObject obj, JS::MutableHandleValue vp); extern JS_PUBLIC_API(bool) -JS_GetUCProperty(JSContext *cx, JSObject *obj, +JS_GetUCProperty(JSContext *cx, JS::HandleObject obj, const jschar *name, size_t namelen, JS::MutableHandleValue vp); @@ -3092,7 +3092,7 @@ JS_SetUCProperty(JSContext *cx, JS::HandleObject obj, JS::HandleValue v); extern JS_PUBLIC_API(bool) -JS_DeleteUCProperty2(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, +JS_DeleteUCProperty2(JSContext *cx, JS::HandleObject obj, const jschar *name, size_t namelen, bool *succeeded); extern JS_PUBLIC_API(JSObject *) @@ -3124,7 +3124,7 @@ extern JS_PUBLIC_API(bool) JS_LookupElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::MutableHandleValue vp); extern JS_PUBLIC_API(bool) -JS_GetElement(JSContext *cx, JSObject *obj, uint32_t index, JS::MutableHandleValue vp); +JS_GetElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::MutableHandleValue vp); extern JS_PUBLIC_API(bool) JS_ForwardGetElementTo(JSContext *cx, JSObject *obj, uint32_t index, JSObject *onBehalfOf, diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 5cd1fd41c43e..86c3aafced78 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -456,7 +456,8 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile) } nsCOMPtr file_holder; - rv = xpc->WrapNative(cx, entry->obj, file, + RootedObject entryObj(cx, entry->obj); + rv = xpc->WrapNative(cx, entryObj, file, NS_GET_IID(nsIFile), getter_AddRefs(file_holder)); @@ -472,7 +473,7 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile) JSCLAutoErrorReporterSetter aers(cx, xpc::SystemErrorReporter); RootedValue NSGetFactory_val(cx); - if (!JS_GetProperty(cx, entry->obj, "NSGetFactory", &NSGetFactory_val) || + if (!JS_GetProperty(cx, entryObj, "NSGetFactory", &NSGetFactory_val) || JSVAL_IS_VOID(NSGetFactory_val)) { return nullptr; } @@ -508,7 +509,7 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile) // Set the location information for the new global, so that tools like // about:memory may use that information if (!mReuseLoaderGlobal) { - xpc::SetLocationForGlobal(entry->obj, spec); + xpc::SetLocationForGlobal(entryObj, spec); } // The hash owns the ModuleEntry now, forget about it @@ -1265,7 +1266,8 @@ mozJSComponentLoader::ImportInto(const nsACString &aLocation, JSAutoCompartment ac(mContext, mod->obj); RootedValue symbols(mContext); - if (!JS_GetProperty(mContext, mod->obj, + RootedObject modObj(mContext, mod->obj); + if (!JS_GetProperty(mContext, modObj, "EXPORTED_SYMBOLS", &symbols)) { return ReportOnCaller(cxhelper, ERROR_NOT_PRESENT, PromiseFlatCString(aLocation).get()); @@ -1300,7 +1302,8 @@ mozJSComponentLoader::ImportInto(const nsACString &aLocation, PromiseFlatCString(aLocation).get(), i); } - if (!JS_GetPropertyById(mContext, mod->obj, symbolId, &value)) { + RootedObject modObj(mContext, mod->obj); + if (!JS_GetPropertyById(mContext, modObj, symbolId, &value)) { JSAutoByteString bytes(mContext, JSID_TO_STRING(symbolId)); if (!bytes) return NS_ERROR_FAILURE; diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index 883251c691eb..d8198606d800 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -188,7 +188,6 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx, RootedValue retval(cx); RootedObject retObj(cx); bool success = false; - jsid funid; RootedValue fun(cx); // Don't call the actual function on a content object. We'll determine @@ -208,7 +207,7 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx, return nullptr; // check upfront for the existence of the function property - funid = mRuntime->GetStringID(XPCJSRuntime::IDX_QUERY_INTERFACE); + HandleId funid = mRuntime->GetStringID(XPCJSRuntime::IDX_QUERY_INTERFACE); if (!JS_GetPropertyById(cx, jsobj, funid, &fun) || JSVAL_IS_PRIMITIVE(fun)) return nullptr; @@ -295,8 +294,8 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx, static bool GetNamedPropertyAsVariantRaw(XPCCallContext& ccx, - JSObject* aJSObj, - jsid aName, + HandleObject aJSObj, + HandleId aName, nsIVariant** aResult, nsresult* pErr) { @@ -1360,11 +1359,15 @@ pre_call_clean_up: if (param.IsRetval()) val = rval; - else if (JSVAL_IS_PRIMITIVE(argv[i]) || - !JS_GetPropertyById(cx, JSVAL_TO_OBJECT(argv[i]), - mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE), - &val)) + else if (argv[i].isPrimitive()) break; + else { + RootedObject obj(cx, &argv[i].toObject()); + if (!JS_GetPropertyById(cx, obj, + mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE), + &val)) + break; + } // setup allocator and/or iid @@ -1405,10 +1408,13 @@ pre_call_clean_up: if (param.IsRetval()) val = rval; - else if (!JS_GetPropertyById(cx, JSVAL_TO_OBJECT(argv[i]), - mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE), - &val)) - break; + else { + RootedObject obj(cx, &argv[i].toObject()); + if (!JS_GetPropertyById(cx, obj, + mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE), + &val)) + break; + } // setup allocator and/or iid diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index 18ae1d1270c0..ecfc0beca1ff 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -1854,18 +1854,18 @@ CallMethodHelper::GetOutParamSource(uint8_t paramIndex, MutableHandleValue srcp) MOZ_ASSERT(paramIndex < mArgc || paramInfo.IsOptional(), "Expected either enough arguments or an optional argument"); jsval arg = paramIndex < mArgc ? mArgv[paramIndex] : JSVAL_NULL; - if (paramIndex < mArgc && - (JSVAL_IS_PRIMITIVE(arg) || - !JS_GetPropertyById(mCallContext, - JSVAL_TO_OBJECT(arg), - mIdxValueId, - srcp))) { - // Explicitly passed in unusable value for out param. Note - // that if i >= mArgc we already know that |arg| is JSVAL_NULL, - // and that's ok. - ThrowBadParam(NS_ERROR_XPC_NEED_OUT_OBJECT, paramIndex, - mCallContext); - return false; + if (paramIndex < mArgc) { + RootedObject obj(mCallContext); + if (!arg.isPrimitive()) + obj = &arg.toObject(); + if (!obj || !JS_GetPropertyById(mCallContext, obj, mIdxValueId, srcp)) { + // Explicitly passed in unusable value for out param. Note + // that if i >= mArgc we already know that |arg| is JSVAL_NULL, + // and that's ok. + ThrowBadParam(NS_ERROR_XPC_NEED_OUT_OBJECT, paramIndex, + mCallContext); + return false; + } } } diff --git a/toolkit/components/ctypes/ctypes.cpp b/toolkit/components/ctypes/ctypes.cpp index 7fc181e75f51..c5cfcfeb0a93 100644 --- a/toolkit/components/ctypes/ctypes.cpp +++ b/toolkit/components/ctypes/ctypes.cpp @@ -65,7 +65,7 @@ Module::~Module() #include "xpc_map_end.h" static bool -SealObjectAndPrototype(JSContext* cx, JSObject* parent, const char* name) +SealObjectAndPrototype(JSContext* cx, JS::Handle parent, const char* name) { JS::Rooted prop(cx); if (!JS_GetProperty(cx, parent, name, &prop)) diff --git a/toolkit/components/perf/PerfMeasurement.cpp b/toolkit/components/perf/PerfMeasurement.cpp index 6cc51fe198f0..0c3b41056663 100644 --- a/toolkit/components/perf/PerfMeasurement.cpp +++ b/toolkit/components/perf/PerfMeasurement.cpp @@ -40,7 +40,7 @@ Module::~Module() #include "xpc_map_end.h" static bool -SealObjectAndPrototype(JSContext* cx, JSObject* parent, const char* name) +SealObjectAndPrototype(JSContext* cx, JS::Handle parent, const char* name) { JS::Rooted prop(cx); if (!JS_GetProperty(cx, parent, name, &prop)) diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index c2089eb83555..37dee5bf4965 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -293,7 +293,7 @@ GetJSValueAsURI(JSContext* aCtx, */ already_AddRefed GetURIFromJSObject(JSContext* aCtx, - JSObject* aObject, + JS::Handle aObject, const char* aProperty) { JS::Rooted uriVal(aCtx); @@ -350,7 +350,7 @@ GetJSValueAsString(JSContext* aCtx, */ void GetStringFromJSObject(JSContext* aCtx, - JSObject* aObject, + JS::Handle aObject, const char* aProperty, nsString& _string) { @@ -380,7 +380,7 @@ GetStringFromJSObject(JSContext* aCtx, template nsresult GetIntFromJSObject(JSContext* aCtx, - JSObject* aObject, + JS::Handle aObject, const char* aProperty, IntType* _int) {