Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 630202 Details for
Bug 754202
[patch]
Part 5 - Remove context pushing/popping API. v1
Bug-754202---Remove-context-pushingpopping-API-v1.patch (text/plain), 25.30 KB, created by
Bobby Holley (:bholley)
(
hide
)
Description:
Part 5 - Remove context pushing/popping API. v1
Filename:
MIME Type:
Creator:
Bobby Holley (:bholley)
Size:
25.30 KB
patch
obsolete
># HG changeset patch ># User Bobby Holley <bobbyholley@gmail.com> > >Bug 754202 - Remove context pushing/popping API. v1 > >diff --git a/caps/idl/nsIScriptSecurityManager.idl b/caps/idl/nsIScriptSecurityManager.idl >index 1eb56a1..1195ad5 100644 >--- a/caps/idl/nsIScriptSecurityManager.idl >+++ b/caps/idl/nsIScriptSecurityManager.idl >@@ -4,17 +4,17 @@ > * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ > > #include "nsISupports.idl" > #include "nsIPrincipal.idl" > #include "nsIXPCSecurityManager.idl" > interface nsIURI; > interface nsIChannel; > >-[scriptable, uuid(3708aa92-e2d9-4fd1-9e46-edfa3eb5ebf5)] >+[scriptable, uuid(cdb27711-492b-4973-938b-de81ac124658)] > interface nsIScriptSecurityManager : nsIXPCSecurityManager > { > ///////////////// Security Checks ////////////////// > /** > * Checks whether the running script is allowed to access aProperty. > */ > [noscript] void checkPropertyAccess(in JSContextPtr aJSContext, > in JSObjectPtr aJSObject, >@@ -255,37 +255,14 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager > * Same as getSubjectPrincipal(), only faster. cx must *never* be > * passed null, and it must be the context on the top of the > * context stack. Does *not* reference count the returned > * principal. > */ > [noscript,notxpcom] nsIPrincipal getCxSubjectPrincipal(in JSContextPtr cx); > [noscript,notxpcom] nsIPrincipal getCxSubjectPrincipalAndFrame(in JSContextPtr cx, > out JSStackFramePtr fp); >- >- /** >- * If no scripted code is running "above" (or called from) fp, then >- * instead of looking at cx->globalObject, we will return |principal|. >- * This function only affects |cx|. If someone pushes another context onto >- * the context stack, then it supersedes this call. >- * NOTE: If |fp| is non-null popContextPrincipal must be called before fp >- * has finished executing. >- * >- * @param cx The context to clamp. >- * @param fp The frame pointer to clamp at. May be 'null'. >- * @param principal The principal to clamp to. >- */ >- [noscript] void pushContextPrincipal(in JSContextPtr cx, >- in JSStackFramePtr fp, >- in nsIPrincipal principal); >- >- /** >- * Removes a clamp set by pushContextPrincipal from cx. This must be >- * called in a stack-like fashion (e.g., given two contexts |a| and |b|, >- * it is not legal to do: push(a) push(b) pop(a)). >- */ >- [noscript] void popContextPrincipal(in JSContextPtr cx); > }; > > %{C++ > #define NS_SCRIPTSECURITYMANAGER_CONTRACTID "@mozilla.org/scriptsecuritymanager;1" > #define NS_SCRIPTSECURITYMANAGER_CLASSNAME "scriptsecuritymanager" > %} >diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp >index b579673..329c3aa 100644 >--- a/caps/src/nsScriptSecurityManager.cpp >+++ b/caps/src/nsScriptSecurityManager.cpp >@@ -157,54 +157,16 @@ GetPrincipalDomainOrigin(nsIPrincipal* aPrincipal, > } > > static nsIScriptContext * > GetScriptContext(JSContext *cx) > { > return GetScriptContextFromJSContext(cx); > } > >-// Callbacks for the JS engine to use to push/pop context principals. >-static JSBool >-PushPrincipalCallback(JSContext *cx, JSPrincipals *principals) >-{ >- // We should already be in the compartment of the given principal. >- MOZ_ASSERT(principals == >- JS_GetCompartmentPrincipals((js::GetContextCompartment(cx)))); >- >- // Get the security manager. >- nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager(); >- if (!ssm) { >- return true; >- } >- >- // Push the principal. >- JSStackFrame *fp = NULL; >- nsresult rv = ssm->PushContextPrincipal(cx, JS_FrameIterator(cx, &fp), >- nsJSPrincipals::get(principals)); >- if (NS_FAILED(rv)) { >- JS_ReportOutOfMemory(cx); >- return false; >- } >- >- return true; >-} >- >-static JSBool >-PopPrincipalCallback(JSContext *cx) >-{ >- nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager(); >- if (ssm) { >- ssm->PopContextPrincipal(cx); >- } >- >- return true; >-} >- >- > inline void SetPendingException(JSContext *cx, const char *aMsg) > { > JSAutoRequest ar(cx); > JS_ReportError(cx, "%s", aMsg); > } > > inline void SetPendingException(JSContext *cx, const PRUnichar *aMsg) > { >@@ -399,44 +361,16 @@ nsScriptSecurityManager::GetCxSubjectPrincipalAndFrame(JSContext *cx, JSStackFra > nsresult rv = NS_ERROR_FAILURE; > nsIPrincipal *principal = GetPrincipalAndFrame(cx, fp, &rv); > if (NS_FAILED(rv)) > return nsnull; > > return principal; > } > >-NS_IMETHODIMP >-nsScriptSecurityManager::PushContextPrincipal(JSContext *cx, >- JSStackFrame *fp, >- nsIPrincipal *principal) >-{ >- NS_ASSERTION(principal, "Must pass a non-null principal"); >- >- ContextPrincipal *cp = new ContextPrincipal(mContextPrincipals, cx, fp, >- principal); >- if (!cp) >- return NS_ERROR_OUT_OF_MEMORY; >- >- mContextPrincipals = cp; >- return NS_OK; >-} >- >-NS_IMETHODIMP >-nsScriptSecurityManager::PopContextPrincipal(JSContext *cx) >-{ >- NS_ASSERTION(mContextPrincipals->mCx == cx, "Mismatched push/pop"); >- >- ContextPrincipal *next = mContextPrincipals->mNext; >- delete mContextPrincipals; >- mContextPrincipals = next; >- >- return NS_OK; >-} >- > //////////////////// > // Policy Storage // > //////////////////// > > // Table of security levels > static bool > DeleteCapability(nsHashKey *aKey, void *aData, void* closure) > { >@@ -3123,19 +3057,17 @@ nsresult nsScriptSecurityManager::Init() > > rv = runtimeService->GetRuntime(&sRuntime); > NS_ENSURE_SUCCESS(rv, rv); > > static const JSSecurityCallbacks securityCallbacks = { > CheckObjectAccess, > nsJSPrincipals::Subsume, > ObjectPrincipalFinder, >- ContentSecurityPolicyPermitsJSAction, >- PushPrincipalCallback, >- PopPrincipalCallback >+ ContentSecurityPolicyPermitsJSAction > }; > > MOZ_ASSERT(!JS_GetSecurityCallbacks(sRuntime)); > JS_SetSecurityCallbacks(sRuntime, &securityCallbacks); > JS_InitDestroyPrincipalsCallback(sRuntime, nsJSPrincipals::Destroy); > > JS_SetTrustedPrincipals(sRuntime, system); > >diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp >index 4e96e56..c6abe61 100644 >--- a/dom/base/nsJSEnvironment.cpp >+++ b/dom/base/nsJSEnvironment.cpp >@@ -1218,19 +1218,16 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript, > nsCOMPtr<nsIJSContextStack> stack = > do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv); > if (NS_FAILED(rv) || NS_FAILED(stack->Push(mContext))) { > return NS_ERROR_FAILURE; > } > > 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. > // Since the caller is responsible for parsing the version strings, we just > // check it isn't JSVERSION_UNKNOWN. > if (ok && ((JSVersion)aVersion) != JSVERSION_UNKNOWN) { > > XPCAutoRequest ar(mContext); >@@ -1276,18 +1273,16 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript, > // tricky... > } > else { > if (aIsUndefined) { > *aIsUndefined = true; > } > } > >- sSecurityManager->PopContextPrincipal(mContext); >- > // Pop here, after JS_ValueToString and any other possible evaluation. > if (NS_FAILED(stack->Pop(nsnull))) > rv = NS_ERROR_FAILURE; > > // ScriptEvaluated needs to come after we pop the stack > ScriptEvaluated(true); > > return rv; >@@ -1421,19 +1416,16 @@ nsJSContext::EvaluateString(const nsAString& aScript, > } > > // The result of evaluation, used only if there were no errors. This need > // not be a GC root currently, provided we run the GC only from the > // operation callback or from ScriptEvaluated. > 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; > > // SecurityManager said "ok", but don't compile if aVersion is unknown. > // Since the caller is responsible for parsing the version strings, we just > // check it isn't JSVERSION_UNKNOWN. > if (ok && JSVersion(aVersion) != JSVERSION_UNKNOWN) { >@@ -1475,18 +1467,16 @@ nsJSContext::EvaluateString(const nsAString& aScript, > > if (aRetValue) { > aRetValue->Truncate(); > } > } > > --mExecuteDepth; > >- sSecurityManager->PopContextPrincipal(mContext); >- > // Pop here, after JS_ValueToString and any other possible evaluation. > if (NS_FAILED(stack->Pop(nsnull))) > rv = NS_ERROR_FAILURE; > > // ScriptEvaluated needs to come after we pop the stack > ScriptEvaluated(true); > > return rv; >@@ -1574,25 +1564,16 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject, > // called from JS calls back into JS via XPConnect. > nsresult rv; > nsCOMPtr<nsIJSContextStack> stack = > do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv); > if (NS_FAILED(rv) || NS_FAILED(stack->Push(mContext))) { > 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; > > // The result of evaluation, used only if there were no errors. This need > // not be a GC root currently, provided we run the GC only from the > // operation callback or from ScriptEvaluated. > jsval val; >@@ -1609,18 +1590,16 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject, > > if (aRetValue) { > aRetValue->Truncate(); > } > } > > --mExecuteDepth; > >- sSecurityManager->PopContextPrincipal(mContext); >- > // Pop here, after JS_ValueToString and any other possible evaluation. > if (NS_FAILED(stack->Pop(nsnull))) > rv = NS_ERROR_FAILURE; > > // ScriptEvaluated needs to come after we pop the stack > ScriptEvaluated(true); > > return rv; >@@ -1851,34 +1830,22 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope, > nsJSContext::TerminationFuncHolder holder(this); > > if (NS_SUCCEEDED(rv)) { > // Convert args to jsvals. > PRUint32 argc = 0; > 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; > } > > Maybe<nsRootedJSValueArray> tempStorage; > > // Use |target| as the scope for wrapping the arguments, since aScope is > // the safe scope in many cases, which isn't very useful. Wrapping aTarget > // was OK because those typically have PreCreate methods that give them the >@@ -1911,18 +1878,16 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, JSObject* aScope, > rv = nsContentUtils::XPConnect()->JSToVariant(mContext, rval, arv); > } > > // Tell XPConnect about any pending exceptions. This is needed > // to avoid dropping JS exceptions in case we got here through > // nested calls through XPConnect. > if (NS_FAILED(rv)) > ReportPendingException(); >- >- sSecurityManager->PopContextPrincipal(mContext); > } > > pusher.Pop(); > > // ScriptEvaluated needs to come after we pop the stack > ScriptEvaluated(true); > > return rv; >diff --git a/dom/src/json/nsJSON.cpp b/dom/src/json/nsJSON.cpp >index 7522197..afce058 100644 >--- a/dom/src/json/nsJSON.cpp >+++ b/dom/src/json/nsJSON.cpp >@@ -172,41 +172,27 @@ NS_IMETHODIMP > nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result) > { > result.Truncate(); > > // Begin a new request > JSAutoRequest ar(cx); > > JSAutoEnterCompartment ac; >- nsIScriptSecurityManager *ssm = nsnull; > if (value->isObject()) { > JSObject *obj = &value->toObject(); > if (!ac.enter(cx, obj)) { > return NS_ERROR_FAILURE; > } >- >- nsCOMPtr<nsIPrincipal> principal; >- ssm = nsContentUtils::GetSecurityManager(); >- nsresult rv = ssm->GetObjectPrincipal(cx, obj, getter_AddRefs(principal)); >- NS_ENSURE_SUCCESS(rv, rv); >- >- JSStackFrame *fp = nsnull; >- rv = ssm->PushContextPrincipal(cx, JS_FrameIterator(cx, &fp), principal); >- NS_ENSURE_SUCCESS(rv, rv); > } > > nsJSONWriter writer; > JSBool ok = JS_Stringify(cx, value, NULL, JSVAL_NULL, > WriteCallback, &writer); > >- if (ssm) { >- ssm->PopContextPrincipal(cx); >- } >- > if (!ok) { > return NS_ERROR_XPC_BAD_CONVERT_JS; > } > > NS_ENSURE_TRUE(writer.DidWrite(), NS_ERROR_UNEXPECTED); > writer.FlushBuffer(); > result.Assign(writer.mOutputString); > return NS_OK; >diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp >index 04e0751..5ec03fd 100644 >--- a/ipc/testshell/XPCShellEnvironment.cpp >+++ b/ipc/testshell/XPCShellEnvironment.cpp >@@ -875,30 +875,16 @@ FullTrustSecMan::GetCxSubjectPrincipal(JSContext *cx) > NS_IMETHODIMP_(nsIPrincipal *) > FullTrustSecMan::GetCxSubjectPrincipalAndFrame(JSContext *cx, > JSStackFrame **fp) > { > *fp = nsnull; > return mSystemPrincipal; > } > >-NS_IMETHODIMP >-FullTrustSecMan::PushContextPrincipal(JSContext *cx, >- JSStackFrame *fp, >- nsIPrincipal *principal) >-{ >- return NS_OK; >-} >- >-NS_IMETHODIMP >-FullTrustSecMan::PopContextPrincipal(JSContext *cx) >-{ >- return NS_OK; >-} >- > NS_IMETHODIMP_(nsrefcnt) > XPCShellDirProvider::AddRef() > { > return 2; > } > > NS_IMETHODIMP_(nsrefcnt) > XPCShellDirProvider::Release() >diff --git a/js/src/jsapi.h b/js/src/jsapi.h >index f27df27..edce0a0 100644 >--- a/js/src/jsapi.h >+++ b/js/src/jsapi.h >@@ -1667,26 +1667,16 @@ typedef JSPrincipals * > /* > * Used to check if a CSP instance wants to disable eval() and friends. > * See js_CheckCSPPermitsJSAction() in jsobj. > */ > typedef JSBool > (* JSCSPEvalChecker)(JSContext *cx); > > /* >- * Security callbacks for pushing and popping context principals. These are only >- * temporarily necessary and will hopefully be gone again in a matter of weeks. >- */ >-typedef JSBool >-(* JSPushContextPrincipalOp)(JSContext *cx, JSPrincipals *principals); >- >-typedef JSBool >-(* JSPopContextPrincipalOp)(JSContext *cx); >- >-/* > * Callback used to ask the embedding for the cross compartment wrapper handler > * that implements the desired prolicy for this kind of object in the > * destination compartment. > */ > typedef JSObject * > (* JSWrapObjectCallback)(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent, > unsigned flags); > >@@ -4352,18 +4342,16 @@ JS_HoldPrincipals(JSPrincipals *principals); > extern JS_PUBLIC_API(void) > JS_DropPrincipals(JSRuntime *rt, JSPrincipals *principals); > > struct JSSecurityCallbacks { > JSCheckAccessOp checkObjectAccess; > JSSubsumePrincipalsOp subsumePrincipals; > JSObjectPrincipalsFinder findObjectPrincipals; > JSCSPEvalChecker contentSecurityPolicyAllows; >- JSPushContextPrincipalOp pushContextPrincipal; >- JSPopContextPrincipalOp popContextPrincipal; > }; > > extern JS_PUBLIC_API(void) > JS_SetSecurityCallbacks(JSRuntime *rt, const JSSecurityCallbacks *callbacks); > > extern JS_PUBLIC_API(const JSSecurityCallbacks *) > JS_GetSecurityCallbacks(JSRuntime *rt); > >diff --git a/js/src/jsclone.cpp b/js/src/jsclone.cpp >index 3e28fd3..b5c5912 100644 >--- a/js/src/jsclone.cpp >+++ b/js/src/jsclone.cpp >@@ -467,47 +467,16 @@ JSStructuredCloneWriter::startObject(JSObject *obj) > if (!objs.append(ObjectValue(*obj)) || !counts.append(count)) > return false; > checkStack(); > > /* Write the header for obj. */ > return out.writePair(obj->isArray() ? SCTAG_ARRAY_OBJECT : SCTAG_OBJECT_OBJECT, 0); > } > >-class AutoEnterCompartmentAndPushPrincipal : public JSAutoEnterCompartment >-{ >- public: >- bool enter(JSContext *cx, JSObject *target) { >- // First, enter the compartment. >- if (!JSAutoEnterCompartment::enter(cx, target)) >- return false; >- >- // We only need to push a principal if we changed compartments. >- if (state != STATE_OTHER_COMPARTMENT) >- return true; >- >- // Push. >- const JSSecurityCallbacks *cb = cx->runtime->securityCallbacks; >- if (cb->pushContextPrincipal) >- return cb->pushContextPrincipal(cx, target->principals(cx)); >- return true; >- }; >- >- ~AutoEnterCompartmentAndPushPrincipal() { >- // Pop the principal if necessary. >- if (state == STATE_OTHER_COMPARTMENT) { >- AutoCompartment *ac = getAutoCompartment(); >- const JSSecurityCallbacks *cb = ac->context->runtime->securityCallbacks; >- if (cb->popContextPrincipal) >- cb->popContextPrincipal(ac->context); >- } >- }; >-}; >- >- > bool > JSStructuredCloneWriter::startWrite(const Value &v) > { > assertSameCompartment(context(), v); > > if (v.isString()) { > return writeString(SCTAG_STRING, v.toString()); > } else if (v.isNumber()) { >@@ -524,17 +493,17 @@ JSStructuredCloneWriter::startWrite(const Value &v) > // The object might be a security wrapper. See if we can clone what's > // behind it. If we can, unwrap the object. > obj = UnwrapObjectChecked(context(), obj); > if (!obj) > return false; > > // If we unwrapped above, we'll need to enter the underlying compartment. > // Let the AutoEnterCompartment do the right thing for us. >- AutoEnterCompartmentAndPushPrincipal ac; >+ JSAutoEnterCompartment ac; > if (!ac.enter(context(), obj)) > return false; > > if (obj->isRegExp()) { > RegExpObject &reobj = obj->asRegExp(); > return out.writePair(SCTAG_REGEXP_OBJECT, reobj.getFlags()) && > writeString(SCTAG_STRING, reobj.getSource()); > } else if (obj->isDate()) { >@@ -569,17 +538,17 @@ JSStructuredCloneWriter::write(const Value &v) > { > if (!startWrite(v)) > return false; > > while (!counts.empty()) { > RootedObject obj(context(), &objs.back().toObject()); > > // The objects in |obj| can live in other compartments. >- AutoEnterCompartmentAndPushPrincipal ac; >+ JSAutoEnterCompartment ac; > if (!ac.enter(context(), obj)) > return false; > > if (counts.back()) { > counts.back()--; > RootedId id(context(), ids.back()); > ids.popBack(); > checkStack(); >diff --git a/js/xpconnect/shell/xpcshell.cpp b/js/xpconnect/shell/xpcshell.cpp >index a27aded..7d135c7 100644 >--- a/js/xpconnect/shell/xpcshell.cpp >+++ b/js/xpconnect/shell/xpcshell.cpp >@@ -1391,30 +1391,16 @@ FullTrustSecMan::CanExecuteScripts(JSContext * cx, nsIPrincipal *principal, > /* [noscript] nsIPrincipal getSubjectPrincipal (); */ > NS_IMETHODIMP > FullTrustSecMan::GetSubjectPrincipal(nsIPrincipal **_retval) > { > NS_IF_ADDREF(*_retval = mSystemPrincipal); > return *_retval ? NS_OK : NS_ERROR_FAILURE; > } > >-/* [noscript] void pushContextPrincipal (in JSContextPtr cx, in JSStackFramePtr fp, in nsIPrincipal principal); */ >-NS_IMETHODIMP >-FullTrustSecMan::PushContextPrincipal(JSContext * cx, JSStackFrame * fp, nsIPrincipal *principal) >-{ >- return NS_OK; >-} >- >-/* [noscript] void popContextPrincipal (in JSContextPtr cx); */ >-NS_IMETHODIMP >-FullTrustSecMan::PopContextPrincipal(JSContext * cx) >-{ >- return NS_OK; >-} >- > /* [noscript] nsIPrincipal getSystemPrincipal (); */ > NS_IMETHODIMP > FullTrustSecMan::GetSystemPrincipal(nsIPrincipal **_retval) > { > NS_IF_ADDREF(*_retval = mSystemPrincipal); > return *_retval ? NS_OK : NS_ERROR_FAILURE; > } > >diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp >index 8ee762e..b50aae0 100644 >--- a/js/xpconnect/src/XPCWrappedJSClass.cpp >+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp >@@ -1111,27 +1111,16 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx, > // see if JS code signaled failure result without throwing exception > if (NS_FAILED(pending_result)) { > return pending_result; > } > } > return NS_ERROR_FAILURE; > } > >-class ContextPrincipalGuard >-{ >- nsIScriptSecurityManager *ssm; >- XPCCallContext &ccx; >- public: >- ContextPrincipalGuard(XPCCallContext &ccx) >- : ssm(nsnull), ccx(ccx) {} >- void principalPushed(nsIScriptSecurityManager *ssm) { this->ssm = ssm; } >- ~ContextPrincipalGuard() { if (ssm) ssm->PopContextPrincipal(ccx); } >-}; >- > NS_IMETHODIMP > nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex, > const XPTMethodDescriptor* info, > nsXPTCMiniVariant* nativeParams) > { > jsval* sp = nsnull; > jsval* argv = nsnull; > uint8_t i; >@@ -1165,52 +1154,29 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex, > JSAutoEnterCompartment ac; > if (!ac.enter(cx, obj)) > return NS_ERROR_FAILURE; > > ccx.SetScopeForNewJSObjects(obj); > > JS::AutoValueVector args(cx); > AutoScriptEvaluate scriptEval(cx); >- ContextPrincipalGuard principalGuard(ccx); > > // XXX ASSUMES that retval is last arg. The xpidl compiler ensures this. > uint8_t paramCount = info->num_args; > uint8_t argc = paramCount - > (paramCount && XPT_PD_IS_RETVAL(info->params[paramCount-1].flags) ? 1 : 0); > > if (!scriptEval.StartEvaluating(obj, xpcWrappedJSErrorReporter)) > goto pre_call_clean_up; > > xpcc->SetPendingResult(pending_result); > xpcc->SetException(nsnull); > ccx.GetThreadData()->SetException(nsnull); > >- if (XPCPerThreadData::IsMainThread(ccx)) { >- // TODO Remove me in favor of security wrappers. >- nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager(); >- if (ssm) { >- nsIPrincipal *objPrincipal = >- xpc::AccessCheck::getPrincipal(js::GetObjectCompartment(obj)); >- if (objPrincipal) { >- JSStackFrame* fp = nsnull; >- nsresult rv = >- ssm->PushContextPrincipal(ccx, JS_FrameIterator(ccx, &fp), >- objPrincipal); >- if (NS_FAILED(rv)) { >- JS_ReportOutOfMemory(ccx); >- retval = NS_ERROR_OUT_OF_MEMORY; >- goto pre_call_clean_up; >- } >- >- principalGuard.principalPushed(ssm); >- } >- } >- } >- > // We use js_Invoke so that the gcthings we use as args will be rooted by > // the engine as we do conversions and prepare to do the function call. > > // setup stack > > // if this isn't a function call then we don't need to push extra stuff > if (!(XPT_MD_IS_SETTER(info->flags) || XPT_MD_IS_GETTER(info->flags))) { > // We get fval before allocating the stack to avoid gc badness that can >diff --git a/js/xpconnect/wrappers/CrossOriginWrapper.cpp b/js/xpconnect/wrappers/CrossOriginWrapper.cpp >index 9e57fd5..4faeecb 100644 >--- a/js/xpconnect/wrappers/CrossOriginWrapper.cpp >+++ b/js/xpconnect/wrappers/CrossOriginWrapper.cpp >@@ -69,37 +69,17 @@ CrossOriginWrapper::construct(JSContext *cx, JSObject *wrapper, > return CrossCompartmentWrapper::construct(cx, wrapper, argc, argv, rval) && > WrapperFactory::WaiveXrayAndWrap(cx, rval); > } > > bool > NoWaiverWrapper::enter(JSContext *cx, JSObject *wrapper, jsid id, Action act, bool *bp) > { > *bp = true; // always allowed >- nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager(); >- if (!ssm) { >- return true; >- } >- >- // Note: By the time enter is called here, CrossCompartmentWrapper has >- // already pushed the fake stack frame onto cx. Because of this, the frame >- // that we're clamping is the one that we want (the one in our compartment). >- JSStackFrame *fp = NULL; >- nsIPrincipal *principal = GetCompartmentPrincipal(js::GetObjectCompartment(wrappedObject(wrapper))); >- nsresult rv = ssm->PushContextPrincipal(cx, JS_FrameIterator(cx, &fp), principal); >- if (NS_FAILED(rv)) { >- NS_WARNING("Not allowing call because we're out of memory"); >- JS_ReportOutOfMemory(cx); >- return false; >- } > return true; > } > > void > NoWaiverWrapper::leave(JSContext *cx, JSObject *wrapper) > { >- nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager(); >- if (ssm) { >- ssm->PopContextPrincipal(cx); >- } > } > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Flags:
mrbkap
: review+
Actions:
View
|
Diff
|
Review
Attachments on
bug 754202
:
625948
|
625950
|
625951
|
630200
|
630201
| 630202 |
630203
|
630204
|
630223
|
632263
|
632264
|
633471
|
637446
|
637487