Bug 842186 - Replace use of jsval with JS::Value in h and cpp files in the dom/bindings/ dom/plugins/ dom/src/ dom/activities/ directories. r=jwalden
authorJose Cortes <escozzia@gmail.com>
Tue, 02 Apr 2013 16:05:37 -0700
changeset 138792 4287ba54fd1654179cbe1470c869df297281ad90
parent 138791 d42d278b253534d4ad6b788ca50dc6a052b80cf4
child 138793 cc52fa570c12cd6c9f00ec4ba53e855b4c228700
push id350
push userbbajaj@mozilla.com
push dateMon, 29 Jul 2013 23:00:49 +0000
treeherdermozilla-release@064965b37dbd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs842186
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 842186 - Replace use of jsval with JS::Value in h and cpp files in the dom/bindings/ dom/plugins/ dom/src/ dom/activities/ directories. r=jwalden
dom/bindings/BindingUtils.cpp
dom/bindings/DOMJSProxyHandler.cpp
dom/bindings/DOMJSProxyHandler.h
dom/plugins/base/nsJSNPRuntime.cpp
dom/plugins/base/nsJSNPRuntime.h
dom/plugins/base/nsNPAPIPlugin.cpp
dom/src/geolocation/nsGeolocation.cpp
dom/src/json/nsJSON.cpp
dom/src/json/nsJSON.h
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -225,17 +225,18 @@ InterfaceObjectToString(JSContext* cx, u
 
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj) {
     JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CONVERT_TO,
                          "null", "object");
     return false;
   }
 
-  jsval v = js::GetFunctionNativeReserved(callee, TOSTRING_CLASS_RESERVED_SLOT);
+  JS::Value v = js::GetFunctionNativeReserved(callee,
+                                              TOSTRING_CLASS_RESERVED_SLOT);
   JSClass* clasp = static_cast<JSClass*>(JSVAL_TO_PRIVATE(v));
 
   v = js::GetFunctionNativeReserved(callee, TOSTRING_NAME_RESERVED_SLOT);
   JSString* jsname = static_cast<JSString*>(JSVAL_TO_STRING(v));
   size_t length;
   const jschar* name = JS_GetInternedStringCharsAndLength(jsname, &length);
 
   if (js::GetObjectJSClass(obj) != clasp) {
--- a/dom/bindings/DOMJSProxyHandler.cpp
+++ b/dom/bindings/DOMJSProxyHandler.cpp
@@ -249,17 +249,17 @@ DOMProxyHandler::AppendNamedPropertyIds(
   return true;
 }
 
 int32_t
 IdToInt32(JSContext* cx, jsid id)
 {
   JSAutoRequest ar(cx);
 
-  jsval idval;
+  JS::Value idval;
   double array_index;
   int32_t i;
   if (!::JS_IdToValue(cx, id, &idval) ||
       !::JS_ValueToNumber(cx, idval, &array_index) ||
       !::JS_DoubleIsInt32(array_index, &i)) {
     return -1;
   }
 
--- a/dom/bindings/DOMJSProxyHandler.h
+++ b/dom/bindings/DOMJSProxyHandler.h
@@ -108,17 +108,17 @@ FillPropertyDescriptor(JSPropertyDescrip
   desc->obj = obj;
   desc->attrs = (readonly ? JSPROP_READONLY : 0) | JSPROP_ENUMERATE;
   desc->getter = NULL;
   desc->setter = NULL;
   desc->shortid = 0;
 }
 
 inline void
-FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, jsval v, bool readonly)
+FillPropertyDescriptor(JSPropertyDescriptor* desc, JSObject* obj, JS::Value v, bool readonly)
 {
   desc->value = v;
   FillPropertyDescriptor(desc, obj, readonly);
 }
 
 JSObject*
 EnsureExpandoObject(JSContext* cx, JSObject* obj);
 
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -121,37 +121,37 @@ static JSBool
 NPObjWrapper_SetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict,
                          JSMutableHandleValue vp);
 
 static JSBool
 NPObjWrapper_GetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp);
 
 static JSBool
 NPObjWrapper_newEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
-                          jsval *statep, jsid *idp);
+                          JS::Value *statep, jsid *idp);
 
 static JSBool
 NPObjWrapper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
                         JSMutableHandleObject objp);
 
 static JSBool
 NPObjWrapper_Convert(JSContext *cx, JSHandleObject obj, JSType type, JSMutableHandleValue vp);
 
 static void
 NPObjWrapper_Finalize(JSFreeOp *fop, JSObject *obj);
 
 static JSBool
-NPObjWrapper_Call(JSContext *cx, unsigned argc, jsval *vp);
+NPObjWrapper_Call(JSContext *cx, unsigned argc, JS::Value *vp);
 
 static JSBool
-NPObjWrapper_Construct(JSContext *cx, unsigned argc, jsval *vp);
+NPObjWrapper_Construct(JSContext *cx, unsigned argc, JS::Value *vp);
 
 static JSBool
 CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject *npobj,
-                     jsid id, NPVariant* getPropertyResult, jsval *vp);
+                     jsid id, NPVariant* getPropertyResult, JS::Value *vp);
 
 JSClass sNPObjectJSWrapperClass =
   {
     NPRUNTIME_JSCLASS_NAME,
     JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_NEW_RESOLVE | JSCLASS_NEW_ENUMERATE,
     NPObjWrapper_AddProperty,
     NPObjWrapper_DelProperty,
     NPObjWrapper_GetProperty,
@@ -163,29 +163,29 @@ JSClass sNPObjectJSWrapperClass =
     nullptr,                                                /* checkAccess */
     NPObjWrapper_Call,
     nullptr,                                                /* hasInstance */
     NPObjWrapper_Construct
   };
 
 typedef struct NPObjectMemberPrivate {
     JSObject *npobjWrapper;
-    jsval fieldValue;
+    JS::Value fieldValue;
     NPIdentifier methodName;
     NPP   npp;
 } NPObjectMemberPrivate;
 
 static JSBool
 NPObjectMember_Convert(JSContext *cx, JSHandleObject obj, JSType type, JSMutableHandleValue vp);
 
 static void
 NPObjectMember_Finalize(JSFreeOp *fop, JSObject *obj);
 
 static JSBool
-NPObjectMember_Call(JSContext *cx, unsigned argc, jsval *vp);
+NPObjectMember_Call(JSContext *cx, unsigned argc, JS::Value *vp);
 
 static void
 NPObjectMember_Trace(JSTracer *trc, JSObject *obj);
 
 static JSClass sNPObjectMemberClass =
   {
     "NPObject Ambiguous Member class", JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS,
     JS_PropertyStub, JS_PropertyStub,
@@ -343,30 +343,30 @@ GetJSContext(NPP npp)
 }
 }
 }
 
 static NPP
 LookupNPP(NPObject *npobj);
 
 
-static jsval
+static JS::Value
 NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant)
 {
   switch (variant->type) {
   case NPVariantType_Void :
     return JSVAL_VOID;
   case NPVariantType_Null :
     return JSVAL_NULL;
   case NPVariantType_Bool :
     return BOOLEAN_TO_JSVAL(NPVARIANT_TO_BOOLEAN(*variant));
   case NPVariantType_Int32 :
     {
       // Don't use INT_TO_JSVAL directly to prevent bugs when dealing
-      // with ints larger than what fits in a integer jsval.
+      // with ints larger than what fits in a integer JS::Value.
       return ::JS_NumberValue(NPVARIANT_TO_INT32(*variant));
     }
   case NPVariantType_Double :
     {
       return ::JS_NumberValue(NPVARIANT_TO_DOUBLE(*variant));
     }
   case NPVariantType_String :
     {
@@ -404,17 +404,17 @@ NPVariantToJSVal(NPP npp, JSContext *cx,
   }
 
   NS_ERROR("Unable to convert NPVariant to jsval!");
 
   return JSVAL_VOID;
 }
 
 bool
-JSValToNPVariant(NPP npp, JSContext *cx, jsval val, NPVariant *variant)
+JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant)
 {
   NS_ASSERTION(npp, "Must have an NPP to wrap a jsval!");
 
   if (JSVAL_IS_PRIMITIVE(val)) {
     if (val == JSVAL_VOID) {
       VOID_TO_NPVARIANT(*variant);
     } else if (JSVAL_IS_NULL(val)) {
       NULL_TO_NPVARIANT(*variant);
@@ -582,17 +582,17 @@ nsJSObjWrapper::NP_Invalidate(NPObject *
     }
 
     // Forget our reference to the JSObject.
     jsnpobj->mJSObj = nullptr;
   }
 }
 
 static JSBool
-GetProperty(JSContext *cx, JSObject *obj, NPIdentifier id, jsval *rval)
+GetProperty(JSContext *cx, JSObject *obj, NPIdentifier id, JS::Value *rval)
 {
   NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
                "id must be either string or int!\n");
   return ::JS_GetPropertyById(cx, obj, NPIdentifierToJSId(id), rval);
 }
 
 // static
 bool
@@ -615,17 +615,17 @@ nsJSObjWrapper::NP_HasMethod(NPObject *n
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
 
   AutoCXPusher pusher(cx);
   JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   AutoJSExceptionReporter reporter(cx);
 
-  jsval v;
+  JS::Value v;
   JSBool ok = GetProperty(cx, npjsobj->mJSObj, id, &v);
 
   return ok && !JSVAL_IS_PRIMITIVE(v) &&
     ::JS_ObjectIsFunction(cx, JSVAL_TO_OBJECT(v));
 }
 
 static bool
 doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
@@ -643,48 +643,48 @@ doInvoke(NPObject *npobj, NPIdentifier m
 
     return false;
   }
 
   // Initialize *result
   VOID_TO_NPVARIANT(*result);
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
-  jsval fv;
+  JS::Value fv;
 
   AutoCXPusher pusher(cx);
   JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   AutoJSExceptionReporter reporter(cx);
 
   if (method != NPIdentifier_VOID) {
     if (!GetProperty(cx, npjsobj->mJSObj, method, &fv) ||
         ::JS_TypeOfValue(cx, fv) != JSTYPE_FUNCTION) {
       return false;
     }
   } else {
     fv = OBJECT_TO_JSVAL(npjsobj->mJSObj);
   }
 
-  jsval jsargs_buf[8];
-  jsval *jsargs = jsargs_buf;
-
-  if (argCount > (sizeof(jsargs_buf) / sizeof(jsval))) {
+  JS::Value jsargs_buf[8];
+  JS::Value *jsargs = jsargs_buf;
+
+  if (argCount > (sizeof(jsargs_buf) / sizeof(JS::Value))) {
     // Our stack buffer isn't large enough to hold all arguments,
     // malloc a buffer.
-    jsargs = (jsval *)PR_Malloc(argCount * sizeof(jsval));
+    jsargs = (JS::Value *)PR_Malloc(argCount * sizeof(JS::Value));
     if (!jsargs) {
       ::JS_ReportOutOfMemory(cx);
 
       return false;
     }
   }
 
-  jsval v;
+  JS::Value v;
   JSBool ok;
 
   {
     JS::AutoArrayRooter tvr(cx, 0, jsargs);
 
     // Convert args
     for (uint32_t i = 0; i < argCount; ++i) {
       jsargs[i] = NPVariantToJSVal(npp, cx, args + i);
@@ -793,17 +793,17 @@ nsJSObjWrapper::NP_GetProperty(NPObject 
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
 
   AutoCXPusher pusher(cx);
   JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
-  jsval v;
+  JS::Value v;
   return (GetProperty(cx, npjsobj->mJSObj, id, &v) &&
           JSValToNPVariant(npp, cx, v, result));
 }
 
 // static
 bool
 nsJSObjWrapper::NP_SetProperty(NPObject *npobj, NPIdentifier id,
                                const NPVariant *value)
@@ -825,17 +825,17 @@ nsJSObjWrapper::NP_SetProperty(NPObject 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
   JSBool ok = JS_FALSE;
 
   AutoCXPusher pusher(cx);
   JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
-  jsval v = NPVariantToJSVal(npp, cx, value);
+  JS::Value v = NPVariantToJSVal(npp, cx, value);
   JS::AutoValueRooter tvr(cx, v);
 
   NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
                "id must be either string or int!\n");
   ok = ::JS_SetPropertyById(cx, npjsobj->mJSObj, NPIdentifierToJSId(id), &v);
 
   // return ok == JS_TRUE to quiet down compiler warning, even if
   // return ok is what we really want.
@@ -861,17 +861,17 @@ nsJSObjWrapper::NP_RemoveProperty(NPObje
   }
 
   nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
   JSBool ok = JS_FALSE;
 
   AutoCXPusher pusher(cx);
   JSAutoRequest ar(cx);
   AutoJSExceptionReporter reporter(cx);
-  jsval deleted = JSVAL_FALSE;
+  JS::Value deleted = JSVAL_FALSE;
   JSAutoCompartment ac(cx, npjsobj->mJSObj);
 
   NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
                "id must be either string or int!\n");
   ok = ::JS_DeletePropertyById2(cx, npjsobj->mJSObj, NPIdentifierToJSId(id), &deleted);
   if (ok && deleted == JSVAL_TRUE) {
     // FIXME: See bug 425823, we shouldn't need to do this, and once
     // that bug is fixed we can remove this code.
@@ -929,17 +929,17 @@ nsJSObjWrapper::NP_Enumerate(NPObject *n
   *count = ida.length();
   *idarray = (NPIdentifier *)PR_Malloc(*count * sizeof(NPIdentifier));
   if (!*idarray) {
     ThrowJSException(cx, "Memory allocation failed for NPIdentifier!");
     return false;
   }
 
   for (uint32_t i = 0; i < *count; i++) {
-    jsval v;
+    JS::Value v;
     if (!JS_IdToValue(cx, ida[i], &v)) {
       PR_Free(*idarray);
       return false;
     }
 
     NPIdentifier id;
     if (JSVAL_IS_STRING(v)) {
       JSString *str = JS_InternJSString(cx, JSVAL_TO_STRING(v));
@@ -1370,18 +1370,18 @@ NPObjWrapper_GetProperty(JSContext *cx, 
     if (!ReportExceptionIfPending(cx))
       return JS_FALSE;
   }
 
   return JS_TRUE;
 }
 
 static JSBool
-CallNPMethodInternal(JSContext *cx, JSObject *obj, unsigned argc, jsval *argv,
-                     jsval *rval, bool ctorCall)
+CallNPMethodInternal(JSContext *cx, JSObject *obj, unsigned argc,
+                     JS::Value *argv, JS::Value *rval, bool ctorCall)
 {
   NPObject *npobj = GetNPObject(cx, obj);
 
   if (!npobj || !npobj->_class) {
     ThrowJSException(cx, "Bad NPObject as private data!");
 
     return JS_FALSE;
   }
@@ -1497,34 +1497,34 @@ CallNPMethodInternal(JSContext *cx, JSOb
 
   // *rval now owns the value, release our reference.
   _releasevariantvalue(&v);
 
   return ReportExceptionIfPending(cx);
 }
 
 static JSBool
-CallNPMethod(JSContext *cx, unsigned argc, jsval *vp)
+CallNPMethod(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   JSObject *obj = JS_THIS_OBJECT(cx, vp);
   if (!obj)
       return JS_FALSE;
 
   return CallNPMethodInternal(cx, obj, argc, JS_ARGV(cx, vp), vp, false);
 }
 
 struct NPObjectEnumerateState {
   uint32_t     index;
   uint32_t     length;
   NPIdentifier *value;
 };
 
 static JSBool
 NPObjWrapper_newEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op,
-                          jsval *statep, jsid *idp)
+                          JS::Value *statep, jsid *idp)
 {
   NPObject *npobj = GetNPObject(cx, obj);
   NPIdentifier *enum_value;
   uint32_t length;
   NPObjectEnumerateState *state;
 
   if (!npobj || !npobj->_class) {
     ThrowJSException(cx, "Bad NPObject as private data!");
@@ -1662,17 +1662,17 @@ NPObjWrapper_Convert(JSContext *cx, JSHa
   // be a problem, because the absence of either property, or the presence of
   // either property with a value that isn't callable, will cause that property
   // to simply be ignored.  But there is a problem in one specific case: Java,
   // specifically java.lang.Integer.  The Integer class has static valueOf
   // methods, none of which are nullary, so the JS-reflected method will behave
   // poorly when called with no arguments.  We work around this problem by
   // giving plugins a [[DefaultValue]] which uses only toString and not valueOf.
 
-  jsval v = JSVAL_VOID;
+  JS::Value v = JSVAL_VOID;
   if (!JS_GetProperty(cx, obj, "toString", &v))
     return false;
   if (!JSVAL_IS_PRIMITIVE(v) && JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(v))) {
     if (!JS_CallFunctionValue(cx, obj, v, 0, NULL, vp.address()))
       return false;
     if (JSVAL_IS_PRIMITIVE(vp))
       return true;
   }
@@ -1698,24 +1698,24 @@ NPObjWrapper_Finalize(JSFreeOp *fop, JSO
   }
 
   if (!sDelayedReleases)
     sDelayedReleases = new nsTArray<NPObject*>;
   sDelayedReleases->AppendElement(npobj);
 }
 
 static JSBool
-NPObjWrapper_Call(JSContext *cx, unsigned argc, jsval *vp)
+NPObjWrapper_Call(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   return CallNPMethodInternal(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)), argc,
                               JS_ARGV(cx, vp), vp, false);
 }
 
 static JSBool
-NPObjWrapper_Construct(JSContext *cx, unsigned argc, jsval *vp)
+NPObjWrapper_Construct(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   return CallNPMethodInternal(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)), argc,
                               JS_ARGV(cx, vp), vp, true);
 }
 
 class NPObjWrapperHashEntry : public PLDHashEntryHdr
 {
 public:
@@ -2009,17 +2009,17 @@ LookupNPP(NPObject *npobj)
 
   NS_ASSERTION(entry->mNpp, "Live NPObject entry w/o an NPP!");
 
   return entry->mNpp;
 }
 
 JSBool
 CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
-                     jsid id,  NPVariant* getPropertyResult, jsval *vp)
+                     jsid id,  NPVariant* getPropertyResult, JS::Value *vp)
 {
   NS_ENSURE_TRUE(vp, JS_FALSE);
 
   if (!npobj || !npobj->_class || !npobj->_class->getProperty ||
       !npobj->_class->invoke) {
     ThrowJSException(cx, "Bad NPObject");
 
     return JS_FALSE;
@@ -2042,17 +2042,17 @@ CreateNPObjectMember(NPP npp, JSContext 
 
   *vp = OBJECT_TO_JSVAL(memobj);
   ::JS_AddValueRoot(cx, vp);
 
   ::JS_SetPrivate(memobj, (void *)memberPrivate);
 
   NPIdentifier identifier = JSIdToNPIdentifier(id);
 
-  jsval fieldValue;
+  JS::Value fieldValue;
   NPVariant npv;
 
   if (getPropertyResult) {
     // Plugin has already handed us the value we want here.
     npv = *getPropertyResult;
   }
   else {
     VOID_TO_NPVARIANT(npv);
@@ -2130,17 +2130,17 @@ NPObjectMember_Finalize(JSFreeOp *fop, J
   memberPrivate = (NPObjectMemberPrivate *)::JS_GetPrivate(obj);
   if (!memberPrivate)
     return;
 
   PR_Free(memberPrivate);
 }
 
 static JSBool
-NPObjectMember_Call(JSContext *cx, unsigned argc, jsval *vp)
+NPObjectMember_Call(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   JSObject *memobj = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
   NS_ENSURE_TRUE(memobj, JS_FALSE);
 
   NPObjectMemberPrivate *memberPrivate =
     (NPObjectMemberPrivate *)::JS_GetInstancePrivate(cx, memobj,
                                                      &sNPObjectMemberClass,
                                                      JS_ARGV(cx, vp));
@@ -2166,17 +2166,17 @@ NPObjectMember_Call(JSContext *cx, unsig
       ThrowJSException(cx, "Out of memory!");
 
       return JS_FALSE;
     }
   }
 
   // Convert arguments
   uint32_t i;
-  jsval *argv = JS_ARGV(cx, vp);
+  JS::Value *argv = JS_ARGV(cx, vp);
   for (i = 0; i < argc; ++i) {
     if (!JSValToNPVariant(memberPrivate->npp, cx, argv[i], npargs + i)) {
       ThrowJSException(cx, "Error converting jsvals to NPVariants!");
 
       if (npargs != npargs_buf) {
         PR_Free(npargs);
       }
 
--- a/dom/plugins/base/nsJSNPRuntime.h
+++ b/dom/plugins/base/nsJSNPRuntime.h
@@ -70,12 +70,12 @@ public:
 class nsNPObjWrapper
 {
 public:
   static void OnDestroy(NPObject *npobj);
   static JSObject *GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj);
 };
 
 bool
-JSValToNPVariant(NPP npp, JSContext *cx, jsval val, NPVariant *variant);
+JSValToNPVariant(NPP npp, JSContext *cx, JS::Value val, NPVariant *variant);
 
 
 #endif // nsJSNPRuntime_h_
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -1520,19 +1520,19 @@ bool NP_CALLBACK
     return false;
   }
 
   obj = JS_ObjectToInnerObject(cx, obj);
   NS_ABORT_IF_FALSE(obj,
     "JS_ObjectToInnerObject should never return null with non-null input.");
 
   // Root obj and the rval (below).
-  jsval vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
+  JS::Value vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
   JS::AutoArrayRooter tvr(cx, ArrayLength(vec), vec);
-  jsval *rval = &vec[1];
+  JS::Value *rval = &vec[1];
 
   if (result) {
     // Initialize the out param to void
     VOID_TO_NPVARIANT(*result);
   }
 
   if (!script || !script->UTF8Length || !script->UTF8Characters) {
     // Nothing to evaluate.
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -85,17 +85,17 @@ public:
   GeolocationSettingsCallback() {
     MOZ_COUNT_CTOR(GeolocationSettingsCallback);
   }
 
   virtual ~GeolocationSettingsCallback() {
     MOZ_COUNT_DTOR(GeolocationSettingsCallback);
   }
 
-  NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult)
+  NS_IMETHOD Handle(const nsAString& aName, const JS::Value& aResult)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     // The geolocation is enabled by default:
     bool value = true;
     if (aResult.isBoolean()) {
       value = aResult.toBoolean();
     }
@@ -302,17 +302,17 @@ nsGeolocationRequest::nsGeolocationReque
 }
 
 nsGeolocationRequest::~nsGeolocationRequest()
 {
 }
 
 
 static mozilla::idl::GeoPositionOptions*
-OptionsFromJSOptions(JSContext* aCx, const jsval& aOptions, nsresult* aRv)
+OptionsFromJSOptions(JSContext* aCx, const JS::Value& aOptions, nsresult* aRv)
 {
   *aRv = NS_OK;
   nsAutoPtr<mozilla::idl::GeoPositionOptions> options(nullptr);
   if (aCx && !JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) {
     options = new mozilla::idl::GeoPositionOptions();
     nsresult rv = options->Init(aCx, &aOptions);
     if (NS_FAILED(rv)) {
       *aRv = rv;
@@ -1276,17 +1276,17 @@ nsGeolocation::Update(nsIDOMGeoPosition 
   for (uint32_t i = 0; i< mWatchingCallbacks.Length(); i++) {
     mWatchingCallbacks[i]->Update(aSomewhere, aIsBetter);
   }
 }
 
 NS_IMETHODIMP
 nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
                                   nsIDOMGeoPositionErrorCallback *errorCallback,
-                                  const jsval& jsoptions,
+                                  const JS::Value& jsoptions,
                                   JSContext* cx)
 {
   nsresult rv;
   nsAutoPtr<mozilla::idl::GeoPositionOptions> options(
       OptionsFromJSOptions(cx, jsoptions, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   return GetCurrentPosition(callback, errorCallback, options.forget());
 }
@@ -1348,17 +1348,17 @@ nsGeolocation::GetCurrentPositionReady(n
   NS_DispatchToMainThread(ev);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback,
                              nsIDOMGeoPositionErrorCallback *errorCallback,
-                             const jsval& jsoptions,
+                             const JS::Value& jsoptions,
                              JSContext* cx,
                              int32_t *_retval)
 {
   nsresult rv;
   nsAutoPtr<mozilla::idl::GeoPositionOptions> options(
       OptionsFromJSOptions(cx, jsoptions, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   return WatchPosition(callback, errorCallback, options.forget(), _retval);
--- a/dom/src/json/nsJSON.cpp
+++ b/dom/src/json/nsJSON.cpp
@@ -52,17 +52,18 @@ WarnDeprecatedMethod(DeprecationWarning 
                                          "DOM Core", nullptr,
                                          nsContentUtils::eDOM_PROPERTIES,
                                          warning == EncodeWarning
                                          ? "nsIJSONEncodeDeprecatedWarning"
                                          : "nsIJSONDecodeDeprecatedWarning");
 }
 
 NS_IMETHODIMP
-nsJSON::Encode(const JS::Value& aValue, JSContext* cx, uint8_t aArgc, nsAString &aJSON)
+nsJSON::Encode(const JS::Value& aValue, JSContext* cx, uint8_t aArgc,
+               nsAString &aJSON)
 {
   // This function should only be called from JS.
   nsresult rv = WarnDeprecatedMethod(EncodeWarning);
   if (NS_FAILED(rv))
     return rv;
 
   if (aArgc == 0) {
     aJSON.Truncate();
@@ -189,17 +190,18 @@ nsJSON::EncodeFromJSVal(JS::Value *value
 
   NS_ENSURE_TRUE(writer.DidWrite(), NS_ERROR_UNEXPECTED);
   writer.FlushBuffer();
   result.Assign(writer.mOutputString);
   return NS_OK;
 }
 
 nsresult
-nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue, nsJSONWriter* writer)
+nsJSON::EncodeInternal(JSContext* cx, const JS::Value& aValue,
+                       nsJSONWriter* writer)
 {
   JSAutoRequest ar(cx);
 
   // Backward compatibility:
   // nsIJSON does not allow to serialize anything other than objects
   if (!aValue.isObject()) {
     return NS_ERROR_INVALID_ARG;
   }
@@ -209,17 +211,17 @@ nsJSON::EncodeInternal(JSContext* cx, co
   JS::Value val = aValue;
 
   /* Backward compatibility:
    * Manually call toJSON if implemented by the object and check that
    * the result is still an object
    * Note: It is perfectly fine to not implement toJSON, so it is
    * perfectly fine for GetMethod to fail
    */
-  jsval toJSON;
+  JS::Value toJSON;
   if (JS_GetMethod(cx, obj, "toJSON", NULL, &toJSON) &&
       !JSVAL_IS_PRIMITIVE(toJSON) &&
       JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(toJSON))) {
     // If toJSON is implemented, it must not throw
     if (!JS_CallFunctionValue(cx, obj, toJSON, 0, NULL, &val)) {
       if (JS_IsExceptionPending(cx))
         // passing NS_OK will throw the pending exception
         return NS_OK;
@@ -383,17 +385,17 @@ nsJSON::Decode(const nsAString& json, JS
 NS_IMETHODIMP
 nsJSON::DecodeFromStream(nsIInputStream *aStream, int32_t aContentLength,
                          JSContext* cx, JS::Value* aRetval)
 {
   return DecodeInternal(cx, aStream, aContentLength, true, aRetval);
 }
 
 NS_IMETHODIMP
-nsJSON::DecodeToJSVal(const nsAString &str, JSContext *cx, jsval *result)
+nsJSON::DecodeToJSVal(const nsAString &str, JSContext *cx, JS::Value *result)
 {
   JSAutoRequest ar(cx);
 
   if (!JS_ParseJSON(cx, static_cast<const jschar*>(PromiseFlatString(str).get()),
                     str.Length(), result)) {
     return NS_ERROR_UNEXPECTED;
   }
 
@@ -492,17 +494,17 @@ nsJSON::LegacyDecode(const nsAString& js
 NS_IMETHODIMP
 nsJSON::LegacyDecodeFromStream(nsIInputStream *aStream, int32_t aContentLength,
                                JSContext* cx, JS::Value* aRetval)
 {
   return DecodeInternal(cx, aStream, aContentLength, true, aRetval, LEGACY);
 }
 
 NS_IMETHODIMP
-nsJSON::LegacyDecodeToJSVal(const nsAString &str, JSContext *cx, jsval *result)
+nsJSON::LegacyDecodeToJSVal(const nsAString &str, JSContext *cx, JS::Value *result)
 {
   JSAutoRequest ar(cx);
 
   JS::RootedValue reviver(cx, JS::NullValue()), value(cx);
 
   JS::StableCharPtr chars(static_cast<const jschar*>(PromiseFlatString(str).get()),
                           str.Length());
   if (!js::ParseJSONWithReviver(cx, chars, str.Length(), reviver,
@@ -522,17 +524,17 @@ NS_NewJSON(nsISupports* aOuter, REFNSIID
     return NS_ERROR_OUT_OF_MEMORY;
 
   NS_ADDREF(json);
   *aResult = json;
 
   return NS_OK;
 }
 
-nsJSONListener::nsJSONListener(JSContext *cx, jsval *rootVal,
+nsJSONListener::nsJSONListener(JSContext *cx, JS::Value *rootVal,
                                bool needsConverter,
                                DecodingMode mode /* = STRICT */)
   : mNeedsConverter(needsConverter), 
     mCx(cx),
     mRootVal(rootVal),
     mDecodingMode(mode)
 {
 }
--- a/dom/src/json/nsJSON.h
+++ b/dom/src/json/nsJSON.h
@@ -67,28 +67,28 @@ protected:
 };
 
 nsresult
 NS_NewJSON(nsISupports* aOuter, REFNSIID aIID, void** aResult);
 
 class nsJSONListener : public nsIStreamListener
 {
 public:
-  nsJSONListener(JSContext *cx, jsval *rootVal, bool needsConverter,
+  nsJSONListener(JSContext *cx, JS::Value *rootVal, bool needsConverter,
                  DecodingMode mode);
   virtual ~nsJSONListener();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
 
 protected:
   bool mNeedsConverter;
   JSContext *mCx;
-  jsval *mRootVal;
+  JS::Value *mRootVal;
   nsCOMPtr<nsIUnicodeDecoder> mDecoder;
   nsCString mSniffBuffer;
   nsTArray<PRUnichar> mBufferedChars;
   DecodingMode mDecodingMode;
   nsresult ProcessBytes(const char* aBuffer, uint32_t aByteLength);
   nsresult ConsumeConverted(const char* aBuffer, uint32_t aByteLength);
   nsresult Consume(const PRUnichar *data, uint32_t len);
 };