зеркало из https://github.com/mozilla/gecko-dev.git
Bug 880917 - Convert JS_SetVersion API consumers to per-compartment versions. r=luke
This commit is contained in:
Родитель
dbe3fa03a5
Коммит
8a63d76884
|
@ -1108,7 +1108,6 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
|
||||||
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
|
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
|
||||||
|
|
||||||
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_PRIVATE_IS_NSISUPPORTS);
|
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_PRIVATE_IS_NSISUPPORTS);
|
||||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
|
||||||
JS_SetErrorReporter(cx, ContentScriptErrorReporter);
|
JS_SetErrorReporter(cx, ContentScriptErrorReporter);
|
||||||
|
|
||||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||||
|
@ -1118,7 +1117,8 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
|
||||||
JS_SetContextPrivate(cx, aScope);
|
JS_SetContextPrivate(cx, aScope);
|
||||||
|
|
||||||
JS::CompartmentOptions options;
|
JS::CompartmentOptions options;
|
||||||
options.setZone(JS::SystemZone);
|
options.setZone(JS::SystemZone)
|
||||||
|
.setVersion(JSVERSION_LATEST);
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
xpc->InitClassesWithNewWrappedGlobal(cx, aScope, mPrincipal,
|
xpc->InitClassesWithNewWrappedGlobal(cx, aScope, mPrincipal,
|
||||||
flags, options, getter_AddRefs(mGlobal));
|
flags, options, getter_AddRefs(mGlobal));
|
||||||
|
|
|
@ -829,10 +829,6 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate)
|
||||||
JS_SetGCZeal(workerCx, settings.gcZeal, settings.gcZealFrequency);
|
JS_SetGCZeal(workerCx, settings.gcZeal, settings.gcZealFrequency);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (aWorkerPrivate->IsChromeWorker()) {
|
|
||||||
JS_SetVersion(workerCx, JSVERSION_LATEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
return workerCx;
|
return workerCx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -967,9 +967,12 @@ CreateDedicatedWorkerGlobalScope(JSContext* aCx)
|
||||||
WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
|
WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
|
||||||
JS_ASSERT(worker);
|
JS_ASSERT(worker);
|
||||||
|
|
||||||
|
JS::CompartmentOptions options;
|
||||||
|
if (worker->IsChromeWorker())
|
||||||
|
options.setVersion(JSVERSION_LATEST);
|
||||||
JS::Rooted<JSObject*> global(aCx,
|
JS::Rooted<JSObject*> global(aCx,
|
||||||
JS_NewGlobalObject(aCx, DedicatedWorkerGlobalScope::Class(),
|
JS_NewGlobalObject(aCx, DedicatedWorkerGlobalScope::Class(),
|
||||||
GetWorkerPrincipal()));
|
GetWorkerPrincipal(), options));
|
||||||
if (!global) {
|
if (!global) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,6 @@ ContextCallback(JSContext *cx,
|
||||||
|
|
||||||
if (contextOp == JSCONTEXT_NEW) {
|
if (contextOp == JSCONTEXT_NEW) {
|
||||||
JS_SetErrorReporter(cx, ScriptErrorReporter);
|
JS_SetErrorReporter(cx, ScriptErrorReporter);
|
||||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
|
||||||
}
|
}
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -784,7 +783,8 @@ XPCShellEnvironment::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::CompartmentOptions options;
|
JS::CompartmentOptions options;
|
||||||
options.setZone(JS::SystemZone);
|
options.setZone(JS::SystemZone)
|
||||||
|
.setVersion(JSVERSION_LATEST);
|
||||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||||
rv = xpc->InitClassesWithNewWrappedGlobal(cx,
|
rv = xpc->InitClassesWithNewWrappedGlobal(cx,
|
||||||
static_cast<nsIGlobalObject *>(backstagePass),
|
static_cast<nsIGlobalObject *>(backstagePass),
|
||||||
|
|
|
@ -62,13 +62,14 @@ main (int argc, const char **argv)
|
||||||
JS_SetNativeStackQuota(runtime, 5000000);
|
JS_SetNativeStackQuota(runtime, 5000000);
|
||||||
|
|
||||||
JSContext *cx = checkPtr(JS_NewContext(runtime, 8192));
|
JSContext *cx = checkPtr(JS_NewContext(runtime, 8192));
|
||||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
|
||||||
JS_SetErrorReporter(cx, reportError);
|
JS_SetErrorReporter(cx, reportError);
|
||||||
|
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
/* Create the global object. */
|
/* Create the global object. */
|
||||||
RootedObject global(cx, checkPtr(JS_NewGlobalObject(cx, &global_class, NULL)));
|
JS::CompartmentOptions options;
|
||||||
|
options.setVersion(JSVERSION_LATEST);
|
||||||
|
RootedObject global(cx, checkPtr(JS_NewGlobalObject(cx, &global_class, NULL, options)));
|
||||||
JS_SetGlobalObject(cx, global);
|
JS_SetGlobalObject(cx, global);
|
||||||
|
|
||||||
JSAutoCompartment ac(cx, global);
|
JSAutoCompartment ac(cx, global);
|
||||||
|
|
|
@ -51,7 +51,9 @@ bool JSAPITest::definePrint()
|
||||||
JSObject * JSAPITest::createGlobal(JSPrincipals *principals)
|
JSObject * JSAPITest::createGlobal(JSPrincipals *principals)
|
||||||
{
|
{
|
||||||
/* Create the global object. */
|
/* Create the global object. */
|
||||||
global = JS_NewGlobalObject(cx, getGlobalClass(), principals);
|
JS::CompartmentOptions options;
|
||||||
|
options.setVersion(JSVERSION_LATEST);
|
||||||
|
global = JS_NewGlobalObject(cx, getGlobalClass(), principals, options);
|
||||||
if (!global)
|
if (!global)
|
||||||
return NULL;
|
return NULL;
|
||||||
JS_AddNamedObjectRoot(cx, &global, "test-global");
|
JS_AddNamedObjectRoot(cx, &global, "test-global");
|
||||||
|
|
|
@ -299,7 +299,6 @@ class JSAPITest
|
||||||
if (!cx)
|
if (!cx)
|
||||||
return NULL;
|
return NULL;
|
||||||
JS_SetOptions(cx, JSOPTION_VAROBJFIX);
|
JS_SetOptions(cx, JSOPTION_VAROBJFIX);
|
||||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
|
||||||
JS_SetErrorReporter(cx, &reportError);
|
JS_SetErrorReporter(cx, &reportError);
|
||||||
return cx;
|
return cx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4774,7 +4774,6 @@ NewContext(JSRuntime *rt)
|
||||||
|
|
||||||
JS_SetContextPrivate(cx, data);
|
JS_SetContextPrivate(cx, data);
|
||||||
JS_SetErrorReporter(cx, my_ErrorReporter);
|
JS_SetErrorReporter(cx, my_ErrorReporter);
|
||||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
|
||||||
SetContextOptions(cx);
|
SetContextOptions(cx);
|
||||||
if (enableTypeInference)
|
if (enableTypeInference)
|
||||||
JS_ToggleOptions(cx, JSOPTION_TYPE_INFERENCE);
|
JS_ToggleOptions(cx, JSOPTION_TYPE_INFERENCE);
|
||||||
|
@ -4800,7 +4799,8 @@ static JSObject *
|
||||||
NewGlobalObject(JSContext *cx, JSObject *sameZoneAs)
|
NewGlobalObject(JSContext *cx, JSObject *sameZoneAs)
|
||||||
{
|
{
|
||||||
JS::CompartmentOptions options;
|
JS::CompartmentOptions options;
|
||||||
options.setZone(sameZoneAs ? JS::SameZoneAs(sameZoneAs) : JS::FreshZone);
|
options.setZone(sameZoneAs ? JS::SameZoneAs(sameZoneAs) : JS::FreshZone)
|
||||||
|
.setVersion(JSVERSION_LATEST);
|
||||||
RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, NULL, options));
|
RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, NULL, options));
|
||||||
if (!glob)
|
if (!glob)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -460,9 +460,6 @@ mozJSComponentLoader::ReallyInit()
|
||||||
if (!mContext)
|
if (!mContext)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
// Always use the latest js version
|
|
||||||
JS_SetVersion(mContext, JSVERSION_LATEST);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptSecurityManager> secman =
|
nsCOMPtr<nsIScriptSecurityManager> secman =
|
||||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
|
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
|
||||||
if (!secman)
|
if (!secman)
|
||||||
|
@ -727,7 +724,8 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
|
|
||||||
JS::CompartmentOptions options;
|
JS::CompartmentOptions options;
|
||||||
options.setZone(JS::SystemZone);
|
options.setZone(JS::SystemZone)
|
||||||
|
.setVersion(JSVERSION_LATEST);
|
||||||
rv = xpc->InitClassesWithNewWrappedGlobal(aCx,
|
rv = xpc->InitClassesWithNewWrappedGlobal(aCx,
|
||||||
static_cast<nsIGlobalObject *>(backstagePass),
|
static_cast<nsIGlobalObject *>(backstagePass),
|
||||||
mSystemPrincipal,
|
mSystemPrincipal,
|
||||||
|
|
|
@ -1400,7 +1400,6 @@ ContextCallback(JSContext *cx, unsigned contextOp)
|
||||||
|
|
||||||
if (contextOp == JSCONTEXT_NEW) {
|
if (contextOp == JSCONTEXT_NEW) {
|
||||||
JS_SetErrorReporter(cx, my_ErrorReporter);
|
JS_SetErrorReporter(cx, my_ErrorReporter);
|
||||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1635,7 +1634,8 @@ main(int argc, char **argv, char **envp)
|
||||||
}
|
}
|
||||||
|
|
||||||
JS::CompartmentOptions options;
|
JS::CompartmentOptions options;
|
||||||
options.setZone(JS::SystemZone);
|
options.setZone(JS::SystemZone)
|
||||||
|
.setVersion(JSVERSION_LATEST);
|
||||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||||
rv = xpc->InitClassesWithNewWrappedGlobal(cx,
|
rv = xpc->InitClassesWithNewWrappedGlobal(cx,
|
||||||
static_cast<nsIGlobalObject *>(backstagePass),
|
static_cast<nsIGlobalObject *>(backstagePass),
|
||||||
|
|
|
@ -3913,12 +3913,11 @@ xpc_EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sourc
|
||||||
pusher.Push(sandcx);
|
pusher.Push(sandcx);
|
||||||
JSAutoCompartment ac(sandcx, sandbox);
|
JSAutoCompartment ac(sandcx, sandbox);
|
||||||
|
|
||||||
if (jsVersion != JSVERSION_DEFAULT)
|
|
||||||
JS_SetVersion(sandcx, jsVersion);
|
|
||||||
|
|
||||||
JS::CompileOptions options(sandcx);
|
JS::CompileOptions options(sandcx);
|
||||||
options.setPrincipals(nsJSPrincipals::get(prin))
|
options.setPrincipals(nsJSPrincipals::get(prin))
|
||||||
.setFileAndLine(filename, lineNo);
|
.setFileAndLine(filename, lineNo);
|
||||||
|
if (jsVersion != JSVERSION_DEFAULT)
|
||||||
|
options.setVersion(jsVersion);
|
||||||
JS::RootedObject rootedSandbox(sandcx, sandbox);
|
JS::RootedObject rootedSandbox(sandcx, sandbox);
|
||||||
ok = JS::Evaluate(sandcx, rootedSandbox, options,
|
ok = JS::Evaluate(sandcx, rootedSandbox, options,
|
||||||
PromiseFlatString(source).get(), source.Length(),
|
PromiseFlatString(source).get(), source.Length(),
|
||||||
|
|
|
@ -537,14 +537,14 @@ private:
|
||||||
JSAutoRequest ar(mContext);
|
JSAutoRequest ar(mContext);
|
||||||
|
|
||||||
JS::CompartmentOptions options;
|
JS::CompartmentOptions options;
|
||||||
options.setZone(JS::SystemZone);
|
options.setZone(JS::SystemZone)
|
||||||
|
.setVersion(JSVERSION_LATEST);
|
||||||
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr, options);
|
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr, options);
|
||||||
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
JS_SetGlobalObject(mContext, mGlobal);
|
JS_SetGlobalObject(mContext, mGlobal);
|
||||||
JS_InitStandardClasses(mContext, mGlobal);
|
JS_InitStandardClasses(mContext, mGlobal);
|
||||||
|
|
||||||
JS_SetVersion(mContext, JSVERSION_LATEST);
|
|
||||||
JS_SetErrorReporter(mContext, PACErrorReporter);
|
JS_SetErrorReporter(mContext, PACErrorReporter);
|
||||||
|
|
||||||
if (!JS_DefineFunctions(mContext, mGlobal, PACGlobalFunctions))
|
if (!JS_DefineFunctions(mContext, mGlobal, PACGlobalFunctions))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче