2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-07-11 10:33:10 +04:00
|
|
|
|
|
|
|
#ifndef _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
|
|
|
|
#define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <stdio.h>
|
2009-08-29 03:16:19 +04:00
|
|
|
|
|
|
|
#include "nsAutoJSValHolder.h"
|
2009-07-11 10:33:10 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDebug.h"
|
2009-08-29 03:16:19 +04:00
|
|
|
#include "nsStringGlue.h"
|
2009-07-24 02:27:17 +04:00
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
struct JSContext;
|
|
|
|
struct JSObject;
|
|
|
|
struct JSPrincipals;
|
|
|
|
|
|
|
|
class nsIJSContextStack;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace ipc {
|
|
|
|
|
|
|
|
class XPCShellEnvironment
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static XPCShellEnvironment* CreateEnvironment();
|
2009-08-29 03:16:19 +04:00
|
|
|
~XPCShellEnvironment();
|
2009-07-11 10:33:10 +04:00
|
|
|
|
2009-07-30 01:12:15 +04:00
|
|
|
bool EvaluateString(const nsString& aString,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsString* aResult = nullptr);
|
2009-07-11 10:33:10 +04:00
|
|
|
|
|
|
|
JSPrincipals* GetPrincipal() {
|
|
|
|
return mJSPrincipals;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject* GetGlobalObject() {
|
|
|
|
return mGlobalHolder.ToJSObject();
|
|
|
|
}
|
|
|
|
|
2009-11-06 23:43:39 +03:00
|
|
|
JSContext* GetContext() {
|
|
|
|
return mCx;
|
|
|
|
}
|
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
void SetExitCode(int aExitCode) {
|
|
|
|
mExitCode = aExitCode;
|
|
|
|
}
|
|
|
|
int ExitCode() {
|
|
|
|
return mExitCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetIsQuitting() {
|
|
|
|
mQuitting = JS_TRUE;
|
|
|
|
}
|
|
|
|
JSBool IsQuitting() {
|
|
|
|
return mQuitting;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetShouldReportWarnings(JSBool aReportWarnings) {
|
|
|
|
mReportWarnings = aReportWarnings;
|
|
|
|
}
|
|
|
|
JSBool ShouldReportWarnings() {
|
|
|
|
return mReportWarnings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetShouldCompoleOnly(JSBool aCompileOnly) {
|
|
|
|
mCompileOnly = aCompileOnly;
|
|
|
|
}
|
|
|
|
JSBool ShouldCompileOnly() {
|
|
|
|
return mCompileOnly;
|
|
|
|
}
|
|
|
|
|
2009-08-26 03:07:22 +04:00
|
|
|
class AutoContextPusher
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AutoContextPusher(XPCShellEnvironment* aEnv);
|
|
|
|
~AutoContextPusher();
|
|
|
|
private:
|
|
|
|
XPCShellEnvironment* mEnv;
|
|
|
|
};
|
|
|
|
|
2009-07-11 10:33:10 +04:00
|
|
|
protected:
|
|
|
|
XPCShellEnvironment();
|
|
|
|
bool Init();
|
|
|
|
|
|
|
|
private:
|
|
|
|
JSContext* mCx;
|
|
|
|
nsAutoJSValHolder mGlobalHolder;
|
|
|
|
nsCOMPtr<nsIJSContextStack> mCxStack;
|
|
|
|
JSPrincipals* mJSPrincipals;
|
|
|
|
|
|
|
|
int mExitCode;
|
|
|
|
JSBool mQuitting;
|
|
|
|
JSBool mReportWarnings;
|
|
|
|
JSBool mCompileOnly;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ipc */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
2009-11-06 23:43:39 +03:00
|
|
|
#endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */
|