зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1479712 part 4 - Use JSAutoRealm instead of JSAutoRealmAllowCCW in NativeInterface2JSObject. r=bholley
Also fixes some callers to not pass a potential CCW.
This commit is contained in:
Родитель
1d54f66140
Коммит
4cda94fb7d
|
@ -755,7 +755,7 @@ nsJSCID::HasInstance(nsIXPConnectWrappedNative* wrapper,
|
|||
// additional utilities...
|
||||
|
||||
JSObject*
|
||||
xpc_NewIDObject(JSContext* cx, HandleObject jsobj, const nsID& aID)
|
||||
xpc_NewIDObject(JSContext* cx, HandleObject scope, const nsID& aID)
|
||||
{
|
||||
RootedObject obj(cx);
|
||||
|
||||
|
@ -763,7 +763,7 @@ xpc_NewIDObject(JSContext* cx, HandleObject jsobj, const nsID& aID)
|
|||
if (iid) {
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
if (xpc) {
|
||||
xpc->WrapNative(cx, jsobj, static_cast<nsISupports*>(iid),
|
||||
xpc->WrapNative(cx, scope, static_cast<nsISupports*>(iid),
|
||||
NS_GET_IID(nsIJSID), obj.address());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,7 +195,8 @@ GetLocationProperty(JSContext* cx, unsigned argc, Value* vp)
|
|||
!symlink)
|
||||
location->Normalize();
|
||||
RootedObject locationObj(cx);
|
||||
rv = nsXPConnect::XPConnect()->WrapNative(cx, &args.thisv().toObject(),
|
||||
RootedObject scope(cx, JS::CurrentGlobalOrNull(cx));
|
||||
rv = nsXPConnect::XPConnect()->WrapNative(cx, scope,
|
||||
location,
|
||||
NS_GET_IID(nsIFile),
|
||||
locationObj.address());
|
||||
|
|
|
@ -240,7 +240,11 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if ((id = xpc_NewIDObject(cx, jsobj, aIID))) {
|
||||
// AutoScriptEvaluate entered jsobj's realm.
|
||||
js::AssertSameCompartment(cx, jsobj);
|
||||
RootedObject scope(cx, JS::CurrentGlobalOrNull(cx));
|
||||
|
||||
if ((id = xpc_NewIDObject(cx, scope, aIID))) {
|
||||
// Throwing NS_NOINTERFACE is the prescribed way to fail QI from JS. It
|
||||
// is not an exception that is ever worth reporting, but we don't want
|
||||
// to eat all exceptions either.
|
||||
|
|
|
@ -604,7 +604,7 @@ NativeInterface2JSObject(HandleObject aScope,
|
|||
MutableHandleValue aVal)
|
||||
{
|
||||
AutoJSContext cx;
|
||||
JSAutoRealmAllowCCW ar(cx, aScope);
|
||||
JSAutoRealm ar(cx, aScope);
|
||||
|
||||
nsresult rv;
|
||||
xpcObjectHelper helper(aCOMObj, aCache);
|
||||
|
|
|
@ -2213,7 +2213,7 @@ protected:
|
|||
/***************************************************************************/
|
||||
|
||||
extern JSObject*
|
||||
xpc_NewIDObject(JSContext* cx, JS::HandleObject jsobj, const nsID& aID);
|
||||
xpc_NewIDObject(JSContext* cx, JS::HandleObject scope, const nsID& aID);
|
||||
|
||||
extern const nsID*
|
||||
xpc_JSObjectToID(JSContext* cx, JSObject* obj);
|
||||
|
|
Загрузка…
Ссылка в новой задаче