bug 1467023 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 804503 a8be75ac9f0dbdce831566853e26c663cd9b0691
parent 804498 3c2accb71faf3f017a44c405ae0484e57aaf039c
push id112393
push userktomlinson@mozilla.com
push dateWed, 06 Jun 2018 04:27:45 +0000
reviewerspeterv
bugs1467023
milestone62.0a1
bug 1467023 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
@@ -2380,19 +2380,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) {