Bug 1255818. Switch from JS_ClearPendingException to AutoJSAPI::ClearException for cases when we have an AutoJSAPI around. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 11 Mar 2016 16:43:31 -0500
changeset 339702 cf1c5ae001f8b4d384efcd6e6de00409fceea1c5
parent 339701 ce90c668f3abed79a4c6f524622dc31c3d0df5fa
child 339703 6e8cd31f8397ae2458fdccfc18397145dce64526
push id12803
push userjbeich@FreeBSD.org
push dateSun, 13 Mar 2016 09:48:54 +0000
reviewersbholley
bugs1255818
milestone48.0a1
Bug 1255818. Switch from JS_ClearPendingException to AutoJSAPI::ClearException for cases when we have an AutoJSAPI around. r=bholley
dom/bluetooth/common/webapi/BluetoothAdapter.cpp
dom/bluetooth/common/webapi/BluetoothDevice.cpp
dom/bluetooth/common/webapi/BluetoothGattCharacteristic.cpp
dom/bluetooth/common/webapi/BluetoothGattDescriptor.cpp
dom/icc/IccCallback.cpp
dom/mobileconnection/MobileConnectionCallback.cpp
dom/mobilemessage/MobileMessageCallback.cpp
--- a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp
@@ -102,17 +102,17 @@ public:
 
     /**
      * Create a new discovery handle and wrap it to return. Each
      * discovery handle is one-time-use only.
      */
     RefPtr<BluetoothDiscoveryHandle> discoveryHandle =
       BluetoothDiscoveryHandle::Create(mAdapter->GetParentObject());
     if (!ToJSValue(cx, discoveryHandle, aValue)) {
-      JS_ClearPendingException(cx);
+      jsapi.ClearException();
       return false;
     }
 
     // Set the created discovery handle as the one in use.
     mAdapter->SetDiscoveryHandleInUse(discoveryHandle);
     return true;
   }
 
@@ -156,17 +156,17 @@ public:
      * Create a new discovery handle and wrap it to return. Each
      * discovery handle is one-time-use only.
      */
     RefPtr<BluetoothDiscoveryHandle> discoveryHandle =
       BluetoothDiscoveryHandle::Create(mAdapter->GetParentObject(),
                                        mServiceUuids, v.get_BluetoothUuid());
 
     if (!ToJSValue(cx, discoveryHandle, aValue)) {
-      JS_ClearPendingException(cx);
+      jsapi.ClearException();
       return false;
     }
 
     // Append a BluetoothDiscoveryHandle to LeScan handle array.
     mAdapter->AppendLeScanHandle(discoveryHandle);
 
     return true;
   }
--- a/dom/bluetooth/common/webapi/BluetoothDevice.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothDevice.cpp
@@ -71,17 +71,17 @@ public:
     const InfallibleTArray<nsString>& uuids = v.get_ArrayOfnsString();
 
     AutoJSAPI jsapi;
     NS_ENSURE_TRUE(jsapi.Init(mDevice->GetParentObject()), false);
 
     JSContext* cx = jsapi.cx();
     if (!ToJSValue(cx, uuids, aValue)) {
       BT_WARNING("Cannot create JS array!");
-      JS_ClearPendingException(cx);
+      jsapi.ClearException();
       return false;
     }
 
     return true;
   }
 
   virtual void ReleaseMembers() override
   {
--- a/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothGattCharacteristic.cpp
@@ -327,17 +327,17 @@ public:
     const BluetoothValue& v = mReply->get_BluetoothReplySuccess().value();
     NS_ENSURE_TRUE(v.type() == BluetoothValue::TArrayOfuint8_t, false);
 
     AutoJSAPI jsapi;
     NS_ENSURE_TRUE(jsapi.Init(mCharacteristic->GetParentObject()), false);
 
     JSContext* cx = jsapi.cx();
     if (!ToJSValue(cx, v.get_ArrayOfuint8_t(), aValue)) {
-      JS_ClearPendingException(cx);
+      jsapi.ClearException();
       return false;
     }
 
     return true;
   }
 
   void
   ReleaseMembers()
--- a/dom/bluetooth/common/webapi/BluetoothGattDescriptor.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothGattDescriptor.cpp
@@ -197,17 +197,17 @@ public:
     const BluetoothValue& v = mReply->get_BluetoothReplySuccess().value();
     NS_ENSURE_TRUE(v.type() == BluetoothValue::TArrayOfuint8_t, false);
 
     AutoJSAPI jsapi;
     NS_ENSURE_TRUE(jsapi.Init(mDescriptor->GetParentObject()), false);
 
     JSContext* cx = jsapi.cx();
     if (!ToJSValue(cx, v.get_ArrayOfuint8_t(), aValue)) {
-      JS_ClearPendingException(cx);
+      jsapi.ClearException();
       return false;
     }
 
     return true;
   }
 
   void
   ReleaseMembers()
--- a/dom/icc/IccCallback.cpp
+++ b/dom/icc/IccCallback.cpp
@@ -154,17 +154,17 @@ IccCallback::NotifyGetCardLockEnabled(bo
   AutoJSAPI jsapi;
   if (NS_WARN_IF(!jsapi.Init(mWindow))) {
     return NS_ERROR_FAILURE;
   }
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> jsResult(cx);
   if (!ToJSValue(cx, result, &jsResult)) {
-    JS_ClearPendingException(cx);
+    jsapi.ClearException();
     return NS_ERROR_TYPE_ERR;
   }
 
   return NotifySuccess(jsResult);
 }
 
 NS_IMETHODIMP
 IccCallback::NotifySuccess()
@@ -196,17 +196,17 @@ IccCallback::NotifyGetCardLockRetryCount
   AutoJSAPI jsapi;
   if (NS_WARN_IF(!jsapi.Init(mWindow))) {
     return NS_ERROR_FAILURE;
   }
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> jsResult(cx);
   if (!ToJSValue(cx, result, &jsResult)) {
-    JS_ClearPendingException(cx);
+    jsapi.ClearException();
     return NS_ERROR_TYPE_ERR;
   }
 
   return NotifySuccess(jsResult);
 }
 
 NS_IMETHODIMP
 IccCallback::NotifyError(const nsAString & aErrorMsg)
--- a/dom/mobileconnection/MobileConnectionCallback.cpp
+++ b/dom/mobileconnection/MobileConnectionCallback.cpp
@@ -54,17 +54,17 @@ MobileConnectionCallback::NotifySuccessW
   if (NS_WARN_IF(!jsapi.Init(mWindow))) {
     return NS_ERROR_FAILURE;
   }
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> jsResult(cx);
 
   if (!ToJSValue(cx, aResult, &jsResult)) {
-    JS_ClearPendingException(cx);
+    jsapi.ClearException();
     return NS_ERROR_TYPE_ERR;
   }
 
   return NotifySuccess(jsResult);
 }
 
 // nsIMobileConnectionCallback
 
@@ -97,17 +97,17 @@ MobileConnectionCallback::NotifyGetNetwo
   if (NS_WARN_IF(!jsapi.Init(mWindow))) {
     return NS_ERROR_FAILURE;
   }
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> jsResult(cx);
 
   if (!ToJSValue(cx, results, &jsResult)) {
-    JS_ClearPendingException(cx);
+    jsapi.ClearException();
     return NS_ERROR_TYPE_ERR;
   }
 
   return NotifySuccess(jsResult);
 }
 
 NS_IMETHODIMP
 MobileConnectionCallback::NotifyGetCallForwardingSuccess(uint32_t aCount,
@@ -154,17 +154,17 @@ MobileConnectionCallback::NotifyGetCallF
   if (NS_WARN_IF(!jsapi.Init(mWindow))) {
     return NS_ERROR_FAILURE;
   }
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> jsResult(cx);
 
   if (!ToJSValue(cx, results, &jsResult)) {
-    JS_ClearPendingException(cx);
+    jsapi.ClearException();
     return NS_ERROR_TYPE_ERR;
   }
 
   return NotifySuccess(jsResult);
 }
 
 NS_IMETHODIMP
 MobileConnectionCallback::NotifyGetCallBarringSuccess(uint16_t aProgram,
@@ -179,17 +179,17 @@ MobileConnectionCallback::NotifyGetCallB
   AutoJSAPI jsapi;
   if (NS_WARN_IF(!jsapi.Init(mWindow))) {
     return NS_ERROR_FAILURE;
   }
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> jsResult(cx);
   if (!ToJSValue(cx, result, &jsResult)) {
-    JS_ClearPendingException(cx);
+    jsapi.ClearException();
     return NS_ERROR_TYPE_ERR;
   }
 
   return NotifySuccess(jsResult);
 }
 
 NS_IMETHODIMP
 MobileConnectionCallback::NotifyGetCallWaitingSuccess(uint16_t aServiceClass)
@@ -209,17 +209,17 @@ MobileConnectionCallback::NotifyGetClirS
   AutoJSAPI jsapi;
   if (NS_WARN_IF(!jsapi.Init(mWindow))) {
     return NS_ERROR_FAILURE;
   }
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> jsResult(cx);
   if (!ToJSValue(cx, result, &jsResult)) {
-    JS_ClearPendingException(cx);
+    jsapi.ClearException();
     return NS_ERROR_TYPE_ERR;
   }
 
   return NotifySuccess(jsResult);
 };
 
 NS_IMETHODIMP
 MobileConnectionCallback::NotifyGetPreferredNetworkTypeSuccess(int32_t aType)
--- a/dom/mobilemessage/MobileMessageCallback.cpp
+++ b/dom/mobilemessage/MobileMessageCallback.cpp
@@ -302,17 +302,17 @@ MobileMessageCallback::NotifySegmentInfo
   SmsSegmentInfo info;
   info.mSegments = aSegments;
   info.mCharsPerSegment = aCharsPerSegment;
   info.mCharsAvailableInLastSegment = aCharsAvailableInLastSegment;
 
   JSContext* cx = jsapi.cx();
   JS::Rooted<JS::Value> val(cx);
   if (!ToJSValue(cx, info, &val)) {
-    JS_ClearPendingException(cx);
+    jsapi.ClearException();
     return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
   }
 
   return NotifySuccess(val, true);
 }
 
 NS_IMETHODIMP
 MobileMessageCallback::NotifyGetSegmentInfoForTextFailed(int32_t aError)