Bug 1331977 - CreateException doesn't use JSContext argument, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 19 Jan 2017 09:03:03 +0100
changeset 463539 e2f6478f748157bf82a5fd0e940a6043af076a77
parent 463538 e5c12e3f9e1d3f2b2e178f81a8c65ca1f5e79e76
child 463540 2164277367ccce620b9105aa9e8c2ea21fb3e22f
push id42094
push userjdescottes@mozilla.com
push dateThu, 19 Jan 2017 09:04:31 +0000
reviewersqdot
bugs1331977
milestone53.0a1
Bug 1331977 - CreateException doesn't use JSContext argument, r=qdot
dom/bindings/Exceptions.cpp
dom/bindings/Exceptions.h
dom/bindings/ToJSValue.cpp
--- a/dom/bindings/Exceptions.cpp
+++ b/dom/bindings/Exceptions.cpp
@@ -53,17 +53,17 @@ ThrowExceptionValueIfSafe(JSContext* aCx
   }
 
   // We could probably Throw(aCx, NS_ERROR_UNEXPECTED) here, and it would do the
   // right thing due to there not being an existing exception on the runtime at
   // this point, but it's clearer to explicitly do the thing we want done.  This
   // is also why we don't just call ThrowExceptionObject on the Exception we
   // create: it would do the right thing, but that fact is not obvious.
   RefPtr<Exception> syntheticException =
-    CreateException(aCx, NS_ERROR_UNEXPECTED);
+    CreateException(NS_ERROR_UNEXPECTED);
   JS::Rooted<JS::Value> syntheticVal(aCx);
   if (!GetOrCreateDOMReflector(aCx, syntheticException, &syntheticVal)) {
     return;
   }
   MOZ_ASSERT(syntheticVal.isObject() &&
              !js::IsWrapper(&syntheticVal.toObject()),
              "Must have a reflector here, not a wrapper");
   JS_SetPendingException(aCx, syntheticVal);
@@ -158,17 +158,17 @@ Throw(JSContext* aCx, nsresult aRv, cons
     if (NS_SUCCEEDED(existingException->GetResult(&nr)) &&
         aRv == nr) {
       // Reuse the existing exception.
       ThrowExceptionObject(aCx, existingException);
       return false;
     }
   }
 
-  RefPtr<Exception> finalException = CreateException(aCx, aRv, aMessage);
+  RefPtr<Exception> finalException = CreateException(aRv, aMessage);
   MOZ_ASSERT(finalException);
 
   ThrowExceptionObject(aCx, finalException);
   return false;
 }
 
 void
 ThrowAndReport(nsPIDOMWindowInner* aWindow, nsresult aRv)
@@ -179,17 +179,17 @@ ThrowAndReport(nsPIDOMWindowInner* aWind
   if (NS_WARN_IF(!jsapi.Init(aWindow))) {
     return;
   }
 
   Throw(jsapi.cx(), aRv);
 }
 
 already_AddRefed<Exception>
-CreateException(JSContext* aCx, nsresult aRv, const nsACString& aMessage)
+CreateException(nsresult aRv, const nsACString& aMessage)
 {
   // Do we use DOM exceptions for this error code?
   switch (NS_ERROR_GET_MODULE(aRv)) {
   case NS_ERROR_MODULE_DOM:
   case NS_ERROR_MODULE_SVG:
   case NS_ERROR_MODULE_DOM_XPATH:
   case NS_ERROR_MODULE_DOM_INDEXEDDB:
   case NS_ERROR_MODULE_DOM_FILEHANDLE:
--- a/dom/bindings/Exceptions.h
+++ b/dom/bindings/Exceptions.h
@@ -36,24 +36,23 @@ ThrowAndReport(nsPIDOMWindowInner* aWind
 
 // Both signatures of ThrowExceptionObject guarantee that an exception is set on
 // aCx before they return.
 void
 ThrowExceptionObject(JSContext* aCx, Exception* aException);
 void
 ThrowExceptionObject(JSContext* aCx, nsIException* aException);
 
-// Create an exception object for the given nsresult and message but don't set
-// it pending on aCx.  If we're throwing a DOMException and aMessage is empty,
-// the default message for the nsresult in question will be used.
+// Create an exception object for the given nsresult and message. If we're
+// throwing a DOMException and aMessage is empty, the default message for the
+// nsresult in question will be used.
 //
 // This never returns null.
 already_AddRefed<Exception>
-CreateException(JSContext* aCx, nsresult aRv,
-                const nsACString& aMessage = EmptyCString());
+CreateException(nsresult aRv, const nsACString& aMessage = EmptyCString());
 
 // aMaxDepth can be used to define a maximal depth for the stack trace. If the
 // value is -1, a default maximal depth will be selected.  Will return null if
 // there is no JS stack right now.
 already_AddRefed<nsIStackFrame>
 GetCurrentJSStack(int32_t aMaxDepth = -1);
 
 // Internal stuff not intended to be widely used.
--- a/dom/bindings/ToJSValue.cpp
+++ b/dom/bindings/ToJSValue.cpp
@@ -39,17 +39,17 @@ ToJSValue(JSContext* aCx, const nsAStrin
 }
 
 
 bool
 ToJSValue(JSContext* aCx,
           nsresult aArgument,
           JS::MutableHandle<JS::Value> aValue)
 {
-  RefPtr<Exception> exception = CreateException(aCx, aArgument);
+  RefPtr<Exception> exception = CreateException(aArgument);
   return ToJSValue(aCx, exception, aValue);
 }
 
 bool
 ToJSValue(JSContext* aCx,
           ErrorResult& aArgument,
           JS::MutableHandle<JS::Value> aValue)
 {