Bug 956569 - Make nsContentUtils::WrapNative MOZ_WARN_UNUSED_RESULT. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Mon, 06 Jan 2014 11:54:43 -0800
changeset 179284 c25ee7b8c1851d78a5f45ef83cfdf070ce7d4adb
parent 179283 b997d2cce0ebf85e08a34a82d349994218c9c635
child 179285 643150e6bb9d36dc40fd6579b6c96882b53216ff
push id462
push userraliiev@mozilla.com
push dateTue, 22 Apr 2014 00:22:30 +0000
treeherdermozilla-release@ac5db8c74ac0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs956569
milestone29.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 956569 - Make nsContentUtils::WrapNative MOZ_WARN_UNUSED_RESULT. r=smaug
content/base/public/nsContentUtils.h
content/base/src/nsFrameMessageManager.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -1632,31 +1632,35 @@ public:
 
   /**
    * The method checks whether the caller can access native anonymous content.
    * If there is no JS in the stack or privileged JS is running, this
    * method returns true, otherwise false.
    */
   static bool CanAccessNativeAnon();
 
+  MOZ_WARN_UNUSED_RESULT
   static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
                              nsISupports *native, const nsIID* aIID,
                              JS::MutableHandle<JS::Value> vp,
                              bool aAllowWrapping = false)
   {
     return WrapNative(cx, scope, native, nullptr, aIID, vp, aAllowWrapping);
   }
 
   // Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
+  MOZ_WARN_UNUSED_RESULT
   static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
                              nsISupports *native, JS::MutableHandle<JS::Value> vp,
                              bool aAllowWrapping = false)
   {
     return WrapNative(cx, scope, native, nullptr, nullptr, vp, aAllowWrapping);
   }
+
+  MOZ_WARN_UNUSED_RESULT
   static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
                              nsISupports *native, nsWrapperCache *cache,
                              JS::MutableHandle<JS::Value> vp,
                              bool aAllowWrapping = false)
   {
     return WrapNative(cx, scope, native, cache, nullptr, vp, aAllowWrapping);
   }
 
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -921,17 +921,18 @@ nsFrameMessageManager::ReceiveMessage(ns
 
       // The parameter for the listener function.
       JS::Rooted<JSObject*> param(ctx,
         JS_NewObject(ctx, nullptr, nullptr, nullptr));
       NS_ENSURE_TRUE(param, NS_ERROR_OUT_OF_MEMORY);
 
       JS::Rooted<JS::Value> targetv(ctx);
       JS::Rooted<JSObject*> global(ctx, JS_GetGlobalForObject(ctx, object));
-      nsContentUtils::WrapNative(ctx, global, aTarget, &targetv, true);
+      nsresult rv = nsContentUtils::WrapNative(ctx, global, aTarget, &targetv, true);
+      NS_ENSURE_SUCCESS(rv, rv);
 
       JS::Rooted<JSObject*> cpows(ctx);
       if (aCpows) {
         if (!aCpows->ToObject(ctx, &cpows)) {
           return NS_ERROR_UNEXPECTED;
         }
       }
 
@@ -1011,17 +1012,18 @@ nsFrameMessageManager::ReceiveMessage(ns
         // messageManager is wrapped in TabChildGlobal.
         nsCOMPtr<nsISupports> defaultThisValue;
         if (mChrome) {
           defaultThisValue = do_QueryObject(this);
         } else {
           defaultThisValue = aTarget;
         }
         JS::Rooted<JSObject*> global(ctx, JS_GetGlobalForObject(ctx, object));
-        nsContentUtils::WrapNative(ctx, global, defaultThisValue, &thisValue, true);
+        nsresult rv = nsContentUtils::WrapNative(ctx, global, defaultThisValue, &thisValue, true);
+        NS_ENSURE_SUCCESS(rv, rv);
       } else {
         // If the listener is a JS object which has receiveMessage function:
         if (!JS_GetProperty(ctx, object, "receiveMessage", &funval) ||
             !funval.isObject())
           return NS_ERROR_UNEXPECTED;
 
         // Check if the object is even callable.
         NS_ENSURE_STATE(JS_ObjectIsCallable(ctx, &funval.toObject()));