Bug 1643635, it is ok to have a cycle collected non-nsISupports class which doesn't inherit nsWrapperCache, r=mccr8,peterv
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 05 Jun 2020 15:29:05 +0000
changeset 598246 431b35a5b06ce4e543a38d35a38e2625a9ae2314
parent 598245 33847bf1cfbb5c7203b42c397b10da217d367bc7
child 598247 8a842264000abd7a68075a03394e70e5af43046e
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8, peterv
bugs1643635, 1642974
milestone79.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 1643635, it is ok to have a cycle collected non-nsISupports class which doesn't inherit nsWrapperCache, r=mccr8,peterv The method lets one to have nsISupports objects not supporting nsWrapperCache, but non-nsISupports objects are required to inherit nsWrapperCache because of the assertion. jonco is adding tests in https://bugzilla.mozilla.org/show_bug.cgi?id=1642974 Differential Revision: https://phabricator.services.mozilla.com/D78478
dom/bindings/BindingUtils.cpp
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -1138,23 +1138,23 @@ bool TryPreserveWrapper(JS::Handle<JSObj
   const DOMJSClass* domClass = GetDOMClass(obj);
   const JSClass* clasp = domClass->ToJSClass();
   JSAddPropertyOp addProperty = clasp->getAddProperty();
 
   // We expect all proxies to be nsISupports.
   MOZ_RELEASE_ASSERT(!clasp->isProxy(),
                      "Should not call addProperty for proxies.");
 
-  // The class should have an addProperty hook iff it is a CC participant.
-  MOZ_RELEASE_ASSERT(bool(domClass->mParticipant) == bool(addProperty));
-
   if (!addProperty) {
     return true;
   }
 
+  // The class should have an addProperty hook iff it is a CC participant.
+  MOZ_RELEASE_ASSERT(domClass->mParticipant);
+
   JS::Rooted<jsid> dummyId(RootingCx());
   JS::Rooted<JS::Value> dummyValue(RootingCx());
   return addProperty(nullptr, obj, dummyId, dummyValue);
 }
 
 // Can only be called with a DOM JSClass.
 bool InstanceClassHasProtoAtDepth(const JSClass* clasp, uint32_t protoID,
                                   uint32_t depth) {