Bug 824864 - Fix Ms2ger nits. r=me

This commit is contained in:
Bobby Holley 2013-01-16 18:50:27 -08:00
parent fe9b482b3b
commit 7a0d54fa07
4 changed files with 13 additions and 11 deletions

View File

@ -861,8 +861,9 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
JS::CompileOptions options(context->GetNativeContext());
options.setFileAndLine(url.get(), aRequest->mLineNo)
.setVersion(JSVersion(aRequest->mJSVersion));
if (aRequest->mOriginPrincipal)
if (aRequest->mOriginPrincipal) {
options.setOriginPrincipals(nsJSPrincipals::get(aRequest->mOriginPrincipal));
}
JS::Value ignored;
rv = context->EvaluateString(aScript, *globalObject->GetGlobalJSObject(),
options, /* aCoerceToString = */ false, &ignored);

View File

@ -1273,10 +1273,10 @@ nsJSContext::EvaluateString(const nsAString& aScript,
ok = JS::Evaluate(mContext, rootedScope, aOptions,
PromiseFlatString(aScript).get(),
aScript.Length(), aRetValue);
if (ok && !JSVAL_IS_VOID(*aRetValue) && aCoerceToString) {
if (ok && !aRetValue->isUndefined() && aCoerceToString) {
JSString* str = JS_ValueToString(mContext, *aRetValue);
ok = !!str;
*aRetValue = ok ? JS::StringValue(str) : JSVAL_VOID;
*aRetValue = ok ? JS::StringValue(str) : JS::UndefinedValue();
}
--mExecuteDepth;
}
@ -1395,13 +1395,15 @@ nsJSContext::ExecuteScript(JSScript* aScriptObject,
// not be a GC root currently, provided we run the GC only from the
// operation callback or from ScriptEvaluated.
jsval val;
if (!JS_ExecuteScript(mContext, aScopeObject, aScriptObject, &val))
if (!JS_ExecuteScript(mContext, aScopeObject, aScriptObject, &val)) {
ReportPendingException();
}
--mExecuteDepth;
// Pop here, after JS_ValueToString and any other possible evaluation.
if (NS_FAILED(stack->Pop(nullptr)))
if (NS_FAILED(stack->Pop(nullptr))) {
rv = NS_ERROR_FAILURE;
}
// ScriptEvaluated needs to come after we pop the stack
ScriptEvaluated(true);

View File

@ -159,13 +159,13 @@ nsJSUtils::CompileFunction(JSContext* aCx,
JSObject** aFunctionObject)
{
MOZ_ASSERT(js::GetEnterCompartmentDepth(aCx) > 0);
MOZ_ASSERT(!aTarget || js::IsObjectInContextCompartment(aTarget, aCx));
MOZ_ASSERT_IF(aTarget, js::IsObjectInContextCompartment(aTarget, aCx));
MOZ_ASSERT_IF(aOptions.versionSet, aOptions.version != JSVERSION_UNKNOWN);
// Since aTarget and aCx are same-compartment, there should be no distinction
// between the object principal and the cx principal.
// However, aTarget may be null in the wacky aShared case. So use the cx.
JSPrincipals *p = JS_GetCompartmentPrincipals(js::GetContextCompartment(aCx));
JSPrincipals* p = JS_GetCompartmentPrincipals(js::GetContextCompartment(aCx));
aOptions.setPrincipals(p);
// Do the junk Gecko is supposed to do before calling into JSAPI.
@ -177,8 +177,7 @@ nsJSUtils::CompileFunction(JSContext* aCx,
aArgCount, aArgArray,
PromiseFlatString(aBody).get(),
aBody.Length());
if (!fun)
return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(fun, NS_ERROR_FAILURE);
*aFunctionObject = JS_GetFunctionObject(fun);
return NS_OK;

View File

@ -255,7 +255,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
useSandbox = !subsumes;
}
JS::Value v = JSVAL_VOID;
JS::Value v = JS::UndefinedValue();
// Finally, we have everything needed to evaluate the expression.
JSContext *cx = scriptContext->GetNativeContext();
@ -348,7 +348,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel,
}
else {
nsDependentJSString result;
if (!result.init(cx, JSVAL_TO_STRING(v))) {
if (!result.init(cx, v)) {
return NS_ERROR_OUT_OF_MEMORY;
}