mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 880917 - Convert JS_SetVersion API consumers to per-compartment versions. r=luke
This commit is contained in:
parent
fbb93f2c02
commit
306f8a67ea
@ -1096,7 +1096,6 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
|
||||
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(mPrincipal));
|
||||
|
||||
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_PRIVATE_IS_NSISUPPORTS);
|
||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
||||
JS_SetErrorReporter(cx, ContentScriptErrorReporter);
|
||||
|
||||
nsIXPConnect* xpc = nsContentUtils::XPConnect();
|
||||
@ -1106,7 +1105,8 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope,
|
||||
JS_SetContextPrivate(cx, aScope);
|
||||
|
||||
JS::CompartmentOptions options;
|
||||
options.setZone(JS::SystemZone);
|
||||
options.setZone(JS::SystemZone)
|
||||
.setVersion(JSVERSION_LATEST);
|
||||
nsresult rv =
|
||||
xpc->InitClassesWithNewWrappedGlobal(cx, aScope, mPrincipal,
|
||||
flags, options, getter_AddRefs(mGlobal));
|
||||
|
@ -829,10 +829,6 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate)
|
||||
JS_SetGCZeal(workerCx, settings.gcZeal, settings.gcZealFrequency);
|
||||
#endif
|
||||
|
||||
if (aWorkerPrivate->IsChromeWorker()) {
|
||||
JS_SetVersion(workerCx, JSVERSION_LATEST);
|
||||
}
|
||||
|
||||
return workerCx;
|
||||
}
|
||||
|
||||
|
@ -973,9 +973,12 @@ CreateDedicatedWorkerGlobalScope(JSContext* aCx)
|
||||
WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
|
||||
JS_ASSERT(worker);
|
||||
|
||||
JS::CompartmentOptions options;
|
||||
if (worker->IsChromeWorker())
|
||||
options.setVersion(JSVERSION_LATEST);
|
||||
JS::Rooted<JSObject*> global(aCx,
|
||||
JS_NewGlobalObject(aCx, DedicatedWorkerGlobalScope::Class(),
|
||||
GetWorkerPrincipal()));
|
||||
GetWorkerPrincipal(), options));
|
||||
if (!global) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -188,7 +188,6 @@ ContextCallback(JSContext *cx,
|
||||
|
||||
if (contextOp == JSCONTEXT_NEW) {
|
||||
JS_SetErrorReporter(cx, ScriptErrorReporter);
|
||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -784,7 +783,8 @@ XPCShellEnvironment::Init()
|
||||
}
|
||||
|
||||
JS::CompartmentOptions options;
|
||||
options.setZone(JS::SystemZone);
|
||||
options.setZone(JS::SystemZone)
|
||||
.setVersion(JSVERSION_LATEST);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
rv = xpc->InitClassesWithNewWrappedGlobal(cx,
|
||||
static_cast<nsIGlobalObject *>(backstagePass),
|
||||
|
@ -62,13 +62,14 @@ main (int argc, const char **argv)
|
||||
JS_SetNativeStackQuota(runtime, 5000000);
|
||||
|
||||
JSContext *cx = checkPtr(JS_NewContext(runtime, 8192));
|
||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
||||
JS_SetErrorReporter(cx, reportError);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
/* 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);
|
||||
|
||||
JSAutoCompartment ac(cx, global);
|
||||
|
@ -51,7 +51,9 @@ bool JSAPITest::definePrint()
|
||||
JSObject * JSAPITest::createGlobal(JSPrincipals *principals)
|
||||
{
|
||||
/* 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)
|
||||
return NULL;
|
||||
JS_AddNamedObjectRoot(cx, &global, "test-global");
|
||||
|
@ -301,7 +301,6 @@ class JSAPITest
|
||||
if (!cx)
|
||||
return NULL;
|
||||
JS_SetOptions(cx, JSOPTION_VAROBJFIX);
|
||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
||||
JS_SetErrorReporter(cx, &reportError);
|
||||
return cx;
|
||||
}
|
||||
|
@ -4782,7 +4782,6 @@ NewContext(JSRuntime *rt)
|
||||
|
||||
JS_SetContextPrivate(cx, data);
|
||||
JS_SetErrorReporter(cx, my_ErrorReporter);
|
||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
||||
SetContextOptions(cx);
|
||||
if (enableTypeInference)
|
||||
JS_ToggleOptions(cx, JSOPTION_TYPE_INFERENCE);
|
||||
@ -4808,7 +4807,8 @@ static JSObject *
|
||||
NewGlobalObject(JSContext *cx, JSObject *sameZoneAs)
|
||||
{
|
||||
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));
|
||||
if (!glob)
|
||||
return NULL;
|
||||
|
@ -460,9 +460,6 @@ mozJSComponentLoader::ReallyInit()
|
||||
if (!mContext)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Always use the latest js version
|
||||
JS_SetVersion(mContext, JSVERSION_LATEST);
|
||||
|
||||
nsCOMPtr<nsIScriptSecurityManager> secman =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
|
||||
if (!secman)
|
||||
@ -728,7 +725,8 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
JS::CompartmentOptions options;
|
||||
options.setZone(JS::SystemZone);
|
||||
options.setZone(JS::SystemZone)
|
||||
.setVersion(JSVERSION_LATEST);
|
||||
rv = xpc->InitClassesWithNewWrappedGlobal(aCx,
|
||||
static_cast<nsIGlobalObject *>(backstagePass),
|
||||
mSystemPrincipal,
|
||||
|
@ -1482,7 +1482,6 @@ ContextCallback(JSContext *cx, unsigned contextOp)
|
||||
|
||||
if (contextOp == JSCONTEXT_NEW) {
|
||||
JS_SetErrorReporter(cx, my_ErrorReporter);
|
||||
JS_SetVersion(cx, JSVERSION_LATEST);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1717,7 +1716,8 @@ main(int argc, char **argv, char **envp)
|
||||
}
|
||||
|
||||
JS::CompartmentOptions options;
|
||||
options.setZone(JS::SystemZone);
|
||||
options.setZone(JS::SystemZone)
|
||||
.setVersion(JSVERSION_LATEST);
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
rv = xpc->InitClassesWithNewWrappedGlobal(cx,
|
||||
static_cast<nsIGlobalObject *>(backstagePass),
|
||||
|
@ -3909,12 +3909,11 @@ xpc_EvalInSandbox(JSContext *cx, HandleObject sandboxArg, const nsAString& sourc
|
||||
pusher.Push(sandcx);
|
||||
JSAutoCompartment ac(sandcx, sandbox);
|
||||
|
||||
if (jsVersion != JSVERSION_DEFAULT)
|
||||
JS_SetVersion(sandcx, jsVersion);
|
||||
|
||||
JS::CompileOptions options(sandcx);
|
||||
options.setPrincipals(nsJSPrincipals::get(prin))
|
||||
.setFileAndLine(filename, lineNo);
|
||||
if (jsVersion != JSVERSION_DEFAULT)
|
||||
options.setVersion(jsVersion);
|
||||
JS::RootedObject rootedSandbox(sandcx, sandbox);
|
||||
ok = JS::Evaluate(sandcx, rootedSandbox, options,
|
||||
PromiseFlatString(source).get(), source.Length(),
|
||||
|
@ -537,14 +537,14 @@ private:
|
||||
JSAutoRequest ar(mContext);
|
||||
|
||||
JS::CompartmentOptions options;
|
||||
options.setZone(JS::SystemZone);
|
||||
options.setZone(JS::SystemZone)
|
||||
.setVersion(JSVERSION_LATEST);
|
||||
mGlobal = JS_NewGlobalObject(mContext, &sGlobalClass, nullptr, options);
|
||||
NS_ENSURE_TRUE(mGlobal, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
JS_SetGlobalObject(mContext, mGlobal);
|
||||
JS_InitStandardClasses(mContext, mGlobal);
|
||||
|
||||
JS_SetVersion(mContext, JSVERSION_LATEST);
|
||||
JS_SetErrorReporter(mContext, PACErrorReporter);
|
||||
|
||||
if (!JS_DefineFunctions(mContext, mGlobal, PACGlobalFunctions))
|
||||
|
Loading…
Reference in New Issue
Block a user