зеркало из https://github.com/mozilla/pjs.git
Bug 698378 - Give nsIScriptContext::EvaluateStringWithValue a JSObject* scope parameter; r=peterv
This commit is contained in:
Родитель
2c34ff9380
Коммит
9f1d454364
|
@ -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,
|
||||
|
|
|
@ -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<const jschar*>(PromiseFlatString(aScript).get()),
|
||||
aScript.Length(),
|
||||
aURL,
|
||||
aLineNo,
|
||||
|
|
|
@ -81,9 +81,9 @@ public:
|
|||
nsAString *aRetValue,
|
||||
bool* aIsUndefined);
|
||||
virtual nsresult EvaluateStringWithValue(const nsAString& aScript,
|
||||
void *aScopeObject,
|
||||
nsIPrincipal *aPrincipal,
|
||||
const char *aURL,
|
||||
JSObject* aScopeObject,
|
||||
nsIPrincipal* aPrincipal,
|
||||
const char* aURL,
|
||||
PRUint32 aLineNo,
|
||||
PRUint32 aVersion,
|
||||
void* aRetValue,
|
||||
|
|
|
@ -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 };
|
||||
|
|
Загрузка…
Ссылка в новой задаче