Bug 1595890 part 2. Remove isContentXBLCompartment from CompartmentPrivate. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 14 Nov 2019 05:18:54 +0000
changeset 501884 abee66548e14e53e74efc32050bfea474edce916
parent 501883 cd89e23dd64d2c4e3bd846bdf5437167163abc7d
child 501885 810924c606882d4c235729bed6690e713f5bca9e
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 2. Remove isContentXBLCompartment from CompartmentPrivate. r=bholley It's always false. Differential Revision: https://phabricator.services.mozilla.com/D52743
js/xpconnect/src/Sandbox.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -1168,25 +1168,23 @@ nsresult xpc::CreateSandboxObject(JSCont
   if (creationOptions.compartmentSpecifier() ==
       JS::CompartmentSpecifier::ExistingCompartment) {
     // Make sure the compartment we're reusing has flags that match what we
     // would set on a new compartment.
     CompartmentPrivate* priv = CompartmentPrivate::Get(sandbox);
     MOZ_RELEASE_ASSERT(priv->allowWaivers == options.allowWaivers);
     MOZ_RELEASE_ASSERT(priv->isWebExtensionContentScript ==
                        options.isWebExtensionContentScript);
-    MOZ_RELEASE_ASSERT(priv->isContentXBLCompartment == false);
     MOZ_RELEASE_ASSERT(priv->isUAWidgetCompartment == options.isUAWidgetScope);
     MOZ_RELEASE_ASSERT(priv->hasExclusiveExpandos == hasExclusiveExpandos);
     MOZ_RELEASE_ASSERT(priv->wantXrays == wantXrays);
   } else {
     CompartmentPrivate* priv = CompartmentPrivate::Get(sandbox);
     priv->allowWaivers = options.allowWaivers;
     priv->isWebExtensionContentScript = options.isWebExtensionContentScript;
-    priv->isContentXBLCompartment = false;
     priv->isUAWidgetCompartment = options.isUAWidgetScope;
     priv->hasExclusiveExpandos = hasExclusiveExpandos;
     priv->wantXrays = wantXrays;
   }
 
   {
     JSAutoRealm ar(cx, sandbox);
 
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -192,17 +192,16 @@ namespace xpc {
 CompartmentPrivate::CompartmentPrivate(
     JS::Compartment* c, mozilla::UniquePtr<XPCWrappedNativeScope> scope,
     mozilla::BasePrincipal* origin, const SiteIdentifier& site)
     : originInfo(origin, site),
       wantXrays(false),
       allowWaivers(true),
       isWebExtensionContentScript(false),
       allowCPOWs(false),
-      isContentXBLCompartment(false),
       isUAWidgetCompartment(false),
       hasExclusiveExpandos(false),
       universalXPConnectEnabled(false),
       wasShutdown(false),
       mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_LENGTH)),
       mScope(std::move(scope)) {
   MOZ_COUNT_CTOR(xpc::CompartmentPrivate);
 }
@@ -493,21 +492,17 @@ void Scriptability::SetDocShellAllowsScr
   mDocShellAllowsScript = aAllowed || mImmuneToScriptPolicy;
 }
 
 /* static */
 Scriptability& Scriptability::Get(JSObject* aScope) {
   return RealmPrivate::Get(aScope)->scriptability;
 }
 
-bool IsContentXBLCompartment(JS::Compartment* compartment) {
-  // We always eagerly create compartment privates for content XBL compartments.
-  CompartmentPrivate* priv = CompartmentPrivate::Get(compartment);
-  return priv && priv->isContentXBLCompartment;
-}
+bool IsContentXBLCompartment(JS::Compartment* compartment) { return false; }
 
 bool IsContentXBLScope(JS::Realm* realm) {
   return IsContentXBLCompartment(JS::GetCompartmentForRealm(realm));
 }
 
 bool IsInContentXBLScope(JSObject* obj) {
   return IsContentXBLCompartment(js::GetObjectCompartment(obj));
 }
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -2643,18 +2643,17 @@ class CompartmentPrivate {
   bool CanShareCompartmentWith(nsIPrincipal* principal) {
     // Only share if we're same-origin with the principal.
     if (!originInfo.IsSameOrigin(principal)) {
       return false;
     }
 
     // Don't share if we have any weird state set.
     return !wantXrays && !isWebExtensionContentScript &&
-           !isContentXBLCompartment && !isUAWidgetCompartment &&
-           !universalXPConnectEnabled &&
+           !isUAWidgetCompartment && !universalXPConnectEnabled &&
            mScope->XBLScopeStateMatches(principal);
   }
 
   CompartmentOriginInfo originInfo;
 
   // Controls whether this compartment gets Xrays to same-origin. This behavior
   // is deprecated, but is still the default for sandboxes for compatibity
   // reasons.
@@ -2672,20 +2671,16 @@ class CompartmentPrivate {
 
   // If CPOWs are disabled for browser code via the
   // dom.ipc.cpows.forbid-unsafe-from-browser preferences, then only
   // add-ons can use CPOWs. This flag allows a non-addon scope
   // to opt into CPOWs. It's necessary for the implementation of
   // RemoteAddonsParent.jsm.
   bool allowCPOWs;
 
-  // True if this compartment is a content XBL compartment. Every global in
-  // such a compartment is a content XBL scope.
-  bool isContentXBLCompartment;
-
   // True if this compartment is a UA widget compartment.
   bool isUAWidgetCompartment;
 
   // See CompartmentHasExclusiveExpandos.
   bool hasExclusiveExpandos;
 
   // This is only ever set during mochitest runs when enablePrivilege is called.
   // It's intended as a temporary stopgap measure until we can finish ripping