Bug 1152512 - Use the latest JavaScript version when parsing AutoConfig files. r=mrbkap

--HG--
extra : rebase_source : 4527671894b43e60e16d4b6be5e6af55b68b6ebe
This commit is contained in:
Mike Kaply 2015-07-28 13:57:55 -05:00
Родитель ab384724ae
Коммит 68b080c7c5
3 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -107,7 +107,7 @@ nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
nsAutoCString script(js_buffer, length);
JS::RootedValue v(cx);
rv = xpc->EvalInSandboxObject(NS_ConvertUTF8toUTF16(script), filename, cx,
autoconfigSb, &v);
autoconfigSb, JSVERSION_LATEST, &v);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;

Просмотреть файл

@ -266,7 +266,7 @@ interface nsIXPCFunctionThisTranslator : nsISupports
{ 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
%}
[noscript, uuid(db83b3af-ac22-4dd2-99cf-7f79270ed4cd)]
[noscript, uuid(f339ea52-10ce-4103-b1f2-fd9659040e3c)]
interface nsIXPConnect : nsISupports
{
%{ C++
@ -486,6 +486,8 @@ interface nsIXPConnect : nsISupports
* the script. The actual evaluation will happen on a new
* temporary context.
* @param sandbox The sandbox object to evaluate the script in.
* @param version The JavaScript version to use for evaluating the script.
* Should be a valid JSVersion from jspubtd.h.
* @return The result of the evaluation as a jsval. If the caller
* intends to use the return value from this call the caller
* is responsible for rooting the jsval before making a call
@ -493,7 +495,8 @@ interface nsIXPConnect : nsISupports
*/
[noscript] jsval evalInSandboxObject(in AString source, in string filename,
in JSContextPtr cx,
in JSObjectPtr sandbox);
in JSObjectPtr sandbox,
in int32_t version);
/**
* Whether or not XPConnect should report all JS exceptions when returning

Просмотреть файл

@ -771,8 +771,15 @@ nsXPConnect::CreateSandbox(JSContext* cx, nsIPrincipal* principal,
NS_IMETHODIMP
nsXPConnect::EvalInSandboxObject(const nsAString& source, const char* filename,
JSContext* cx, JSObject* sandboxArg,
int32_t jsVersion,
MutableHandleValue rval)
{
#ifdef DEBUG
{
const char *version = JS_VersionToString(JSVersion(jsVersion));
MOZ_ASSERT(version && strcmp(version, "unknown") != 0, "Illegal JS version passed");
}
#endif
if (!sandboxArg)
return NS_ERROR_INVALID_ARG;
@ -784,7 +791,7 @@ nsXPConnect::EvalInSandboxObject(const nsAString& source, const char* filename,
filenameStr = NS_LITERAL_CSTRING("x-bogus://XPConnect/Sandbox");
}
return EvalInSandbox(cx, sandbox, source, filenameStr, 1,
JSVERSION_LATEST, rval);
JSVersion(jsVersion), rval);
}
/* JSObjectPtr getWrappedNativePrototype (in JSContextPtr aJSContext, in JSObjectPtr aScope); */