Bug 1053271 - Remove some unused XRayWrapper code. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 04 Jun 2018 16:37:04 +0200
changeset 805268 509dc862a71ad7fbdcd19a257877085a6b5d21b1
parent 805267 00275042e5174f27f4a7697326dfd4a2a1c6c854
child 805269 eb4f880a8aa431cf6260aae3709f887bfdd6502f
push id112610
push userbmo:gl@mozilla.com
push dateThu, 07 Jun 2018 15:48:24 +0000
reviewersbz
bugs1053271
milestone62.0a1
Bug 1053271 - Remove some unused XRayWrapper code. r=bz.
js/xpconnect/src/xpcpublic.h
js/xpconnect/wrappers/XrayWrapper.cpp
js/xpconnect/wrappers/XrayWrapper.h
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -136,33 +136,16 @@ IsXrayWrapper(JSObject* obj);
 // If this function was created for a given XrayWrapper, returns the global of
 // the Xrayed object. Otherwise, returns the global of the function.
 //
 // To emphasize the obvious: the return value here is not necessarily same-
 // compartment with the argument.
 JSObject*
 XrayAwareCalleeGlobal(JSObject* fun);
 
-// A version of XrayAwareCalleeGlobal that can be used from a binding
-// specialized getter.  We need this function because in a specialized getter we
-// don't have a callee JSFunction, so can't use xpc::XrayAwareCalleeGlobal.
-// Instead we do something a bit hacky using our current compartment and "this"
-// value.  Note that for the Xray case thisObj will NOT be in the compartment of
-// "cx".
-//
-// As expected, the outparam "global" need not be same-compartment with either
-// thisObj or cx, though it _will_ be same-compartment with one of them.
-//
-// This function can fail; the return value indicates success or failure.
-bool
-XrayAwareCalleeGlobalForSpecializedGetters(JSContext* cx,
-                                           JS::Handle<JSObject*> thisObj,
-                                           JS::MutableHandle<JSObject*> global);
-
-
 void
 TraceXPCGlobal(JSTracer* trc, JSObject* obj);
 
 /**
  * Creates a new global object using the given aCOMObj as the global
  * object. The object will be set up according to the flags (defined
  * below). If you do not pass INIT_JS_STANDARD_CLASSES, then aCOMObj
  * must implement nsIXPCScriptable so it can resolve the standard
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -140,49 +140,16 @@ XrayAwareCalleeGlobal(JSObject* fun)
   Value v =
       js::GetFunctionNativeReserved(fun, XRAY_DOM_FUNCTION_PARENT_WRAPPER_SLOT);
   MOZ_ASSERT(IsXrayWrapper(&v.toObject()));
 
   JSObject* xrayTarget = js::UncheckedUnwrap(&v.toObject());
   return js::GetGlobalForObjectCrossCompartment(xrayTarget);
 }
 
-bool
-XrayAwareCalleeGlobalForSpecializedGetters(JSContext* cx,
-                                           JS::Handle<JSObject*> thisObj,
-                                           JS::MutableHandle<JSObject*> global)
-{
-    JS::Rooted<JSObject*> wrappedObj(cx, thisObj);
-    if (!JS_WrapObject(cx, &wrappedObj)) {
-        return false;
-    }
-
-    if (xpc::WrapperFactory::IsXrayWrapper(wrappedObj)) {
-        // Our current compartment would generaly get xrays to thisObj.  That
-        // means we're presumably doing a call over Xrays, an the compartment of
-        // the callee is presumably that of thisObj.  This isn't _necessarily_
-        // true (e.g. chrome code could be using a chrome-side getter and doing
-        // .call() with a content-side this value), but people shouldn't do
-        // that!
-        //
-        // If someoen does do something weird here, the only impact is that we
-        // will create the rejected promise that a promise-returning getter
-        // creates around any exceptions it throws in the "wrong" compartment.
-        // In particular, we might create it in the content compartment even
-        // though we should really have created it in the chrome compartment
-        // (for the case when a chrome getter is invoked with a content object
-        // instead of just invoking the xrayed getter).
-        global.set(js::GetGlobalForObjectCrossCompartment(thisObj));
-        return true;
-    }
-
-    global.set(JS::CurrentGlobalOrNull(cx));
-    return true;
-}
-
 JSObject*
 XrayTraits::getExpandoChain(HandleObject obj)
 {
     return ObjectScope(obj)->GetExpandoChain(obj);
 }
 
 JSObject*
 XrayTraits::detachExpandoChain(HandleObject obj)
@@ -1358,22 +1325,16 @@ EnsureXrayExpandoObject(JSContext* cx, J
 const JSClass*
 XrayTraits::getExpandoClass(JSContext* cx, HandleObject target) const
 {
     return &DefaultXrayExpandoObjectClass;
 }
 
 static const size_t JSSLOT_XRAY_HOLDER = 0;
 
-static JSObject*
-GetHolder(JSObject* obj)
-{
-    return &js::GetProxyReservedSlot(obj, JSSLOT_XRAY_HOLDER).toObject();
-}
-
 /* static */ JSObject*
 XrayTraits::getHolder(JSObject* wrapper)
 {
     MOZ_ASSERT(WrapperFactory::IsXrayWrapper(wrapper));
     js::Value v = js::GetProxyReservedSlot(wrapper, JSSLOT_XRAY_HOLDER);
     return v.isObject() ? &v.toObject() : nullptr;
 }
 
@@ -1702,27 +1663,16 @@ DOMXrayTraits::createHolder(JSContext* c
 const JSClass*
 DOMXrayTraits::getExpandoClass(JSContext* cx, HandleObject target) const
 {
     return XrayGetExpandoClass(cx, target);
 }
 
 namespace XrayUtils {
 
-JSObject*
-GetNativePropertiesObject(JSContext* cx, JSObject* wrapper)
-{
-    MOZ_ASSERT(js::IsWrapper(wrapper) && WrapperFactory::IsXrayWrapper(wrapper),
-               "bad object passed in");
-
-    JSObject* holder = GetHolder(wrapper);
-    MOZ_ASSERT(holder, "uninitialized wrapper being used?");
-    return holder;
-}
-
 bool
 HasNativeProperty(JSContext* cx, HandleObject wrapper, HandleId id, bool* hasProp)
 {
     MOZ_ASSERT(WrapperFactory::IsXrayWrapper(wrapper));
     XrayTraits* traits = GetXrayTraits(wrapper);
     MOZ_ASSERT(traits);
     RootedObject target(cx, XrayTraits::getTargetObject(wrapper));
     RootedObject holder(cx, traits->ensureHolder(cx, wrapper));
--- a/js/xpconnect/wrappers/XrayWrapper.h
+++ b/js/xpconnect/wrappers/XrayWrapper.h
@@ -32,19 +32,16 @@ class nsIPrincipal;
 
 namespace xpc {
 
 namespace XrayUtils {
 
 bool
 IsTransparent(JSContext* cx, JS::HandleObject wrapper, JS::HandleId id);
 
-JSObject*
-GetNativePropertiesObject(JSContext* cx, JSObject* wrapper);
-
 bool
 HasNativeProperty(JSContext* cx, JS::HandleObject wrapper, JS::HandleId id,
                   bool* hasProp);
 } // namespace XrayUtils
 
 enum XrayType {
     XrayForDOMObject,
     XrayForJSObject,
@@ -460,18 +457,16 @@ class XrayWrapper : public Base {
 #define PermissiveXrayJS xpc::XrayWrapper<js::CrossCompartmentWrapper, xpc::JSXrayTraits>
 #define PermissiveXrayOpaque xpc::XrayWrapper<js::CrossCompartmentWrapper, xpc::OpaqueXrayTraits>
 
 extern template class PermissiveXrayDOM;
 extern template class SecurityXrayDOM;
 extern template class PermissiveXrayJS;
 extern template class PermissiveXrayOpaque;
 
-class AutoSetWrapperNotShadowing;
-
 /*
  * Slots for Xray expando objects.  See comments in XrayWrapper.cpp for details
  * of how these get used; we mostly want the value of JSSLOT_EXPANDO_COUNT here.
  */
 enum ExpandoSlots {
     JSSLOT_EXPANDO_NEXT = 0,
     JSSLOT_EXPANDO_ORIGIN,
     JSSLOT_EXPANDO_EXCLUSIVE_WRAPPER_HOLDER,