Bug 889714 - Reduce the number of places where we pull |env| off cx. r=mrbkap
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -482,24 +482,26 @@ typedef enum JSShellErrNum
#define MSG_DEF(name, number, count, exception, format) \
name = number,
#include "jsshell.msg"
#undef MSG_DEF
JSShellErr_Limit
#undef MSGDEF
} JSShellErrNum;
-static void
-ProcessFile(JSContext *cx,
- JS::Handle<JSObject*> obj,
- const char *filename,
- FILE *file,
- JSBool forceTTY)
+} /* anonymous namespace */
+
+void
+XPCShellEnvironment::ProcessFile(JSContext *cx,
+ JS::Handle<JSObject*> obj,
+ const char *filename,
+ FILE *file,
+ JSBool forceTTY)
{
- XPCShellEnvironment* env = Environment(cx);
+ XPCShellEnvironment* env = this;
nsCxPusher pusher;
pusher.Push(env->GetContext());
JSScript *script;
JS::Rooted<JS::Value> result(cx);
int lineno, startline;
JSBool ok, hitEOF;
char *bufp, buffer[4096];
@@ -594,18 +596,16 @@ ProcessFile(JSContext *cx,
ok = JS_FALSE;
}
}
} while (!hitEOF && !env->IsQuitting());
fprintf(stdout, "\n");
}
-} /* anonymous namespace */
-
NS_IMETHODIMP_(nsrefcnt)
XPCShellDirProvider::AddRef()
{
return 2;
}
NS_IMETHODIMP_(nsrefcnt)
XPCShellDirProvider::Release()
@@ -806,17 +806,17 @@ XPCShellEnvironment::Init()
return true;
}
bool
XPCShellEnvironment::EvaluateString(const nsString& aString,
nsString* aResult)
{
- XPCShellEnvironment* env = Environment(mCx);
+ XPCShellEnvironment* env = this;
nsCxPusher pusher;
pusher.Push(env->GetContext());
JSAutoRequest ar(mCx);
JS_ClearPendingException(mCx);
JS::Rooted<JSObject*> global(mCx, GetGlobalObject());
--- a/ipc/testshell/XPCShellEnvironment.h
+++ b/ipc/testshell/XPCShellEnvironment.h
@@ -23,16 +23,18 @@ namespace mozilla {
namespace ipc {
class XPCShellEnvironment
{
public:
static XPCShellEnvironment* CreateEnvironment();
~XPCShellEnvironment();
+ void ProcessFile(JSContext *cx, JS::Handle<JSObject*> obj,
+ const char *filename, FILE *file, JSBool forceTTY);
bool EvaluateString(const nsString& aString,
nsString* aResult = nullptr);
JSPrincipals* GetPrincipal() {
return mJSPrincipals;
}
JSObject* GetGlobalObject() {