bug 1442776 get CycleCollectedJSContext from JSContext private when available in dom/bindings methods r?peterv
MozReview-Commit-ID: CRcDrKxIq0L
--- 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) {