From 9bc9976c78a9770801b933fa7dc69e20f38e630e Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 16 Jul 2013 20:38:46 -0700 Subject: [PATCH] Bug 889714 - Stop manually holding onto system JSPrincipals. r=mrbkap --- ipc/testshell/XPCShellEnvironment.cpp | 9 --------- ipc/testshell/XPCShellEnvironment.h | 5 +++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index 367788f1af4b..34892aad5af4 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -657,7 +657,6 @@ XPCShellEnvironment::CreateEnvironment() XPCShellEnvironment::XPCShellEnvironment() : mCx(NULL), - mJSPrincipals(NULL), mQuitting(JS_FALSE) { } @@ -676,10 +675,6 @@ XPCShellEnvironment::~XPCShellEnvironment() JSRuntime *rt = JS_GetRuntime(mCx); JS_GC(rt); - if (mJSPrincipals) { - JS_DropPrincipals(rt, mJSPrincipals); - } - JS_EndRequest(mCx); JS_DestroyContext(mCx); @@ -749,10 +744,6 @@ XPCShellEnvironment::Init() rv = securityManager->GetSystemPrincipal(getter_AddRefs(principal)); if (NS_FAILED(rv)) { fprintf(stderr, "+++ Failed to obtain SystemPrincipal from ScriptSecurityManager service.\n"); - } else { - // fetch the JS principals and stick in a global - mJSPrincipals = nsJSPrincipals::get(principal); - JS_HoldPrincipals(mJSPrincipals); } } else { fprintf(stderr, "+++ Failed to get ScriptSecurityManager service, running without principals"); diff --git a/ipc/testshell/XPCShellEnvironment.h b/ipc/testshell/XPCShellEnvironment.h index 43674bd5c70c..61b586845e29 100644 --- a/ipc/testshell/XPCShellEnvironment.h +++ b/ipc/testshell/XPCShellEnvironment.h @@ -14,6 +14,8 @@ #include "nsCOMPtr.h" #include "nsDebug.h" #include "nsStringGlue.h" +#include "nsJSPrincipals.h" +#include "nsContentUtils.h" struct JSContext; class JSObject; @@ -34,7 +36,7 @@ public: nsString* aResult = nullptr); JSPrincipals* GetPrincipal() { - return mJSPrincipals; + return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal()); } JSObject* GetGlobalObject() { @@ -59,7 +61,6 @@ protected: private: JSContext* mCx; nsAutoJSValHolder mGlobalHolder; - JSPrincipals* mJSPrincipals; JSBool mQuitting; };