Skip to content

Commit

Permalink
Bug 956569 - Make nsContentUtils::WrapNative MOZ_WARN_UNUSED_RESULT. …
Browse files Browse the repository at this point in the history
…r=smaug
  • Loading branch information
amccreight committed Jan 6, 2014
1 parent 194d76d commit 6f5b258
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions content/base/public/nsContentUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,7 @@ class nsContentUtils
*/
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,
Expand All @@ -1646,12 +1647,15 @@ class nsContentUtils
}

// 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,
Expand Down
6 changes: 4 additions & 2 deletions content/base/src/nsFrameMessageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,8 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,

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) {
Expand Down Expand Up @@ -1016,7 +1017,8 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
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) ||
Expand Down

0 comments on commit 6f5b258

Please sign in to comment.