mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1283855
part 19 - Make security callbacks take JSContext instead of JSRuntime. r=jorendorff
--HG-- extra : rebase_source : c106826540912b00550b2d6162dcae6e1fb616d4
This commit is contained in:
parent
6c5b8f4c2e
commit
078a91ca56
@ -1386,8 +1386,8 @@ nsresult nsScriptSecurityManager::Init()
|
||||
JSPrincipalsSubsume,
|
||||
};
|
||||
|
||||
MOZ_ASSERT(!JS_GetSecurityCallbacks(sRuntime));
|
||||
JS_SetSecurityCallbacks(sRuntime, &securityCallbacks);
|
||||
MOZ_ASSERT(!JS_GetSecurityCallbacks(JS_GetContext(sRuntime)));
|
||||
JS_SetSecurityCallbacks(JS_GetContext(sRuntime), &securityCallbacks);
|
||||
JS_InitDestroyPrincipalsCallback(sRuntime, nsJSPrincipals::Destroy);
|
||||
|
||||
JS_SetTrustedPrincipals(sRuntime, system);
|
||||
@ -1414,7 +1414,7 @@ void
|
||||
nsScriptSecurityManager::Shutdown()
|
||||
{
|
||||
if (sRuntime) {
|
||||
JS_SetSecurityCallbacks(sRuntime, nullptr);
|
||||
JS_SetSecurityCallbacks(JS_GetContext(sRuntime), nullptr);
|
||||
JS_SetTrustedPrincipals(sRuntime, nullptr);
|
||||
sRuntime = nullptr;
|
||||
}
|
||||
|
@ -777,7 +777,7 @@ InitJSContextForWorker(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
|
||||
static const JSSecurityCallbacks securityCallbacks = {
|
||||
ContentSecurityPolicyAllows
|
||||
};
|
||||
JS_SetSecurityCallbacks(aRuntime, &securityCallbacks);
|
||||
JS_SetSecurityCallbacks(workerCx, &securityCallbacks);
|
||||
|
||||
// Set up the asm.js cache callbacks
|
||||
static const JS::AsmJSCacheOps asmJSCacheOps = {
|
||||
|
@ -76,10 +76,10 @@ struct JSSecurityCallbacks {
|
||||
};
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_SetSecurityCallbacks(JSRuntime* rt, const JSSecurityCallbacks* callbacks);
|
||||
JS_SetSecurityCallbacks(JSContext* cx, const JSSecurityCallbacks* callbacks);
|
||||
|
||||
extern JS_PUBLIC_API(const JSSecurityCallbacks*)
|
||||
JS_GetSecurityCallbacks(JSRuntime* rt);
|
||||
JS_GetSecurityCallbacks(JSContext* cx);
|
||||
|
||||
/*
|
||||
* Code running with "trusted" principals will be given a deeper stack
|
||||
|
@ -130,7 +130,7 @@ JSSecurityCallbacks StructuredCloneTestPrincipals::securityCallbacks = {
|
||||
|
||||
BEGIN_TEST(testStructuredClone_SavedFrame)
|
||||
{
|
||||
JS_SetSecurityCallbacks(rt, &StructuredCloneTestPrincipals::securityCallbacks);
|
||||
JS_SetSecurityCallbacks(cx, &StructuredCloneTestPrincipals::securityCallbacks);
|
||||
JS_InitDestroyPrincipalsCallback(rt, StructuredCloneTestPrincipals::destroy);
|
||||
JS_InitReadPrincipalsCallback(rt, StructuredCloneTestPrincipals::read);
|
||||
|
||||
|
@ -3276,16 +3276,16 @@ JS_DropPrincipals(JSContext* cx, JSPrincipals* principals)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_SetSecurityCallbacks(JSRuntime* rt, const JSSecurityCallbacks* scb)
|
||||
JS_SetSecurityCallbacks(JSContext* cx, const JSSecurityCallbacks* scb)
|
||||
{
|
||||
MOZ_ASSERT(scb != &NullSecurityCallbacks);
|
||||
rt->securityCallbacks = scb ? scb : &NullSecurityCallbacks;
|
||||
cx->securityCallbacks = scb ? scb : &NullSecurityCallbacks;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(const JSSecurityCallbacks*)
|
||||
JS_GetSecurityCallbacks(JSRuntime* rt)
|
||||
JS_GetSecurityCallbacks(JSContext* cx)
|
||||
{
|
||||
return (rt->securityCallbacks != &NullSecurityCallbacks) ? rt->securityCallbacks : nullptr;
|
||||
return (cx->securityCallbacks != &NullSecurityCallbacks) ? cx->securityCallbacks : nullptr;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
|
@ -7397,7 +7397,7 @@ main(int argc, char** argv, char** envp)
|
||||
JS_SetGCParametersBasedOnAvailableMemory(cx, availMem);
|
||||
|
||||
JS_SetTrustedPrincipals(rt, &ShellPrincipals::fullyTrusted);
|
||||
JS_SetSecurityCallbacks(rt, &ShellPrincipals::securityCallbacks);
|
||||
JS_SetSecurityCallbacks(cx, &ShellPrincipals::securityCallbacks);
|
||||
JS_InitDestroyPrincipalsCallback(rt, ShellPrincipals::destroy);
|
||||
|
||||
JS_SetInterruptCallback(rt, ShellInterruptCallback);
|
||||
|
@ -1463,10 +1463,10 @@ XRE_XPCShellMain(int argc, char** argv, char** envp,
|
||||
}
|
||||
}
|
||||
|
||||
const JSSecurityCallbacks* scb = JS_GetSecurityCallbacks(rt);
|
||||
const JSSecurityCallbacks* scb = JS_GetSecurityCallbacks(cx);
|
||||
MOZ_ASSERT(scb, "We are assuming that nsScriptSecurityManager::Init() has been run");
|
||||
shellSecurityCallbacks = *scb;
|
||||
JS_SetSecurityCallbacks(rt, &shellSecurityCallbacks);
|
||||
JS_SetSecurityCallbacks(cx, &shellSecurityCallbacks);
|
||||
|
||||
#ifdef TEST_TranslateThis
|
||||
nsCOMPtr<nsIXPCFunctionThisTranslator>
|
||||
|
Loading…
Reference in New Issue
Block a user