Bug 1595890 part 4. Remove XPCWrappedNativeScope::EnsureContentXBLScope. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 14 Nov 2019 05:20:41 +0000
changeset 501886 56ac0284574922f408585caa1b45162421d04c5b
parent 501885 810924c606882d4c235729bed6690e713f5bca9e
child 501887 9087a6d0879514755548085bf9228f600205f7e3
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1595890
milestone72.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 1595890 part 4. Remove XPCWrappedNativeScope::EnsureContentXBLScope. r=bholley It's dead code. Differential Revision: https://phabricator.services.mozilla.com/D52747
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/src/xpcpublic.h
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -183,54 +183,29 @@ bool XPCWrappedNativeScope::AttachCompon
   DEFINE_SUBCOMPONENT_PROPERTY(c, Utils, &NS_GET_IID(nsIXPCComponents_Utils),
                                CU)
 
 #undef DEFINE_SUBCOMPONENT_PROPERTY
 
   return true;
 }
 
-JSObject* XPCWrappedNativeScope::EnsureContentXBLScope(JSContext* cx) {
-  JS::RootedObject global(cx, CurrentGlobalOrNull(cx));
-  MOZ_ASSERT(js::IsObjectInContextCompartment(global, cx));
-  MOZ_ASSERT(strcmp(js::GetObjectClass(global)->name,
-                    "nsXBLPrototypeScript compilation scope"));
-
-  // We can probably remove EnsureContentXBLScope and clean up all its callers,
-  // but a bunch (all?) of those callers will just go away when we remove XBL
-  // support, so it's simpler to just leave it here as a no-op.
-  return global;
-}
-
 bool XPCWrappedNativeScope::XBLScopeStateMatches(nsIPrincipal* aPrincipal) {
   return mAllowContentXBLScope ==
          !RemoteXULForbidsXBLScopeForPrincipal(aPrincipal);
 }
 
 bool XPCWrappedNativeScope::AllowContentXBLScope(Realm* aRealm) {
   // We only disallow XBL scopes in remote XUL situations.
   MOZ_ASSERT_IF(!mAllowContentXBLScope, nsContentUtils::AllowXULXBLForPrincipal(
                                             xpc::GetRealmPrincipal(aRealm)));
   return mAllowContentXBLScope;
 }
 
 namespace xpc {
-JSObject* GetXBLScope(JSContext* cx, JSObject* contentScopeArg) {
-  JS::RootedObject contentScope(cx, contentScopeArg);
-  JSAutoRealm ar(cx, contentScope);
-  XPCWrappedNativeScope* nativeScope = ObjectScope(contentScope);
-
-  RootedObject scope(cx, nativeScope->EnsureContentXBLScope(cx));
-  NS_ENSURE_TRUE(scope, nullptr);  // See bug 858642.
-
-  scope = js::UncheckedUnwrap(scope);
-  JS::ExposeObjectToActiveJS(scope);
-  return scope;
-}
-
 JSObject* GetUAWidgetScope(JSContext* cx, JSObject* contentScopeArg) {
   JS::RootedObject contentScope(cx, contentScopeArg);
   JSAutoRealm ar(cx, contentScope);
   nsIPrincipal* principal = GetObjectPrincipal(contentScope);
 
   if (nsContentUtils::IsSystemPrincipal(principal)) {
     return JS::GetNonCCWObjectGlobal(contentScope);
   }
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -874,22 +874,16 @@ class XPCWrappedNativeScope final
     size_t mProtoAndIfaceCacheSize;
   };
 
   static void AddSizeOfAllScopesIncludingThis(JSContext* cx,
                                               ScopeSizeInfo* scopeSizeInfo);
 
   void AddSizeOfIncludingThis(JSContext* cx, ScopeSizeInfo* scopeSizeInfo);
 
-  // Gets the appropriate scope object for XBL in this compartment. This method
-  // relies on compartment-per-global still (and release-asserts this). The
-  // context must be same-realm with this compartment's single global upon
-  // entering, and the scope object is wrapped into this compartment.
-  JSObject* EnsureContentXBLScope(JSContext* cx);
-
   // Check whether our mAllowContentXBLScope state matches the given
   // principal.  This is used to avoid sharing compartments on
   // mismatch.
   bool XBLScopeStateMatches(nsIPrincipal* aPrincipal);
 
   XPCWrappedNativeScope(JS::Compartment* aCompartment,
                         JS::HandleObject aFirstGlobal);
   virtual ~XPCWrappedNativeScope();
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -94,40 +94,20 @@ JSObject* TransplantObjectNukingXrayWaiv
 bool IsUAWidgetCompartment(JS::Compartment* compartment);
 bool IsUAWidgetScope(JS::Realm* realm);
 bool IsInUAWidgetScope(JSObject* obj);
 
 bool MightBeWebContentCompartment(JS::Compartment* compartment);
 
 void SetCompartmentChangedDocumentDomain(JS::Compartment* compartment);
 
-// Return a raw XBL scope object corresponding to contentScope, which must
-// be an object whose global is a DOM window.
-//
-// The return value is not wrapped into cx->compartment, so be sure to enter
-// its compartment before doing anything meaningful.
-//
-// Also note that XBL scopes are lazily created, so the return-value should be
-// null-checked unless the caller can ensure that the scope must already
-// exist.
-//
-// This function asserts if |contentScope| is itself in an XBL scope to catch
-// sloppy consumers. Conversely, GetXBLScopeOrGlobal will handle objects that
-// are in XBL scope (by just returning the global).
-JSObject* GetXBLScope(JSContext* cx, JSObject* contentScope);
-
 JSObject* GetUAWidgetScope(JSContext* cx, nsIPrincipal* principal);
 
 JSObject* GetUAWidgetScope(JSContext* cx, JSObject* contentScope);
 
-inline JSObject* GetXBLScopeOrGlobal(JSContext* cx, JSObject* obj) {
-  MOZ_ASSERT(!js::IsCrossCompartmentWrapper(obj));
-  return GetXBLScope(cx, obj);
-}
-
 // Returns whether XBL scopes have been explicitly disabled for code running
 // in this compartment. See the comment around mAllowContentXBLScope.
 bool AllowContentXBLScope(JS::Realm* realm);
 
 // Get the scope for creating reflectors for native anonymous content
 // whose normal global would be the given global.
 JSObject* NACScope(JSObject* global);