Bug 754202 - Remove context pushing/popping API. r=mrbkap Each one of these uses grabs the principal off of an object for pushing, but also enters the compartment of that object. So we shouldn't need this anymore.
Can I get a 'hell yeah'?
This commit is contained in:
@@ -1238,9 +1238,6 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
|
||||
|
||||
jsval val;
|
||||
|
||||
rv = sSecurityManager->PushContextPrincipal(mContext, nsnull, principal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsJSContext::TerminationFuncHolder holder(this);
|
||||
|
||||
// SecurityManager said "ok", but don't compile if aVersion is unknown.
|
||||
@@ -1296,8 +1293,6 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
|
||||
}
|
||||
}
|
||||
|
||||
sSecurityManager->PopContextPrincipal(mContext);
|
||||
|
||||
// Pop here, after JS_ValueToString and any other possible evaluation.
|
||||
if (NS_FAILED(stack->Pop(nsnull)))
|
||||
rv = NS_ERROR_FAILURE;
|
||||
@@ -1446,9 +1441,6 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
||||
jsval val = JSVAL_VOID;
|
||||
jsval* vp = aRetValue ? &val : NULL;
|
||||
|
||||
rv = sSecurityManager->PushContextPrincipal(mContext, nsnull, principal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsJSContext::TerminationFuncHolder holder(this);
|
||||
|
||||
++mExecuteDepth;
|
||||
@@ -1500,8 +1492,6 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
||||
|
||||
--mExecuteDepth;
|
||||
|
||||
sSecurityManager->PopContextPrincipal(mContext);
|
||||
|
||||
// Pop here, after JS_ValueToString and any other possible evaluation.
|
||||
if (NS_FAILED(stack->Pop(nsnull)))
|
||||
rv = NS_ERROR_FAILURE;
|
||||
@@ -1599,15 +1589,6 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
rv = sSecurityManager->GetObjectPrincipal(mContext,
|
||||
JS_GetGlobalFromScript(aScriptObject),
|
||||
getter_AddRefs(principal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = sSecurityManager->PushContextPrincipal(mContext, nsnull, principal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsJSContext::TerminationFuncHolder holder(this);
|
||||
XPCAutoRequest ar(mContext);
|
||||
++mExecuteDepth;
|
||||
@@ -1634,8 +1615,6 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject,
|
||||
|
||||
--mExecuteDepth;
|
||||
|
||||
sSecurityManager->PopContextPrincipal(mContext);
|
||||
|
||||
// Pop here, after JS_ValueToString and any other possible evaluation.
|
||||
if (NS_FAILED(stack->Pop(nsnull)))
|
||||
rv = NS_ERROR_FAILURE;
|
||||
@@ -1876,24 +1855,12 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope,
|
||||
jsval *argv = nsnull;
|
||||
|
||||
JSObject *funobj = aHandler;
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
rv = sSecurityManager->GetObjectPrincipal(mContext, funobj,
|
||||
getter_AddRefs(principal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSStackFrame *currentfp = nsnull;
|
||||
rv = sSecurityManager->PushContextPrincipal(mContext,
|
||||
JS_FrameIterator(mContext, ¤tfp),
|
||||
principal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
jsval funval = OBJECT_TO_JSVAL(funobj);
|
||||
JSAutoEnterCompartment ac;
|
||||
js::ForceFrame ff(mContext, funobj);
|
||||
if (!ac.enter(mContext, funobj) || !ff.enter() ||
|
||||
!JS_WrapObject(mContext, &target)) {
|
||||
ReportPendingException();
|
||||
sSecurityManager->PopContextPrincipal(mContext);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -1936,8 +1903,6 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope,
|
||||
// nested calls through XPConnect.
|
||||
if (NS_FAILED(rv))
|
||||
ReportPendingException();
|
||||
|
||||
sSecurityManager->PopContextPrincipal(mContext);
|
||||
}
|
||||
|
||||
pusher.Pop();
|
||||
|
||||
Reference in New Issue
Block a user