Bug 842186 - Replace use of jsval with JS::Value in dom/base. r=jwalden
authorJose Cortes <escozzia@gmail.com>
Thu, 11 Apr 2013 18:52:10 -0400
changeset 128718 9a6b56a3f24321dc656d91b817a5027864257a76
parent 128717 5e0c8f29b023d6d4ac3c936780caa849924a0421
child 128719 f21835504604e4d30c55bf906e4567c69c9f68a0
push id26464
push userjwalden@mit.edu
push dateSun, 14 Apr 2013 01:04:47 +0000
treeherdermozilla-inbound@9a6b56a3f243 [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 dom/base. r=jwalden From 1a684ed61615d32965201e55335478d5f403ac4a Mon Sep 17 00:00:00 2001 cpp files in the dom/base/ directory. r=jwalden --- dom/base/Crypto.cpp | 3 +- dom/base/DOMRequest.cpp | 12 +++--- dom/base/DOMRequest.h | 4 +- dom/base/Navigator.cpp | 10 ++--- dom/base/nsDOMJSUtils.h | 6 +-- dom/base/nsDOMWindowUtils.cpp | 20 ++++----- dom/base/nsGlobalWindow.cpp | 24 +++++------ dom/base/nsIJSNativeInitializer.h | 4 +- dom/base/nsJSEnvironment.cpp | 73 +++++++++++++++++---------------- dom/base/nsJSEnvironment.h | 8 ++-- dom/base/nsJSTimeoutHandler.cpp | 4 +- dom/base/nsJSUtils.h | 2 +- dom/base/nsStructuredCloneContainer.cpp | 10 ++--- 13 files changed, 91 insertions(+), 89 deletions(-)
dom/base/Crypto.cpp
dom/base/DOMRequest.cpp
dom/base/DOMRequest.h
dom/base/Navigator.cpp
dom/base/nsDOMJSUtils.h
dom/base/nsDOMWindowUtils.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsIJSNativeInitializer.h
dom/base/nsJSEnvironment.cpp
dom/base/nsJSEnvironment.h
dom/base/nsJSTimeoutHandler.cpp
dom/base/nsJSUtils.h
dom/base/nsStructuredCloneContainer.cpp
--- a/dom/base/Crypto.cpp
+++ b/dom/base/Crypto.cpp
@@ -35,17 +35,18 @@ Crypto::Crypto()
 }
 
 Crypto::~Crypto()
 {
   MOZ_COUNT_DTOR(Crypto);
 }
 
 NS_IMETHODIMP
-Crypto::GetRandomValues(const jsval& aData, JSContext *cx, jsval* _retval)
+Crypto::GetRandomValues(const JS::Value& aData, JSContext *cx,
+                        JS::Value* _retval)
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(), "Called on the wrong thread");
 
   // Make sure this is a JavaScript object
   if (!aData.isObject()) {
     return NS_ERROR_DOM_NOT_OBJECT_ERR;
   }
 
--- a/dom/base/DOMRequest.cpp
+++ b/dom/base/DOMRequest.cpp
@@ -96,31 +96,31 @@ DOMRequest::GetReadyState(nsAString& aRe
     default:
       MOZ_NOT_REACHED("Unrecognized readyState.");
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-DOMRequest::GetResult(jsval* aResult)
+DOMRequest::GetResult(JS::Value* aResult)
 {
   *aResult = Result();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DOMRequest::GetError(nsIDOMDOMError** aError)
 {
   NS_IF_ADDREF(*aError = GetError());
   return NS_OK;
 }
 
 void
-DOMRequest::FireSuccess(jsval aResult)
+DOMRequest::FireSuccess(JS::Value aResult)
 {
   NS_ASSERTION(!mDone, "mDone shouldn't have been set to true already!");
   NS_ASSERTION(!mError, "mError shouldn't have been set!");
   NS_ASSERTION(mResult == JSVAL_VOID, "mResult shouldn't have been set!");
 
   mDone = true;
   if (JSVAL_IS_GCTHING(aResult)) {
     RootResultVal();
@@ -214,17 +214,17 @@ DOMRequestService::CreateCursor(nsIDOMWi
                                 nsIDOMDOMCursor** aCursor) {
   NS_ADDREF(*aCursor = new DOMCursor(aWindow, aCallback));
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DOMRequestService::FireSuccess(nsIDOMDOMRequest* aRequest,
-                               const jsval& aResult)
+                               const JS::Value& aResult)
 {
   NS_ENSURE_STATE(aRequest);
   static_cast<DOMRequest*>(aRequest)->FireSuccess(aResult);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -236,17 +236,17 @@ DOMRequestService::FireError(nsIDOMDOMRe
 
   return NS_OK;
 }
 
 class FireSuccessAsyncTask : public nsRunnable
 {
 public:
   FireSuccessAsyncTask(DOMRequest* aRequest,
-                       const jsval& aResult) :
+                       const JS::Value& aResult) :
     mReq(aRequest),
     mResult(aResult)
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     nsresult rv;
     nsIScriptContext* sc = mReq->GetContextForEventHandlers(&rv);
     AutoPushJSContext cx(sc->GetNativeContext());
     MOZ_ASSERT(NS_SUCCEEDED(rv) && cx);
@@ -271,17 +271,17 @@ public:
 
     // We need to build a new request, otherwise we assert since there won't be
     // a request available yet.
     JSAutoRequest ar(cx);
     JS_RemoveValueRoot(cx, &mResult);
   }
 private:
   nsRefPtr<DOMRequest> mReq;
-  jsval mResult;
+  JS::Value mResult;
 };
 
 class FireErrorAsyncTask : public nsRunnable
 {
 public:
   FireErrorAsyncTask(DOMRequest* aRequest,
                      const nsAString& aError) :
     mReq(aRequest),
@@ -297,17 +297,17 @@ public:
   }
 private:
   nsRefPtr<DOMRequest> mReq;
   nsString mError;
 };
 
 NS_IMETHODIMP
 DOMRequestService::FireSuccessAsync(nsIDOMDOMRequest* aRequest,
-                                    const jsval& aResult)
+                                    const JS::Value& aResult)
 {
   NS_ENSURE_STATE(aRequest);
   nsCOMPtr<nsIRunnable> asyncTask =
     new FireSuccessAsyncTask(static_cast<DOMRequest*>(aRequest), aResult);
   if (NS_FAILED(NS_DispatchToMainThread(asyncTask))) {
     NS_WARNING("Failed to dispatch to main thread!");
     return NS_ERROR_FAILURE;
   }
--- a/dom/base/DOMRequest.h
+++ b/dom/base/DOMRequest.h
@@ -17,17 +17,17 @@
 
 namespace mozilla {
 namespace dom {
 
 class DOMRequest : public nsDOMEventTargetHelper,
                    public nsIDOMDOMRequest
 {
 protected:
-  jsval mResult;
+  JS::Value mResult;
   nsCOMPtr<nsIDOMDOMError> mError;
   bool mDone;
   bool mRooted;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMDOMREQUEST
   NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
@@ -64,17 +64,17 @@ public:
                  "Error should be null when pending");
     return mError;
   }
 
   IMPL_EVENT_HANDLER(success)
   IMPL_EVENT_HANDLER(error)
 
 
-  void FireSuccess(jsval aResult);
+  void FireSuccess(JS::Value aResult);
   void FireError(const nsAString& aError);
   void FireError(nsresult aError);
 
   DOMRequest(nsIDOMWindow* aWindow);
   DOMRequest();
 
   virtual ~DOMRequest()
   {
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -692,23 +692,23 @@ VibrateWindowListener::RemoveListener()
     return;
   }
   NS_NAMED_LITERAL_STRING(visibilitychange, "visibilitychange");
   target->RemoveSystemEventListener(visibilitychange, this,
                                     true /* use capture */);
 }
 
 /**
- * Converts a jsval into a vibration duration, checking that the duration is in
+ * Converts a JS::Value into a vibration duration, checking that the duration is in
  * bounds (non-negative and not larger than sMaxVibrateMS).
  *
  * Returns true on success, false on failure.
  */
 bool
-GetVibrationDurationFromJsval(const jsval& aJSVal, JSContext* cx,
+GetVibrationDurationFromJsval(const JS::Value& aJSVal, JSContext* cx,
                               int32_t* aOut)
 {
   return JS_ValueToInt32(cx, aJSVal, aOut) &&
          *aOut >= 0 && static_cast<uint32_t>(*aOut) <= sMaxVibrateMS;
 }
 
 } // anonymous namespace
 
@@ -750,17 +750,17 @@ Navigator::RemoveIdleObserver(nsIIdleObs
   NS_ENSURE_TRUE(win, NS_ERROR_UNEXPECTED);
   if (NS_FAILED(win->UnregisterIdleObserver(aIdleObserver))) {
     NS_WARNING("Failed to remove idle observer.");
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-Navigator::Vibrate(const jsval& aPattern, JSContext* cx)
+Navigator::Vibrate(const JS::Value& aPattern, JSContext* cx)
 {
   nsCOMPtr<nsPIDOMWindow> win = do_QueryReferent(mWindow);
   NS_ENSURE_TRUE(win, NS_OK);
 
   nsCOMPtr<nsIDOMDocument> domDoc = win->GetExtantDocument();
   NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
 
   bool hidden = true;
@@ -790,17 +790,17 @@ Navigator::Vibrate(const jsval& aPattern
     JSObject *obj = JSVAL_TO_OBJECT(aPattern);
     uint32_t length;
     if (!JS_GetArrayLength(cx, obj, &length) || length > sMaxVibrateListLen) {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
     pattern.SetLength(length);
 
     for (uint32_t i = 0; i < length; ++i) {
-      jsval v;
+      JS::Value v;
       int32_t pv;
       if (JS_GetElement(cx, obj, i, &v) &&
           GetVibrationDurationFromJsval(v, cx, &pv)) {
         pattern[i] = pv;
       }
       else {
         return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
       }
@@ -1436,17 +1436,17 @@ Navigator::EnsureMessagesManager()
   nsCOMPtr<nsIDOMNavigatorSystemMessages> messageManager =
     do_CreateInstance("@mozilla.org/system-message-manager;1", &rv);
   
   nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi =
     do_QueryInterface(messageManager);
   NS_ENSURE_TRUE(gpi, NS_ERROR_FAILURE);
 
   // We don't do anything with the return value.
-  jsval prop_val = JSVAL_VOID;
+  JS::Value prop_val = JSVAL_VOID;
   rv = gpi->Init(window, &prop_val);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mMessagesManager = messageManager.forget();
 
   return NS_OK;
 }
 #endif
--- a/dom/base/nsDOMJSUtils.h
+++ b/dom/base/nsDOMJSUtils.h
@@ -40,21 +40,21 @@ GetScriptContextPrincipalFromJSContext(J
     do_QueryInterface(static_cast<nsISupports *>
                                  (::JS_GetContextPrivate(cx)));
 
   // This will return a pointer to something that's about to be
   // released, but that's ok here.
   return scx;
 }
 
-// A factory function for turning a jsval argv into an nsIArray
+// A factory function for turning a JS::Value argv into an nsIArray
 // but also supports an effecient way of extracting the original argv.
 // Bug 312003 describes why this must be "void *", but argv will be cast to
-// jsval* and the args are found at:
-//    ((jsval*)aArgv)[0], ..., ((jsval*)aArgv)[aArgc - 1]
+// JS::Value* and the args are found at:
+//    ((JS::Value*)aArgv)[0], ..., ((JS::Value*)aArgv)[aArgc - 1]
 // The resulting object will take a copy of the array, and ensure each
 // element is rooted.
 // Optionally, aArgv may be NULL, in which case the array is allocated and
 // rooted, but all items remain NULL.  This presumably means the caller will
 // then QI us for nsIJSArgArray, and set our array elements.
 nsresult NS_CreateJSArgv(JSContext *aContext, uint32_t aArgc, void *aArgv,
                          nsIJSArgArray **aArray);
 
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -2661,18 +2661,18 @@ nsDOMWindowUtils::PreventFurtherDialogs(
 static nsIDOMBlob*
 GetXPConnectNative(JSContext* aCx, JSObject* aObj) {
   nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(
     nsContentUtils::XPConnect()->GetNativeOfWrapper(aCx, aObj));
   return blob;
 }
 
 static nsresult
-GetFileOrBlob(const nsAString& aName, const jsval& aBlobParts,
-              const jsval& aParameters, JSContext* aCx,
+GetFileOrBlob(const nsAString& aName, const JS::Value& aBlobParts,
+              const JS::Value& aParameters, JSContext* aCx,
               uint8_t aOptionalArgCount, nsISupports** aResult)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   nsresult rv;
 
@@ -2684,28 +2684,28 @@ GetFileOrBlob(const nsAString& aName, co
   else {
     rv = nsDOMMultipartFile::NewFile(aName, getter_AddRefs(file));
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsDOMMultipartFile* domFile =
     static_cast<nsDOMMultipartFile*>(static_cast<nsIDOMFile*>(file.get()));
 
-  jsval args[2] = { aBlobParts, aParameters };
+  JS::Value args[2] = { aBlobParts, aParameters };
 
   rv = domFile->InitBlob(aCx, aOptionalArgCount, args, GetXPConnectNative);
   NS_ENSURE_SUCCESS(rv, rv);
 
   file.forget(aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMWindowUtils::GetFile(const nsAString& aName, const jsval& aBlobParts,
-                          const jsval& aParameters, JSContext* aCx,
+nsDOMWindowUtils::GetFile(const nsAString& aName, const JS::Value& aBlobParts,
+                          const JS::Value& aParameters, JSContext* aCx,
                           uint8_t aOptionalArgCount, nsIDOMFile** aResult)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   nsCOMPtr<nsISupports> file;
   nsresult rv = GetFileOrBlob(aName, aBlobParts, aParameters, aCx,
@@ -2714,19 +2714,19 @@ nsDOMWindowUtils::GetFile(const nsAStrin
 
   nsCOMPtr<nsIDOMFile> result = do_QueryInterface(file);
   result.forget(aResult);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMWindowUtils::GetBlob(const jsval& aBlobParts, const jsval& aParameters,
-                          JSContext* aCx, uint8_t aOptionalArgCount,
-                          nsIDOMBlob** aResult)
+nsDOMWindowUtils::GetBlob(const JS::Value& aBlobParts,
+                          const JS::Value& aParameters, JSContext* aCx,
+                          uint8_t aOptionalArgCount, nsIDOMBlob** aResult)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   nsCOMPtr<nsISupports> blob;
   nsresult rv = GetFileOrBlob(NullString(), aBlobParts, aParameters, aCx,
                               aOptionalArgCount, getter_AddRefs(blob));
@@ -2734,17 +2734,17 @@ nsDOMWindowUtils::GetBlob(const jsval& a
 
   nsCOMPtr<nsIDOMBlob> result = do_QueryInterface(blob);
   result.forget(aResult);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMWindowUtils::GetFileId(const jsval& aFile, JSContext* aCx,
+nsDOMWindowUtils::GetFileId(const JS::Value& aFile, JSContext* aCx,
                             int64_t* aResult)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   if (!JSVAL_IS_PRIMITIVE(aFile)) {
     JSObject* obj = JSVAL_TO_OBJECT(aFile);
@@ -2923,17 +2923,17 @@ nsDOMWindowUtils::GetPaintingSuppressed(
   nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
   NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
 
   *aPaintingSuppressed = presShell->IsPaintingSuppressed();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMWindowUtils::GetPlugins(JSContext* cx, jsval* aPlugins)
+nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::Value* aPlugins)
 {
   if (!nsContentUtils::IsCallerChrome()) {
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
   NS_ENSURE_STATE(window);
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -6437,17 +6437,17 @@ nsGlobalWindow::OpenDialog(const nsAStri
     return NS_ERROR_NOT_AVAILABLE;
 
   JSContext *cx = nullptr;
 
   rv = ncc->GetJSContext(&cx);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t argc;
-  jsval *argv = nullptr;
+  JS::Value *argv = nullptr;
 
   // XXX - need to get this as nsISupports?
   ncc->GetArgc(&argc);
   ncc->GetArgvPtr(&argv);
 
   // Strip the url, name and options from the args seen by scripts.
   uint32_t argOffset = argc < 3 ? argc : 3;
   nsCOMPtr<nsIJSArgArray> argvArray;
@@ -6620,17 +6620,17 @@ PostMessageReadStructuredClone(JSContext
 
   if (tag == SCTAG_DOM_BLOB || tag == SCTAG_DOM_FILELIST) {
     NS_ASSERTION(!data, "Data should be empty");
 
     nsISupports* supports;
     if (JS_ReadBytes(reader, &supports, sizeof(supports))) {
       JSObject* global = JS_GetGlobalForScopeChain(cx);
       if (global) {
-        jsval val;
+        JS::Value val;
         nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
         if (NS_SUCCEEDED(nsContentUtils::WrapNative(cx, global, supports,
                                                     &val,
                                                     getter_AddRefs(wrapper)))) {
           return JSVAL_TO_OBJECT(val);
         }
       }
     }
@@ -6758,17 +6758,17 @@ PostMessageEvent::Run()
     nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
     nsresult rv =
       ssm->CheckSameOriginURI(mProvidedOrigin, targetURI, true);
     if (NS_FAILED(rv))
       return NS_OK;
   }
 
   // Deserialize the structured clone data
-  jsval messageData;
+  JS::Value messageData;
   {
     JSAutoRequest ar(cx);
     StructuredCloneInfo scInfo;
     scInfo.event = this;
 
     if (!buffer.read(cx, &messageData, &kPostMessageCallbacks, &scInfo))
       return NS_ERROR_DOM_DATA_CLONE_ERR;
   }
@@ -6813,19 +6813,19 @@ PostMessageEvent::Run()
                               presContext,
                               internalEvent,
                               message,
                               &status);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsGlobalWindow::PostMessageMoz(const jsval& aMessage,
+nsGlobalWindow::PostMessageMoz(const JS::Value& aMessage,
                                const nsAString& aOrigin,
-                               const jsval& aTransfer,
+                               const JS::Value& aTransfer,
                                JSContext* aCx)
 {
   FORWARD_TO_OUTER(PostMessageMoz, (aMessage, aOrigin, aTransfer, aCx),
                    NS_ERROR_NOT_INITIALIZED);
 
   //
   // Window.postMessage is an intentional subversion of the same-origin policy.
   // As such, this code must be particularly careful in the information it
@@ -6901,17 +6901,17 @@ nsGlobalWindow::PostMessageMoz(const jsv
     new PostMessageEvent(nsContentUtils::IsCallerChrome() || !callerInnerWin
                          ? nullptr
                          : callerInnerWin->GetOuterWindowInternal(),
                          origin,
                          this,
                          providedOrigin,
                          nsContentUtils::IsCallerChrome());
 
-  // We *must* clone the data here, or the jsval could be modified
+  // We *must* clone the data here, or the JS::Value could be modified
   // by script
   JSAutoStructuredCloneBuffer buffer;
   StructuredCloneInfo scInfo;
   scInfo.event = event;
 
   nsIPrincipal* principal = GetPrincipal();
   if (NS_FAILED(callerPrin->Subsumes(principal, &scInfo.subsumes)))
     return NS_ERROR_DOM_DATA_CLONE_ERR;
@@ -11798,23 +11798,23 @@ nsGlobalWindow::DisableNetworkEvent(uint
       os->RemoveObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC);
       break;
   }
 }
 #endif // MOZ_B2G
 
 #define EVENT(name_, id_, type_, struct_)                                    \
   NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx,                  \
-                                             jsval *vp) {                    \
+                                             JS::Value *vp) {                \
     EventHandlerNonNull* h = GetOn##name_();                                 \
     vp->setObjectOrNull(h ? h->Callable() : nullptr);                        \
     return NS_OK;                                                            \
   }                                                                          \
   NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx,                  \
-                                             const jsval &v) {               \
+                                             const JS::Value &v) {           \
     JSObject *obj = mJSObject;                                               \
     if (!obj) {                                                              \
       /* Just silently do nothing */                                         \
       return NS_OK;                                                          \
     }                                                                        \
     nsRefPtr<EventHandlerNonNull> handler;                                   \
     JSObject *callable;                                                      \
     if (v.isObject() &&                                                      \
@@ -11826,30 +11826,30 @@ nsGlobalWindow::DisableNetworkEvent(uint
       }                                                                      \
     }                                                                        \
     ErrorResult rv;                                                          \
     SetOn##name_(handler, rv);                                               \
     return rv.ErrorCode();                                                   \
   }
 #define ERROR_EVENT(name_, id_, type_, struct_)                              \
   NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx,                  \
-                                             jsval *vp) {                    \
+                                             JS::Value *vp) {                \
     nsEventListenerManager *elm = GetListenerManager(false);                 \
     if (elm) {                                                               \
       OnErrorEventHandlerNonNull* h = elm->GetOnErrorEventHandler();         \
       if (h) {                                                               \
         *vp = JS::ObjectValue(*h->Callable());                               \
         return NS_OK;                                                        \
       }                                                                      \
     }                                                                        \
     *vp = JSVAL_NULL;                                                        \
     return NS_OK;                                                            \
   }                                                                          \
   NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx,                  \
-                                             const jsval &v) {               \
+                                             const JS::Value &v) {           \
     nsEventListenerManager *elm = GetListenerManager(true);                  \
     if (!elm) {                                                              \
       return NS_ERROR_OUT_OF_MEMORY;                                         \
     }                                                                        \
                                                                              \
     JSObject *obj = mJSObject;                                               \
     if (!obj) {                                                              \
       return NS_ERROR_UNEXPECTED;                                            \
@@ -11863,31 +11863,31 @@ nsGlobalWindow::DisableNetworkEvent(uint
       if (!ok) {                                                             \
         return NS_ERROR_OUT_OF_MEMORY;                                       \
       }                                                                      \
     }                                                                        \
     return elm->SetEventHandler(handler);                                    \
   }
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                       \
   NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx,                  \
-                                             jsval *vp) {                    \
+                                             JS::Value *vp) {                \
     nsEventListenerManager *elm = GetListenerManager(false);                 \
     if (elm) {                                                               \
       BeforeUnloadEventHandlerNonNull* h =                                   \
         elm->GetOnBeforeUnloadEventHandler();                                \
       if (h) {                                                               \
         *vp = JS::ObjectValue(*h->Callable());                               \
         return NS_OK;                                                        \
       }                                                                      \
     }                                                                        \
     *vp = JSVAL_NULL;                                                        \
     return NS_OK;                                                            \
   }                                                                          \
   NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx,                  \
-                                             const jsval &v) {               \
+                                             const JS::Value &v) {           \
     nsEventListenerManager *elm = GetListenerManager(true);                  \
     if (!elm) {                                                              \
       return NS_ERROR_OUT_OF_MEMORY;                                         \
     }                                                                        \
                                                                              \
     JSObject *obj = mJSObject;                                               \
     if (!obj) {                                                              \
       return NS_ERROR_UNEXPECTED;                                            \
--- a/dom/base/nsIJSNativeInitializer.h
+++ b/dom/base/nsIJSNativeInitializer.h
@@ -12,27 +12,27 @@
 #define NS_IJSNATIVEINITIALIZER_IID \
 { 0x536c5ad2, 0x1275, 0x4706,       \
   { 0x99, 0xbd, 0x4a, 0xef, 0xb2, 0x4a, 0xb7, 0xf7 } }
 
 /**
  * A JavaScript specific interface used to initialize new
  * native objects, created as a result of calling a
  * JavaScript constructor. The arguments are passed in
- * their raw form as jsval's.
+ * their raw form as JS::Value's.
  */
 
 class nsIJSNativeInitializer : public nsISupports {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IJSNATIVEINITIALIZER_IID)
 
   /**
    * Initialize a newly created native instance using the owner of the
    * constructor and the parameters passed into the JavaScript constructor.
    */
   NS_IMETHOD Initialize(nsISupports* aOwner, JSContext *cx, JSObject *obj,
-                        uint32_t argc, jsval *argv) = 0;
+                        uint32_t argc, JS::Value *argv) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIJSNativeInitializer,
                               NS_IJSNATIVEINITIALIZER_IID)
 
 #endif // nsIJSNativeInitializer_h__
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -255,30 +255,30 @@ nsJSEnvironmentObserver::Observe(nsISupp
 
 class nsRootedJSValueArray {
 public:
   explicit nsRootedJSValueArray(JSContext *cx) : avr(cx, vals.Length(), vals.Elements()) {}
 
   void SetCapacity(JSContext *cx, size_t capacity) {
     vals.SetCapacity(capacity);
     // Values must be safe for the GC to inspect (they must not contain garbage).
-    memset(vals.Elements(), 0, vals.Capacity() * sizeof(jsval));
+    memset(vals.Elements(), 0, vals.Capacity() * sizeof(JS::Value));
     resetRooter(cx);
   }
 
-  jsval *Elements() {
+  JS::Value *Elements() {
     return vals.Elements();
   }
 
 private:
   void resetRooter(JSContext *cx) {
     avr.changeArray(vals.Elements(), vals.Length());
   }
 
-  nsAutoTArray<jsval, 16> vals;
+  nsAutoTArray<JS::Value, 16> vals;
   JS::AutoArrayRooter avr;
 };
 
 /****************************************************************
  ************************** AutoFree ****************************
  ****************************************************************/
 
 class AutoFree {
@@ -1426,17 +1426,17 @@ nsJSContext::ExecuteScript(JSScript* aSc
   // cx and potentially call JS_RestoreFrameChain.
   {
     JSAutoCompartment ac(mContext, aScopeObject);
     ++mExecuteDepth;
 
     // The result of evaluation, used only if there were no errors. This need
     // not be a GC root currently, provided we run the GC only from the
     // operation callback or from ScriptEvaluated.
-    jsval val;
+    JS::Value val;
     if (!JS_ExecuteScript(mContext, aScopeObject, aScriptObject, &val)) {
       ReportPendingException();
     }
     --mExecuteDepth;
   }
 
   // Pop here, after JS_ValueToString and any other possible evaluation.
   pusher.Pop();
@@ -1476,17 +1476,17 @@ nsJSContext::JSObjectFromInterface(nsISu
   if (!aTarget) {
     *aRet = nullptr;
     return NS_OK;
   }
 
   // Get the jsobject associated with this target
   // We don't wrap here because we trust the JS engine to wrap the target
   // later.
-  jsval v;
+  JS::Value v;
   nsresult rv = nsContentUtils::WrapNative(mContext, aScope, aTarget, &v);
   NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef DEBUG
   nsCOMPtr<nsISupports> targetSupp = do_QueryInterface(aTarget);
   nsCOMPtr<nsISupports> native =
     nsContentUtils::XPConnect()->GetNativeOfWrapper(mContext,
                                                     JSVAL_TO_OBJECT(v));
@@ -1658,29 +1658,29 @@ nsJSContext::InitializeExternalClasses()
 
   return nameSpaceManager->InitForContext(this);
 }
 
 nsresult
 nsJSContext::SetProperty(JSObject* aTarget, const char* aPropName, nsISupports* aArgs)
 {
   uint32_t  argc;
-  jsval    *argv = nullptr;
+  JS::Value *argv = nullptr;
 
   nsCxPusher pusher;
   pusher.Push(mContext);
   XPCAutoRequest ar(mContext);
 
   Maybe<nsRootedJSValueArray> tempStorage;
 
   nsresult rv =
     ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc, &argv, tempStorage);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  jsval vargs;
+  JS::Value vargs;
 
   // got the arguments, now attach them.
 
   // window.dialogArguments is supposed to be an array if a JS array
   // was passed to showModalDialog(), deal with that here.
   if (strcmp(aPropName, "dialogArguments") == 0 && argc <= 1) {
     vargs = argc ? argv[0] : JSVAL_VOID;
   } else {
@@ -1700,17 +1700,17 @@ nsJSContext::SetProperty(JSObject* aTarg
     ? NS_OK
     : NS_ERROR_FAILURE;
 }
 
 nsresult
 nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
                                      JSObject *aScope,
                                      uint32_t *aArgc,
-                                     jsval **aArgv,
+                                     JS::Value **aArgv,
                                      Maybe<nsRootedJSValueArray> &aTempStorage)
 {
   nsresult rv = NS_OK;
 
   // If the array implements nsIJSArgArray, just grab the values directly.
   nsCOMPtr<nsIJSArgArray> fastArray = do_QueryInterface(aArgs);
   if (fastArray != nullptr)
     return fastArray->GetArgs(aArgc, reinterpret_cast<void **>(aArgv));
@@ -1739,22 +1739,22 @@ nsJSContext::ConvertSupportsTojsvals(nsI
       return NS_OK;
   } else {
     argCount = 1; // the nsISupports which is not an array
   }
 
   // Use the caller's auto guards to release and unroot.
   aTempStorage.construct(mContext);
   aTempStorage.ref().SetCapacity(mContext, argCount);
-  jsval *argv = aTempStorage.ref().Elements();
+  JS::Value *argv = aTempStorage.ref().Elements();
 
   if (argsArray) {
     for (uint32_t argCtr = 0; argCtr < argCount && NS_SUCCEEDED(rv); argCtr++) {
       nsCOMPtr<nsISupports> arg;
-      jsval *thisval = argv + argCtr;
+      JS::Value *thisval = argv + argCtr;
       argsArray->QueryElementAt(argCtr, NS_GET_IID(nsISupports),
                                 getter_AddRefs(arg));
       if (!arg) {
         *thisval = JSVAL_NULL;
         continue;
       }
       nsCOMPtr<nsIVariant> variant(do_QueryInterface(arg));
       if (variant != nullptr) {
@@ -1770,17 +1770,17 @@ nsJSContext::ConvertSupportsTojsvals(nsI
 #ifdef DEBUG
           // but first, check its not another nsISupportsPrimitive, as
           // these are now deprecated for use with script contexts.
           nsCOMPtr<nsISupportsPrimitive> prim(do_QueryInterface(arg));
           NS_ASSERTION(prim == nullptr,
                        "Don't pass nsISupportsPrimitives - use nsIVariant!");
 #endif
           nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
-          jsval v;
+          JS::Value v;
           rv = nsContentUtils::WrapNative(mContext, aScope, arg, &v,
                                           getter_AddRefs(wrapper));
           if (NS_SUCCEEDED(rv)) {
             *thisval = v;
           }
         }
       }
     }
@@ -1797,17 +1797,17 @@ nsJSContext::ConvertSupportsTojsvals(nsI
     return rv;
   *aArgv = argv;
   *aArgc = argCount;
   return NS_OK;
 }
 
 // This really should go into xpconnect somewhere...
 nsresult
-nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, jsval *aArgv)
+nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
 {
   NS_PRECONDITION(aArg, "Empty arg");
 
   nsCOMPtr<nsISupportsPrimitive> argPrimitive(do_QueryInterface(aArg));
   if (!argPrimitive)
     return NS_ERROR_NO_INTERFACE;
 
   JSContext *cx = mContext;
@@ -1971,17 +1971,17 @@ nsJSContext::AddSupportsPrimitiveTojsval
       p->GetData(getter_AddRefs(data));
       p->GetDataIID(&iid);
       NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
 
       AutoFree iidGuard(iid); // Free iid upon destruction.
 
       nsCOMPtr<nsIXPConnectJSObjectHolder> wrapper;
       JSObject *global = xpc_UnmarkGrayObject(::JS_GetGlobalObject(cx));
-      jsval v;
+      JS::Value v;
       nsresult rv = nsContentUtils::WrapNative(cx, global,
                                                data, iid, &v,
                                                getter_AddRefs(wrapper));
       NS_ENSURE_SUCCESS(rv, rv);
 
       *aArgv = v;
 
       break;
@@ -2021,39 +2021,39 @@ CheckUniversalXPConnectForTraceMalloc(JS
 {
     if (nsContentUtils::IsCallerChrome())
         return JS_TRUE;
     JS_ReportError(cx, "trace-malloc functions require UniversalXPConnect");
     return JS_FALSE;
 }
 
 static JSBool
-TraceMallocDisable(JSContext *cx, unsigned argc, jsval *vp)
+TraceMallocDisable(JSContext *cx, unsigned argc, JS::Value *vp)
 {
     if (!CheckUniversalXPConnectForTraceMalloc(cx))
         return JS_FALSE;
 
     NS_TraceMallocDisable();
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return JS_TRUE;
 }
 
 static JSBool
-TraceMallocEnable(JSContext *cx, unsigned argc, jsval *vp)
+TraceMallocEnable(JSContext *cx, unsigned argc, JS::Value *vp)
 {
     if (!CheckUniversalXPConnectForTraceMalloc(cx))
         return JS_FALSE;
 
     NS_TraceMallocEnable();
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return JS_TRUE;
 }
 
 static JSBool
-TraceMallocOpenLogFile(JSContext *cx, unsigned argc, jsval *vp)
+TraceMallocOpenLogFile(JSContext *cx, unsigned argc, JS::Value *vp)
 {
     int fd;
     JSString *str;
 
     if (!CheckUniversalXPConnectForTraceMalloc(cx))
         return JS_FALSE;
 
     if (argc == 0) {
@@ -2071,17 +2071,17 @@ TraceMallocOpenLogFile(JSContext *cx, un
             return JS_FALSE;
         }
     }
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(fd));
     return JS_TRUE;
 }
 
 static JSBool
-TraceMallocChangeLogFD(JSContext *cx, unsigned argc, jsval *vp)
+TraceMallocChangeLogFD(JSContext *cx, unsigned argc, JS::Value *vp)
 {
     if (!CheckUniversalXPConnectForTraceMalloc(cx))
         return JS_FALSE;
 
     int32_t fd, oldfd;
     if (argc == 0) {
         oldfd = -1;
     } else {
@@ -2093,50 +2093,50 @@ TraceMallocChangeLogFD(JSContext *cx, un
             return JS_FALSE;
         }
     }
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(oldfd));
     return JS_TRUE;
 }
 
 static JSBool
-TraceMallocCloseLogFD(JSContext *cx, unsigned argc, jsval *vp)
+TraceMallocCloseLogFD(JSContext *cx, unsigned argc, JS::Value *vp)
 {
     if (!CheckUniversalXPConnectForTraceMalloc(cx))
         return JS_FALSE;
 
     int32_t fd;
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     if (argc == 0)
         return JS_TRUE;
     if (!JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[0], &fd))
         return JS_FALSE;
     NS_TraceMallocCloseLogFD((int) fd);
     return JS_TRUE;
 }
 
 static JSBool
-TraceMallocLogTimestamp(JSContext *cx, unsigned argc, jsval *vp)
+TraceMallocLogTimestamp(JSContext *cx, unsigned argc, JS::Value *vp)
 {
     if (!CheckUniversalXPConnectForTraceMalloc(cx))
         return JS_FALSE;
 
     JSString *str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
     if (!str)
         return JS_FALSE;
     JSAutoByteString caption(cx, str);
     if (!caption)
         return JS_FALSE;
     NS_TraceMallocLogTimestamp(caption.ptr());
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return JS_TRUE;
 }
 
 static JSBool
-TraceMallocDumpAllocations(JSContext *cx, unsigned argc, jsval *vp)
+TraceMallocDumpAllocations(JSContext *cx, unsigned argc, JS::Value *vp)
 {
     if (!CheckUniversalXPConnectForTraceMalloc(cx))
         return JS_FALSE;
 
     JSString *str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
     if (!str)
         return JS_FALSE;
     JSAutoByteString pathname(cx, str);
@@ -2169,17 +2169,17 @@ static JSFunctionSpec TraceMallocFunctio
 
 namespace mozilla {
 namespace dmd {
 
 // See https://wiki.mozilla.org/Performance/MemShrink/DMD for instructions on
 // how to use DMD.
 
 static JSBool
-ReportAndDump(JSContext *cx, unsigned argc, jsval *vp)
+ReportAndDump(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   JSString *str = JS_ValueToString(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID);
   if (!str)
     return JS_FALSE;
   JSAutoByteString pathname(cx, str);
   if (!pathname)
     return JS_FALSE;
 
@@ -2223,17 +2223,17 @@ IsJProfAction(struct sigaction *action)
             (action->sa_flags & (SA_RESTART | SA_SIGINFO)) == (SA_RESTART | SA_SIGINFO));
 }
 
 void NS_JProfStartProfiling();
 void NS_JProfStopProfiling();
 void NS_JProfClearCircular();
 
 static JSBool
-JProfStartProfilingJS(JSContext *cx, unsigned argc, jsval *vp)
+JProfStartProfilingJS(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   NS_JProfStartProfiling();
   return JS_TRUE;
 }
 
 void NS_JProfStartProfiling()
 {
     // Figure out whether we're dealing with SIGPROF, SIGALRM, or
@@ -2265,45 +2265,45 @@ void NS_JProfStartProfiling()
         raise(SIGPOLL);
         return;
     }
 
     printf("Could not start jprof-profiling since JPROF_FLAGS was not set.\n");
 }
 
 static JSBool
-JProfStopProfilingJS(JSContext *cx, unsigned argc, jsval *vp)
+JProfStopProfilingJS(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   NS_JProfStopProfiling();
   return JS_TRUE;
 }
 
 void
 NS_JProfStopProfiling()
 {
     raise(SIGUSR1);
     //printf("Stopped jprof profiling.\n");
 }
 
 static JSBool
-JProfClearCircularJS(JSContext *cx, unsigned argc, jsval *vp)
+JProfClearCircularJS(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   NS_JProfClearCircular();
   return JS_TRUE;
 }
 
 void
 NS_JProfClearCircular()
 {
     raise(SIGUSR2);
     //printf("cleared jprof buffer\n");
 }
 
 static JSBool
-JProfSaveCircularJS(JSContext *cx, unsigned argc, jsval *vp)
+JProfSaveCircularJS(JSContext *cx, unsigned argc, JS::Value *vp)
 {
   // Not ideal...
   NS_JProfStopProfiling();
   NS_JProfStartProfiling();
   return JS_TRUE;
 }
 
 static JSFunctionSpec JProfFunctions[] = {
@@ -3395,17 +3395,17 @@ NS_DOMReadStructuredClone(JSContext* cx,
         !JS_ReadTypedArray(reader, &dataArray)) {
       return nullptr;
     }
     MOZ_ASSERT(dataArray.isObject());
 
     // Construct the ImageData.
     nsRefPtr<ImageData> imageData = new ImageData(width, height,
                                                   dataArray.toObject());
-    // Wrap it in a jsval.
+    // Wrap it in a JS::Value.
     JSObject* global = JS_GetGlobalForScopeChain(cx);
     if (!global) {
       return nullptr;
     }
     return imageData->WrapObject(cx, global);
   }
 
   // Don't know what this is. Bail.
@@ -3621,47 +3621,48 @@ nsresult NS_CreateJSRuntime(nsIScriptRun
 // A fast-array class for JS.  This class supports both nsIJSScriptArray and
 // nsIArray.  If it is JS itself providing and consuming this class, all work
 // can be done via nsIJSScriptArray, and avoid the conversion of elements
 // to/from nsISupports.
 // When consumed by non-JS (eg, another script language), conversion is done
 // on-the-fly.
 class nsJSArgArray MOZ_FINAL : public nsIJSArgArray {
 public:
-  nsJSArgArray(JSContext *aContext, uint32_t argc, jsval *argv, nsresult *prv);
+  nsJSArgArray(JSContext *aContext, uint32_t argc, JS::Value *argv,
+               nsresult *prv);
   ~nsJSArgArray();
   // nsISupports
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsJSArgArray,
                                                          nsIJSArgArray)
 
   // nsIArray
   NS_DECL_NSIARRAY
 
   // nsIJSArgArray
   nsresult GetArgs(uint32_t *argc, void **argv);
 
   void ReleaseJSObjects();
 
 protected:
   JSContext *mContext;
-  jsval *mArgv;
+  JS::Value *mArgv;
   uint32_t mArgc;
 };
 
-nsJSArgArray::nsJSArgArray(JSContext *aContext, uint32_t argc, jsval *argv,
+nsJSArgArray::nsJSArgArray(JSContext *aContext, uint32_t argc, JS::Value *argv,
                            nsresult *prv) :
     mContext(aContext),
     mArgv(nullptr),
     mArgc(argc)
 {
   // copy the array - we don't know its lifetime, and ours is tied to xpcom
   // refcounting.  Alloc zero'd array so cleanup etc is safe.
   if (argc) {
-    mArgv = (jsval *) PR_CALLOC(argc * sizeof(jsval));
+    mArgv = (JS::Value *) PR_CALLOC(argc * sizeof(JS::Value));
     if (!mArgv) {
       *prv = NS_ERROR_OUT_OF_MEMORY;
       return;
     }
   }
 
   // Callers are allowed to pass in a null argv even for argc > 0. They can
   // then use GetArgs to initialize the values.
@@ -3698,19 +3699,19 @@ nsJSArgArray::ReleaseJSObjects()
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSArgArray)
   tmp->ReleaseJSObjects();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsJSArgArray)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSArgArray)
-  jsval *argv = tmp->mArgv;
+  JS::Value *argv = tmp->mArgv;
   if (argv) {
-    jsval *end;
+    JS::Value *end;
     for (end = argv + tmp->mArgc; argv < end; ++argv) {
       if (JSVAL_IS_GCTHING(*argv))
         NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(JSVAL_TO_GCTHING(*argv),
                                                    "mArgv[i]")
     }
   }
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
@@ -3766,17 +3767,17 @@ NS_IMETHODIMP nsJSArgArray::Enumerate(ns
 }
 
 // The factory function
 nsresult NS_CreateJSArgv(JSContext *aContext, uint32_t argc, void *argv,
                          nsIJSArgArray **aArray)
 {
   nsresult rv;
   nsJSArgArray *ret = new nsJSArgArray(aContext, argc,
-                                       static_cast<jsval *>(argv), &rv);
+                                       static_cast<JS::Value *>(argv), &rv);
   if (ret == nullptr)
     return NS_ERROR_OUT_OF_MEMORY;
   if (NS_FAILED(rv)) {
     delete ret;
     return rv;
   }
   return ret->QueryInterface(NS_GET_IID(nsIArray), (void **)aArray);
 }
--- a/dom/base/nsJSEnvironment.h
+++ b/dom/base/nsJSEnvironment.h
@@ -158,20 +158,20 @@ public:
   }
 protected:
   nsresult InitializeExternalClasses();
 
   // Helper to convert xpcom datatypes to jsvals.
   nsresult ConvertSupportsTojsvals(nsISupports *aArgs,
                                    JSObject *aScope,
                                    uint32_t *aArgc,
-                                   jsval **aArgv,
+                                   JS::Value **aArgv,
                                    mozilla::Maybe<nsRootedJSValueArray> &aPoolRelease);
 
-  nsresult AddSupportsPrimitiveTojsvals(nsISupports *aArg, jsval *aArgv);
+  nsresult AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv);
 
   // given an nsISupports object (presumably an event target or some other
   // DOM object), get (or create) the JSObject wrapping it.
   nsresult JSObjectFromInterface(nsISupports *aSup, JSObject *aScript,
                                  JSObject **aRet);
 
   // Report the pending exception on our mContext, if any.  This
   // function will set aside the frame chain on mContext before
@@ -301,18 +301,18 @@ public:
 { 0xb6acdac8, 0xf5c6, 0x432c, \
   { 0xa8, 0x6e, 0x33, 0xee, 0xb1, 0xb0, 0xcd, 0xdc } }
 
 class nsIJSArgArray : public nsIArray
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IJSARGARRAY_IID)
   // Bug 312003 describes why this must be "void **", but after calling argv
-  // may be cast to jsval* and the args found at:
-  //    ((jsval*)argv)[0], ..., ((jsval*)argv)[argc - 1]
+  // may be cast to JS::Value* and the args found at:
+  //    ((JS::Value*)argv)[0], ..., ((JS::Value*)argv)[argc - 1]
   virtual nsresult GetArgs(uint32_t *argc, void **argv) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIJSArgArray, NS_IJSARGARRAY_IID)
 
 /* factory functions */
 nsresult NS_CreateJSRuntime(nsIScriptRuntime **aRuntime);
 
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -175,17 +175,17 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
     return NS_ERROR_NOT_AVAILABLE;
 
   JSContext *cx = nullptr;
 
   rv = ncc->GetJSContext(&cx);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t argc;
-  jsval *argv = nullptr;
+  JS::Value *argv = nullptr;
 
   ncc->GetArgc(&argc);
   ncc->GetArgvPtr(&argv);
 
   JSFlatString *expr = nullptr;
   JSObject *funobj = nullptr;
 
   JSAutoRequest ar(cx);
--- a/dom/base/nsJSUtils.h
+++ b/dom/base/nsJSUtils.h
@@ -107,17 +107,17 @@ public:
           return JS_FALSE;
 
       NS_ASSERTION(IsEmpty(), "init() on initialized string");
       nsDependentString* base = this;
       new(base) nsDependentString(chars, length);
       return JS_TRUE;
   }
 
-  JSBool init(JSContext* aContext, const jsval &v)
+  JSBool init(JSContext* aContext, const JS::Value &v)
   {
       return init(aContext, JSVAL_TO_STRING(v));
   }
 
   void init(JSFlatString* fstr)
   {
       MOZ_ASSERT(IsEmpty(), "init() on initialized string");
       new(this) nsDependentJSString(fstr);
--- a/dom/base/nsStructuredCloneContainer.cpp
+++ b/dom/base/nsStructuredCloneContainer.cpp
@@ -39,19 +39,19 @@ nsStructuredCloneContainer::~nsStructure
 
 nsresult
 nsStructuredCloneContainer::InitFromVariant(nsIVariant *aData, JSContext *aCx)
 {
   NS_ENSURE_STATE(!mData);
   NS_ENSURE_ARG_POINTER(aData);
   NS_ENSURE_ARG_POINTER(aCx);
 
-  // First, try to extract a jsval from the variant |aData|.  This works only
+  // First, try to extract a JS::Value from the variant |aData|.  This works only
   // if the variant implements GetAsJSVal.
-  jsval jsData;
+  JS::Value jsData;
   nsresult rv = aData->GetAsJSVal(&jsData);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
 
   // Make sure that we serialize in the right context.
   MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
   JSAutoRequest ar(aCx);
   JSAutoCompartment ac(aCx, JS_GetGlobalObject(aCx));
   JS_WrapValue(aCx, &jsData);
@@ -108,28 +108,28 @@ nsStructuredCloneContainer::InitFromBase
 nsresult
 nsStructuredCloneContainer::DeserializeToVariant(JSContext *aCx,
                                                  nsIVariant **aData)
 {
   NS_ENSURE_STATE(mData);
   NS_ENSURE_ARG_POINTER(aData);
   *aData = nullptr;
 
-  // Deserialize to a jsval.
-  jsval jsStateObj;
+  // Deserialize to a JS::Value.
+  JS::Value jsStateObj;
   JSBool hasTransferable = false;
   bool success = JS_ReadStructuredClone(aCx, mData, mSize, mVersion,
                                           &jsStateObj, nullptr, nullptr) &&
                  JS_StructuredCloneHasTransferables(mData, mSize,
                                                     &hasTransferable);
   // We want to be sure that mData doesn't contain transferable objects
   MOZ_ASSERT(!hasTransferable);
   NS_ENSURE_STATE(success && !hasTransferable);
 
-  // Now wrap the jsval as an nsIVariant.
+  // Now wrap the JS::Value as an nsIVariant.
   nsCOMPtr<nsIVariant> varStateObj;
   nsCOMPtr<nsIXPConnect> xpconnect = do_GetService(nsIXPConnect::GetCID());
   NS_ENSURE_STATE(xpconnect);
   xpconnect->JSValToVariant(aCx, &jsStateObj, getter_AddRefs(varStateObj));
   NS_ENSURE_STATE(varStateObj);
 
   NS_IF_ADDREF(*aData = varStateObj);
   return NS_OK;