Bug 959787 - Handlify remaining JS APIs r=sfink r=bholley r=smaug

This commit is contained in:
Jon Coppeard 2014-04-02 15:28:03 +01:00
parent 4187310007
commit 3e811f8ee0
27 changed files with 101 additions and 100 deletions

View File

@ -3912,12 +3912,11 @@ nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
nsString& key = keys->ElementAt(0);
JSString *str =
JS_NewUCStringCopyN(cx, key.get(), key.Length());
JS::Rooted<JSString*> str(cx, JS_NewUCStringCopyN(cx, key.get(), key.Length()));
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
JS::Rooted<jsid> id(cx);
JS_ValueToId(cx, JS::StringValue(str), &id);
JS_StringToId(cx, str, &id);
*idp = id;
keys->RemoveElementAt(0);

View File

@ -2487,18 +2487,18 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
{
JSAutoCompartment ac(cx, mJSObject);
JS_SetParent(cx, mJSObject, newInnerWindow->mJSObject);
JS::Rooted<JSObject*> obj(cx, mJSObject);
JS::Rooted<JSObject*> newParent(cx, newInnerWindow->mJSObject);
JS_SetParent(cx, obj, newParent);
// Inform the nsJSContext, which is the canonical holder of the outer.
mContext->SetWindowProxy(obj);
NS_ASSERTION(!JS_IsExceptionPending(cx),
"We might overwrite a pending exception!");
XPCWrappedNativeScope* scope = xpc::GetObjectScope(mJSObject);
XPCWrappedNativeScope* scope = xpc::GetObjectScope(obj);
if (scope->mWaiverWrapperMap) {
scope->mWaiverWrapperMap->Reparent(cx, newInnerWindow->mJSObject);
scope->mWaiverWrapperMap->Reparent(cx, newParent);
}
}
}

View File

@ -2793,9 +2793,10 @@ NS_DOMWriteStructuredClone(JSContext* cx,
// Write the internals to the stream.
JSAutoCompartment ac(cx, dataArray);
JS::Rooted<JS::Value> arrayValue(cx, JS::ObjectValue(*dataArray));
return JS_WriteUint32Pair(writer, SCTAG_DOM_IMAGEDATA, 0) &&
JS_WriteUint32Pair(writer, width, height) &&
JS_WriteTypedArray(writer, JS::ObjectValue(*dataArray));
JS_WriteTypedArray(writer, arrayValue);
}
void

View File

@ -871,9 +871,10 @@ nsJSObjWrapper::NP_Enumerate(NPObject *npobj, NPIdentifier **idarray,
nsCxPusher pusher;
pusher.Push(cx);
AutoJSExceptionReporter reporter(cx);
JSAutoCompartment ac(cx, npjsobj->mJSObj);
JS::Rooted<JSObject*> jsobj(cx, npjsobj->mJSObj);
JSAutoCompartment ac(cx, jsobj);
JS::AutoIdArray ida(cx, JS_Enumerate(cx, npjsobj->mJSObj));
JS::AutoIdArray ida(cx, JS_Enumerate(cx, jsobj));
if (!ida) {
return false;
}

View File

@ -426,9 +426,10 @@ struct WorkerStructuredCloneCallbacks
// Write the internals to the stream.
JSAutoCompartment ac(aCx, dataArray);
JS::Rooted<JS::Value> arrayValue(aCx, JS::ObjectValue(*dataArray));
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_IMAGEDATA, 0) &&
JS_WriteUint32Pair(aWriter, width, height) &&
JS_WriteTypedArray(aWriter, JS::ObjectValue(*dataArray));
JS_WriteTypedArray(aWriter, arrayValue);
}
}

View File

@ -91,7 +91,7 @@ PostToNFC(JSContext* aCx,
void* data;
size_t size;
if (JSVAL_IS_STRING(v)) {
JSString* str = JSVAL_TO_STRING(v);
JS::Rooted<JSString*> str(aCx, v.toString());
if (!abs.encodeUtf8(aCx, str)) {
return false;
}

View File

@ -96,7 +96,7 @@ PostToRIL(JSContext *aCx,
void *data;
size_t size;
if (JSVAL_IS_STRING(v)) {
JSString *str = JSVAL_TO_STRING(v);
JS::Rooted<JSString*> str(aCx, v.toString());
if (!abs.encodeUtf8(aCx, str)) {
return false;
}

View File

@ -158,7 +158,7 @@ JavaScriptShared::convertGeckoStringToId(JSContext *cx, const nsString &from, JS
if (!str)
return false;
return JS_ValueToId(cx, StringValue(str), to);
return JS_StringToId(cx, str, to);
}
bool

View File

@ -542,9 +542,10 @@ jsd_EnableSingleStepInterrupts(JSDContext* jsdc, JSDScript* jsdscript, bool enab
{
bool rv;
AutoSafeJSContext cx;
JSAutoCompartment ac(cx, jsdscript->script);
JS::RootedScript script(cx, jsdscript->script);
JSAutoCompartment ac(cx, script);
JSD_LOCK();
rv = JS_SetSingleStepMode(cx, jsdscript->script, enable);
rv = JS_SetSingleStepMode(cx, script, enable);
JSD_UNLOCK();
return rv;
}

View File

@ -199,7 +199,7 @@ JS_SetDebugMode(JSContext *cx, bool debug);
/* Turn on single step mode. */
extern JS_PUBLIC_API(bool)
JS_SetSingleStepMode(JSContext *cx, JSScript *script, bool singleStep);
JS_SetSingleStepMode(JSContext *cx, JS::HandleScript script, bool singleStep);
/* The closure argument will be marked. */
extern JS_PUBLIC_API(bool)
@ -532,7 +532,7 @@ extern JS_PUBLIC_API(bool)
JS_DefineDebuggerObject(JSContext *cx, JS::HandleObject obj);
extern JS_PUBLIC_API(void)
JS_DumpPCCounts(JSContext *cx, JSScript *script);
JS_DumpPCCounts(JSContext *cx, JS::HandleScript script);
extern JS_PUBLIC_API(void)
JS_DumpCompartmentPCCounts(JSContext *cx);

View File

@ -158,6 +158,6 @@ JS_PUBLIC_API(bool)
JS_WriteBytes(JSStructuredCloneWriter *w, const void *p, size_t len);
JS_PUBLIC_API(bool)
JS_WriteTypedArray(JSStructuredCloneWriter *w, JS::Value v);
JS_WriteTypedArray(JSStructuredCloneWriter *w, JS::HandleValue v);
#endif /* js_StructuredClone_h */

View File

@ -258,7 +258,8 @@ BEGIN_TEST(testDebugger_singleStepThrow)
CallArgs args = CallArgsFromVp(argc, vp);
NonBuiltinScriptFrameIter iter(cx);
if (!JS_SetSingleStepMode(cx, iter.script(), true))
JS::RootedScript script(cx, iter.script());
if (!JS_SetSingleStepMode(cx, script, true))
return false;
args.rval().set(UndefinedValue());

View File

@ -2175,15 +2175,24 @@ JS_DestroyIdArray(JSContext *cx, JSIdArray *ida)
}
JS_PUBLIC_API(bool)
JS_ValueToId(JSContext *cx, jsval valueArg, MutableHandleId idp)
JS_ValueToId(JSContext *cx, HandleValue value, MutableHandleId idp)
{
RootedValue value(cx, valueArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, value);
return ValueToId<CanGC>(cx, value, idp);
}
JS_PUBLIC_API(bool)
JS_StringToId(JSContext *cx, HandleString string, MutableHandleId idp)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, string);
RootedValue value(cx, StringValue(string));
return ValueToId<CanGC>(cx, value, idp);
}
JS_PUBLIC_API(bool)
JS_IdToValue(JSContext *cx, jsid id, MutableHandleValue vp)
{
@ -2351,10 +2360,8 @@ JS_GetParent(JSObject *obj)
}
JS_PUBLIC_API(bool)
JS_SetParent(JSContext *cx, JSObject *objArg, JSObject *parentArg)
JS_SetParent(JSContext *cx, HandleObject obj, HandleObject parent)
{
RootedObject obj(cx, objArg);
RootedObject parent(cx, parentArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
JS_ASSERT(!obj->is<ScopeObject>());
@ -3310,11 +3317,9 @@ JS_GetElement(JSContext *cx, HandleObject objArg, uint32_t index, MutableHandleV
}
JS_PUBLIC_API(bool)
JS_ForwardGetElementTo(JSContext *cx, JSObject *objArg, uint32_t index, JSObject *onBehalfOfArg,
JS_ForwardGetElementTo(JSContext *cx, HandleObject obj, uint32_t index, HandleObject onBehalfOf,
MutableHandleValue vp)
{
RootedObject obj(cx, objArg);
RootedObject onBehalfOf(cx, onBehalfOfArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -3512,9 +3517,8 @@ LastConfigurableShape(JSObject *obj)
}
JS_PUBLIC_API(void)
JS_ClearNonGlobalObject(JSContext *cx, JSObject *objArg)
JS_ClearNonGlobalObject(JSContext *cx, HandleObject obj)
{
RootedObject obj(cx, objArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -3563,9 +3567,8 @@ JS_SetAllNonReservedSlotsToUndefined(JSContext *cx, JSObject *objArg)
}
JS_PUBLIC_API(JSIdArray *)
JS_Enumerate(JSContext *cx, JSObject *objArg)
JS_Enumerate(JSContext *cx, HandleObject obj)
{
RootedObject obj(cx, objArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj);
@ -4978,9 +4981,8 @@ JS::Call(JSContext *cx, HandleValue thisv, HandleValue fval, const JS::HandleVal
}
JS_PUBLIC_API(JSObject *)
JS_New(JSContext *cx, JSObject *ctorArg, const JS::HandleValueArray& inputArgs)
JS_New(JSContext *cx, HandleObject ctor, const JS::HandleValueArray& inputArgs)
{
RootedObject ctor(cx, ctorArg);
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, ctor, inputArgs);
@ -5387,7 +5389,7 @@ JS_EncodeString(JSContext *cx, JSString *str)
}
JS_PUBLIC_API(char *)
JS_EncodeStringToUTF8(JSContext *cx, JSString *str)
JS_EncodeStringToUTF8(JSContext *cx, HandleString str)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);

View File

@ -2273,7 +2273,10 @@ class AutoIdArray : private AutoGCRooter
} /* namespace JS */
extern JS_PUBLIC_API(bool)
JS_ValueToId(JSContext *cx, jsval v, JS::MutableHandle<jsid> idp);
JS_ValueToId(JSContext *cx, JS::HandleValue v, JS::MutableHandleId idp);
extern JS_PUBLIC_API(bool)
JS_StringToId(JSContext *cx, JS::HandleString s, JS::MutableHandleId idp);
extern JS_PUBLIC_API(bool)
JS_IdToValue(JSContext *cx, jsid id, JS::MutableHandle<JS::Value> vp);
@ -2520,7 +2523,7 @@ extern JS_PUBLIC_API(JSObject *)
JS_GetParent(JSObject *obj);
extern JS_PUBLIC_API(bool)
JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent);
JS_SetParent(JSContext *cx, JS::HandleObject obj, JS::HandleObject parent);
extern JS_PUBLIC_API(JSObject *)
JS_GetConstructor(JSContext *cx, JS::Handle<JSObject*> proto);
@ -2722,7 +2725,7 @@ extern JS_PUBLIC_API(bool)
JS_PreventExtensions(JSContext *cx, JS::HandleObject obj);
extern JS_PUBLIC_API(JSObject *)
JS_New(JSContext *cx, JSObject *ctor, const JS::HandleValueArray& args);
JS_New(JSContext *cx, JS::HandleObject ctor, const JS::HandleValueArray& args);
extern JS_PUBLIC_API(JSObject *)
JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, const JSClass *clasp,
@ -3037,8 +3040,8 @@ extern JS_PUBLIC_API(bool)
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,
JS::MutableHandleValue vp);
JS_ForwardGetElementTo(JSContext *cx, JS::HandleObject obj, uint32_t index,
JS::HandleObject onBehalfOf, JS::MutableHandleValue vp);
extern JS_PUBLIC_API(bool)
JS_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index, JS::HandleValue v);
@ -3069,7 +3072,7 @@ JS_DeleteElement2(JSContext *cx, JS::HandleObject obj, uint32_t index, bool *suc
* assign undefined to all writable data properties.
*/
JS_PUBLIC_API(void)
JS_ClearNonGlobalObject(JSContext *cx, JSObject *objArg);
JS_ClearNonGlobalObject(JSContext *cx, JS::HandleObject obj);
/*
* Assign 'undefined' to all of the object's non-reserved slots. Note: this is
@ -3113,7 +3116,7 @@ extern JS_PUBLIC_API(void *)
JS_ReallocateArrayBufferContents(JSContext *cx, uint32_t nbytes, void *oldContents, uint32_t oldNbytes);
extern JS_PUBLIC_API(JSIdArray *)
JS_Enumerate(JSContext *cx, JSObject *obj);
JS_Enumerate(JSContext *cx, JS::HandleObject obj);
/*
* Create an object to iterate over enumerable properties of obj, in arbitrary
@ -4055,7 +4058,7 @@ JS_EncodeString(JSContext *cx, JSString *str);
* Same behavior as JS_EncodeString(), but encode into UTF-8 string
*/
JS_PUBLIC_API(char *)
JS_EncodeStringToUTF8(JSContext *cx, JSString *str);
JS_EncodeStringToUTF8(JSContext *cx, JS::HandleString str);
/*
* Get number of bytes in the string encoding (without accounting for a
@ -4112,7 +4115,7 @@ class JSAutoByteString
char *encodeLatin1(js::ExclusiveContext *cx, JSString *str);
char *encodeUtf8(JSContext *cx, JSString *str) {
char *encodeUtf8(JSContext *cx, JS::HandleString str) {
JS_ASSERT(!mBytes);
JS_ASSERT(cx);
mBytes = JS_EncodeStringToUTF8(cx, str);

View File

@ -683,11 +683,9 @@ JS_SetAccumulateTelemetryCallback(JSRuntime *rt, JSAccumulateTelemetryDataCallba
}
JS_FRIEND_API(JSObject *)
JS_CloneObject(JSContext *cx, JSObject *obj_, JSObject *proto_, JSObject *parent_)
JS_CloneObject(JSContext *cx, HandleObject obj, HandleObject protoArg, HandleObject parent)
{
RootedObject obj(cx, obj_);
Rooted<js::TaggedProto> proto(cx, proto_);
RootedObject parent(cx, parent_);
Rooted<js::TaggedProto> proto(cx, protoArg.get());
return CloneObject(cx, obj, proto, parent);
}

View File

@ -133,7 +133,8 @@ extern JS_FRIEND_API(JSObject *)
JS_ObjectToOuterObject(JSContext *cx, JS::HandleObject obj);
extern JS_FRIEND_API(JSObject *)
JS_CloneObject(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent);
JS_CloneObject(JSContext *cx, JS::HandleObject obj, JS::HandleObject proto,
JS::HandleObject parent);
extern JS_FRIEND_API(JSString *)
JS_BasicObjectToString(JSContext *cx, JS::HandleObject obj);
@ -1416,7 +1417,7 @@ JS_GetFloat64ArrayData(JSObject *obj);
* as the object is live.
*/
extern JS_FRIEND_API(uint8_t *)
JS_GetStableArrayBufferData(JSContext *cx, JSObject *obj);
JS_GetStableArrayBufferData(JSContext *cx, JS::HandleObject obj);
/*
* Same as above, but for any kind of ArrayBufferView. Prefer the type-specific

View File

@ -872,7 +872,7 @@ ParseCompileOptions(JSContext *cx, CompileOptions &options, HandleObject opts,
if (!JS_GetProperty(cx, opts, "sourcePolicy", &v))
return false;
if (!v.isUndefined()) {
JSString *s = ToString(cx, v);
RootedString s(cx, ToString(cx, v));
if (!s)
return false;

View File

@ -955,9 +955,9 @@ JS_GetArrayBufferData(JSObject *obj)
}
JS_FRIEND_API(uint8_t *)
JS_GetStableArrayBufferData(JSContext *cx, JSObject *obj)
JS_GetStableArrayBufferData(JSContext *cx, HandleObject objArg)
{
obj = CheckedUnwrap(obj);
JSObject *obj = CheckedUnwrap(objArg);
if (!obj)
return nullptr;

View File

@ -211,9 +211,8 @@ CheckDebugMode(JSContext *cx)
}
JS_PUBLIC_API(bool)
JS_SetSingleStepMode(JSContext *cx, JSScript *scriptArg, bool singleStep)
JS_SetSingleStepMode(JSContext *cx, HandleScript script, bool singleStep)
{
RootedScript script(cx, scriptArg);
assertSameCompartment(cx, script);
if (!CheckDebugMode(cx))
@ -819,9 +818,8 @@ JS_GetGlobalDebugHooks(JSRuntime *rt)
/************************************************************************/
extern JS_PUBLIC_API(void)
JS_DumpPCCounts(JSContext *cx, JSScript *scriptArg)
JS_DumpPCCounts(JSContext *cx, HandleScript script)
{
Rooted<JSScript*> script(cx, scriptArg);
JS_ASSERT(script->hasScriptCounts());
Sprinter sprinter(cx);
@ -838,7 +836,7 @@ JS_PUBLIC_API(void)
JS_DumpCompartmentPCCounts(JSContext *cx)
{
for (CellIter i(cx->zone(), gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
JSScript *script = i.get<JSScript>();
RootedScript script(cx, i.get<JSScript>());
if (script->compartment() != cx->compartment())
continue;

View File

@ -300,7 +300,7 @@ struct JSStructuredCloneWriter {
JS::RootedValue transferable;
JS::AutoObjectVector transferableObjects;
friend bool JS_WriteTypedArray(JSStructuredCloneWriter *w, JS::Value v);
friend bool JS_WriteTypedArray(JSStructuredCloneWriter *w, JS::HandleValue v);
};
JS_FRIEND_API(uint64_t)
@ -1840,7 +1840,7 @@ JS_WriteBytes(JSStructuredCloneWriter *w, const void *p, size_t len)
}
JS_PUBLIC_API(bool)
JS_WriteTypedArray(JSStructuredCloneWriter *w, JS::Value v)
JS_WriteTypedArray(JSStructuredCloneWriter *w, JS::HandleValue v)
{
JS_ASSERT(v.isObject());
assertSameCompartment(w->context(), v);
@ -1856,4 +1856,3 @@ JS_WriteTypedArray(JSStructuredCloneWriter *w, JS::Value v)
}
return w->writeTypedArray(obj);
}

View File

@ -177,7 +177,7 @@ SandboxImport(JSContext *cx, unsigned argc, Value *vp)
}
RootedId id(cx);
if (!JS_ValueToId(cx, StringValue(funname), &id))
if (!JS_StringToId(cx, funname, &id))
return false;
// We need to resolve the this object, because this function is used
@ -299,9 +299,7 @@ ExportFunction(JSContext *cx, HandleValue vfunction, HandleValue vscope, HandleV
if (!funName)
funName = JS_InternString(cx, "");
RootedValue vname(cx);
vname.setString(funName);
if (!JS_ValueToId(cx, vname, &id))
if (!JS_StringToId(cx, funName, &id))
return false;
}
MOZ_ASSERT(JSID_IS_STRING(id));
@ -1841,7 +1839,8 @@ xpc::NewFunctionForwarder(JSContext *cx, HandleObject callable, bool doclone,
MutableHandleValue vp)
{
RootedId emptyId(cx);
if (!JS_ValueToId(cx, JS_GetEmptyStringValue(cx), &emptyId))
RootedValue emptyStringValue(cx, JS_GetEmptyStringValue(cx));
if (!JS_ValueToId(cx, emptyStringValue, &emptyId))
return false;
return NewFunctionForwarder(cx, emptyId, callable, doclone, vp);

View File

@ -265,15 +265,15 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
*statep = UINT_TO_JSVAL(idx + 1);
if (interface) {
JSString* idstr;
const char* name;
JS::Rooted<jsid> id(cx);
if (NS_SUCCEEDED(interface->GetNameShared(&name)) && name &&
nullptr != (idstr = JS_NewStringCopyZ(cx, name)) &&
JS_ValueToId(cx, StringValue(idstr), &id)) {
*idp = id;
return NS_OK;
RootedId id(cx);
if (NS_SUCCEEDED(interface->GetNameShared(&name)) && name) {
RootedString idstr(cx, JS_NewStringCopyZ(cx, name));
if (idstr && JS_StringToId(cx, idstr, &id)) {
*idp = id;
return NS_OK;
}
}
}
// fall through
@ -514,13 +514,12 @@ nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
if (interface) {
nsIID const *iid;
char idstr[NSID_LENGTH];
JSString* jsstr;
if (NS_SUCCEEDED(interface->GetIIDShared(&iid))) {
iid->ToProvidedString(idstr);
jsstr = JS_NewStringCopyZ(cx, idstr);
JS::Rooted<jsid> id(cx);
if (jsstr && JS_ValueToId(cx, StringValue(jsstr), &id)) {
RootedString jsstr(cx, JS_NewStringCopyZ(cx, idstr));
RootedId id(cx);
if (jsstr && JS_StringToId(cx, jsstr, &id)) {
*idp = id;
return NS_OK;
}
@ -774,10 +773,9 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
if (holder) {
nsAutoCString name;
if (NS_SUCCEEDED(holder->GetData(name))) {
JSString* idstr = JS_NewStringCopyN(cx, name.get(), name.Length());
JS::Rooted<jsid> id(cx);
if (idstr &&
JS_ValueToId(cx, StringValue(idstr), &id)) {
RootedString idstr(cx, JS_NewStringCopyN(cx, name.get(), name.Length()));
RootedId id(cx);
if (idstr && JS_StringToId(cx, idstr, &id)) {
*idp = id;
return NS_OK;
}
@ -1015,11 +1013,10 @@ nsXPCComponents_ClassesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
if (holder) {
char* name;
if (NS_SUCCEEDED(holder->ToString(&name)) && name) {
JSString* idstr = JS_NewStringCopyZ(cx, name);
RootedString idstr(cx, JS_NewStringCopyZ(cx, name));
nsMemory::Free(name);
JS::Rooted<jsid> id(cx);
if (idstr &&
JS_ValueToId(cx, StringValue(idstr), &id)) {
RootedId id(cx);
if (idstr && JS_StringToId(cx, idstr, &id)) {
*idp = id;
return NS_OK;
}
@ -1270,9 +1267,9 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
const char* name;
iter = (const void**) JSVAL_TO_PRIVATE(*statep);
if (nsXPCException::IterateNSResults(nullptr, &name, nullptr, iter)) {
JSString* idstr = JS_NewStringCopyZ(cx, name);
JS::Rooted<jsid> id(cx);
if (idstr && JS_ValueToId(cx, StringValue(idstr), &id)) {
RootedString idstr(cx, JS_NewStringCopyZ(cx, name));
JS::RootedId id(cx);
if (idstr && JS_StringToId(cx, idstr, &id)) {
*idp = id;
return NS_OK;
}
@ -2417,7 +2414,7 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
RootedString str(cx, ToString(cx, args[1]));
RootedId id(cx);
if (!str || !JS_ValueToId(cx, StringValue(str), &id))
if (!str || !JS_StringToId(cx, str, &id))
return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
RootedValue val(cx);
@ -2465,7 +2462,7 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative *wrapper,
RootedString str(cx, ToString(cx, args[0]));
RootedId id(cx);
if (!str || !JS_ValueToId(cx, StringValue(str), &id))
if (!str || !JS_StringToId(cx, str, &id))
return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
RootedValue val(cx);

View File

@ -672,12 +672,13 @@ public:
* We reparent wrappers that have as their parent an inner window
* whose outer has the new inner window as its current inner.
*/
JS::RootedObject parent(aCx, JS_GetParent(e.front().value()));
JS::RootedObject wrapper(aCx, e.front().value());
JS::RootedObject parent(aCx, JS_GetParent(wrapper));
JS::RootedObject outer(aCx, JS_ObjectToOuterObject(aCx, parent));
if (outer) {
JSObject *inner = JS_ObjectToInnerObject(aCx, outer);
if (inner == aNewInner && inner != parent)
JS_SetParent(aCx, e.front().value(), aNewInner);
JS_SetParent(aCx, wrapper, aNewInner);
} else {
JS_ClearPendingException(aCx);
}

View File

@ -601,7 +601,7 @@ PropertyOpForwarder(JSContext *cx, unsigned argc, jsval *vp)
if (!obj)
return false;
jsval v = js::GetFunctionNativeReserved(callee, 0);
JS::RootedValue v(cx, js::GetFunctionNativeReserved(callee, 0));
JSObject *ptrobj = JSVAL_TO_OBJECT(v);
Op *popp = static_cast<Op *>(JS_GetPrivate(ptrobj));

View File

@ -1160,9 +1160,8 @@ XPCWrappedNative::ReparentWrapperIfFound(XPCWrappedNativeScope* aOldScope,
// ending up with two reflectors pointing to the same WN. Other than
// that, the objects we create will just go away if we return early.
RootedObject newobj(cx, JS_CloneObject(cx, flat,
newProto->GetJSProtoObject(),
aNewParent));
RootedObject proto(cx, newProto->GetJSProtoObject());
RootedObject newobj(cx, JS_CloneObject(cx, flat, proto, aNewParent));
if (!newobj)
return NS_ERROR_FAILURE;

View File

@ -123,13 +123,13 @@ StatementParams::NewEnumerate(nsIXPConnectWrappedNative *aWrapper,
NS_ENSURE_SUCCESS(rv, rv);
// But drop the first character, which is going to be a ':'.
JSString *jsname = ::JS_NewStringCopyN(aCtx, &(name.get()[1]),
name.Length() - 1);
JS::RootedString jsname(aCtx, ::JS_NewStringCopyN(aCtx, &(name.get()[1]),
name.Length() - 1));
NS_ENSURE_TRUE(jsname, NS_ERROR_OUT_OF_MEMORY);
// Set our name.
JS::Rooted<jsid> id(aCtx);
if (!::JS_ValueToId(aCtx, JS::StringValue(jsname), &id)) {
if (!::JS_StringToId(aCtx, jsname, &id)) {
*_retval = false;
return NS_OK;
}

View File

@ -752,7 +752,7 @@ nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength, JS::Handle<JS::Value> aBu
JS_GetArrayBufferByteLength(buffer) < aLength) {
return NS_ERROR_FAILURE;
}
uint8_t* data = JS_GetStableArrayBufferData(cx, &aBuffer.toObject());
uint8_t* data = JS_GetStableArrayBufferData(cx, buffer);
if (!data) {
return NS_ERROR_FAILURE;
}