bug 1442776 get CycleCollectedJSContext from JSContext private when available in dom/bindings methods r?peterv draft
authorKarl Tomlinson <karlt+@karlt.net>
Mon, 16 Apr 2018 18:27:48 +1200
changeset 799719 2518eb667330cd17983b246844dfb9fa5a4f04f9
parent 799718 1c41ae7dc4ea4e017092c7e2c1499d80dc113855
push id111147
push userktomlinson@mozilla.com
push dateFri, 25 May 2018 07:47:17 +0000
reviewerspeterv
bugs1442776
milestone62.0a1
bug 1442776 get CycleCollectedJSContext from JSContext private when available in dom/bindings methods r?peterv MozReview-Commit-ID: CRcDrKxIq0L
dom/base/nsContentUtils.cpp
dom/bindings/Exceptions.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -2363,19 +2363,17 @@ nsContentUtils::IsSystemCaller(JSContext
 {
   // Note that SubjectPrincipal() assumes we are in a compartment here.
   return SubjectPrincipal(aCx) == sSystemPrincipal;
 }
 
 bool
 nsContentUtils::ThreadsafeIsSystemCaller(JSContext* aCx)
 {
-  CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
-  MOZ_ASSERT(ccjscx->Context() == aCx);
-
+  CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::GetFor(aCx);
   return ccjscx->IsSystemCaller();
 }
 
 // static
 bool
 nsContentUtils::LookupBindingMember(JSContext* aCx, nsIContent *aContent,
                                     JS::Handle<jsid> aId,
                                     JS::MutableHandle<JS::PropertyDescriptor> aDesc)
--- a/dom/bindings/Exceptions.cpp
+++ b/dom/bindings/Exceptions.cpp
@@ -115,17 +115,17 @@ Throw(JSContext* aCx, nsresult aRv, cons
     return false;
   }
 
   if (JS_IsExceptionPending(aCx)) {
     // Don't clobber the existing exception.
     return false;
   }
 
-  CycleCollectedJSContext* context = CycleCollectedJSContext::Get();
+  CycleCollectedJSContext* context = CycleCollectedJSContext::GetFor(aCx);
   RefPtr<Exception> existingException = context->GetPendingException();
   // Make sure to clear the pending exception now.  Either we're going to reuse
   // it (and we already grabbed it), or we plan to throw something else and this
   // pending exception is no longer relevant.
   context->SetPendingException(nullptr);
 
   // Ignore the pending exception if we have a non-default message passed in.
   if (aMessage.IsEmpty() && existingException) {