Bug 1432526 - Replace simple uses of NativeInterface2JSObject with ToJSValue. r=bz
ToJSValue is easier to understand.
MozReview-Commit-ID: rpV5aiUTM9
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -1157,23 +1157,18 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
nsCOMPtr<nsISupports> newThis;
if (NS_FAILED(translator->
TranslateThis((nsISupports*)nativeParams[0].val.p,
getter_AddRefs(newThis)))) {
goto pre_call_clean_up;
}
if (newThis) {
RootedValue v(cx);
- xpcObjectHelper helper(newThis);
- bool ok =
- XPCConvert::NativeInterface2JSObject(
- &v, helper, nullptr, false, nullptr);
- if (!ok) {
+ if (!ToJSValue(cx, newThis, &v))
goto pre_call_clean_up;
- }
thisObj = v.toObjectOrNull();
if (!JS_WrapObject(cx, &thisObj))
goto pre_call_clean_up;
}
}
}
}
}
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -194,20 +194,17 @@ XPCWrappedNativeScope::GetComponentsJSOb
if (!mComponents) {
nsIPrincipal* p = GetPrincipal();
bool system = nsXPConnect::SecurityManager()->IsSystemPrincipal(p);
mComponents = system ? new nsXPCComponents(this)
: new nsXPCComponentsBase(this);
}
RootedValue val(cx);
- xpcObjectHelper helper(mComponents);
- bool ok = XPCConvert::NativeInterface2JSObject(&val, helper, nullptr,
- false, nullptr);
- if (NS_WARN_IF(!ok))
+ if (!ToJSValue(cx, mComponents, &val))
return false;
if (NS_WARN_IF(!val.isObject()))
return false;
// The call to wrap() here is necessary even though the object is same-
// compartment, because it applies our security wrapper.
obj.set(&val.toObject());