1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
6 #define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
8 #include "base/basictypes.h"
13 #include "nsAutoJSValHolder.h"
16 #include "nsStringGlue.h"
17 #include "nsJSPrincipals.h"
18 #include "nsContentUtils.h"
27 class XPCShellEnvironment
30 static XPCShellEnvironment
* CreateEnvironment();
31 ~XPCShellEnvironment();
33 void ProcessFile(JSContext
*cx
, JS::Handle
<JSObject
*> obj
,
34 const char *filename
, FILE *file
, JSBool forceTTY
);
35 bool EvaluateString(const nsString
& aString
,
36 nsString
* aResult
= nullptr);
38 JSPrincipals
* GetPrincipal() {
39 return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal());
42 JSObject
* GetGlobalObject() {
43 return mGlobalHolder
.ToJSObject();
46 void SetIsQuitting() {
54 XPCShellEnvironment();
58 nsAutoJSValHolder mGlobalHolder
;
64 } /* namespace mozilla */
66 #endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */