diff --git a/dom/base/nsIScriptContext.h b/dom/base/nsIScriptContext.h index 357a11f12e7..ca7d5e10bd7 100644 --- a/dom/base/nsIScriptContext.h +++ b/dom/base/nsIScriptContext.h @@ -74,8 +74,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContextPrincipal, NS_ISCRIPTCONTEXTPRINCIPAL_IID) #define NS_ISCRIPTCONTEXT_IID \ -{ 0x0ffcb42a, 0xd2cf, 0x4e16, \ - { 0xac, 0x24, 0x5e, 0x7d, 0xd0, 0x71, 0x72, 0x12 } } +{ 0xace7960f, 0x263b, 0x4a9a, \ + { 0xaa, 0x1f, 0x87, 0x86, 0x5c, 0x67, 0x03, 0x7f } } /* This MUST match JSVERSION_DEFAULT. This version stuff if we don't know what language we have is a little silly... */ @@ -121,10 +121,9 @@ public: nsAString *aRetValue, bool* aIsUndefined) = 0; - // Note JS bigotry remains here - 'void *aRetValue' is assumed to be a - // jsval. This must move to JSObject before it can be made agnostic. + // 'void *aRetValue' is assumed to be a jsval. virtual nsresult EvaluateStringWithValue(const nsAString& aScript, - void *aScopeObject, + JSObject* aScopeObject, nsIPrincipal *aPrincipal, const char *aURL, PRUint32 aLineNo, diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 857879364d9..50f37f158a6 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1196,7 +1196,7 @@ nsJSContext::GetCCRefcnt() nsresult nsJSContext::EvaluateStringWithValue(const nsAString& aScript, - void *aScopeObject, + JSObject* aScopeObject, nsIPrincipal *aPrincipal, const char *aURL, PRUint32 aLineNo, @@ -1207,6 +1207,9 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript, NS_TIME_FUNCTION_MIN_FMT(1.0, "%s (line %d) (url: %s, line: %d)", MOZ_FUNCTION_NAME, __LINE__, aURL, aLineNo); + NS_ABORT_IF_FALSE(aScopeObject, + "Shouldn't call EvaluateStringWithValue with null scope object."); + NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_NOT_INITIALIZED); if (!mScriptsEnabled) { @@ -1217,15 +1220,12 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript, return NS_OK; } - nsresult rv; - if (!aScopeObject) - aScopeObject = ::JS_GetGlobalObject(mContext); - // Safety first: get an object representing the script's principals, i.e., // the entities who signed this script, or the fully-qualified-domain-name // or "codebase" from which it was loaded. JSPrincipals *jsprin; nsIPrincipal *principal = aPrincipal; + nsresult rv; if (!aPrincipal) { nsIScriptGlobalObject *global = GetGlobalObject(); if (!global) @@ -1277,7 +1277,7 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript, JSAutoRequest ar(mContext); JSAutoEnterCompartment ac; - if (!ac.enter(mContext, (JSObject *)aScopeObject)) { + if (!ac.enter(mContext, aScopeObject)) { JSPRINCIPALS_DROP(mContext, jsprin); stack->Pop(nsnull); return NS_ERROR_FAILURE; @@ -1286,9 +1286,9 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript, ++mExecuteDepth; ok = ::JS_EvaluateUCScriptForPrincipalsVersion(mContext, - (JSObject *)aScopeObject, + aScopeObject, jsprin, - (jschar*)PromiseFlatString(aScript).get(), + static_cast(PromiseFlatString(aScript).get()), aScript.Length(), aURL, aLineNo, diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index 85f3101d16b..8d4affd22e3 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -81,13 +81,13 @@ public: nsAString *aRetValue, bool* aIsUndefined); virtual nsresult EvaluateStringWithValue(const nsAString& aScript, - void *aScopeObject, - nsIPrincipal *aPrincipal, - const char *aURL, - PRUint32 aLineNo, - PRUint32 aVersion, - void* aRetValue, - bool* aIsUndefined); + JSObject* aScopeObject, + nsIPrincipal* aPrincipal, + const char* aURL, + PRUint32 aLineNo, + PRUint32 aVersion, + void* aRetValue, + bool* aIsUndefined); virtual nsresult CompileScript(const PRUnichar* aText, PRInt32 aTextLength, diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 8f0e4bbd6eb..aa7f0625bc4 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -1646,6 +1646,8 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result) } obj = JS_ObjectToInnerObject(cx, obj); + NS_ABORT_IF_FALSE(obj, + "JS_ObjectToInnerObject should never return null with non-null input."); // Root obj and the rval (below). jsval vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };