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"
16 #include "nsJSPrincipals.h"
17 #include "nsContentUtils.h"
18 #include "js/RootingAPI.h"
19 #include "js/TypeDecls.h"
26 class XPCShellEnvironment
{
28 static XPCShellEnvironment
* CreateEnvironment();
29 ~XPCShellEnvironment();
31 void ProcessFile(JSContext
* cx
, const char* filename
, FILE* file
,
33 bool EvaluateString(const nsAString
& aString
, nsString
* aResult
= nullptr);
35 JSPrincipals
* GetPrincipal() {
36 return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal());
39 JSObject
* GetGlobalObject() { return mGlobalHolder
; }
41 void SetIsQuitting() { mQuitting
= true; }
42 bool IsQuitting() { return mQuitting
; }
45 XPCShellEnvironment();
49 JS::PersistentRooted
<JSObject
*> mGlobalHolder
;
55 } /* namespace mozilla */
57 #endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */