Bug 899135 - Drop buffers in ScriptProcessorNode instead of buffering them when the...
[gecko.git] / ipc / testshell / XPCShellEnvironment.h
blob36456f8a836a406530f21701ca47cf3dc502fbb0
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"
10 #include <string>
11 #include <stdio.h>
13 #include "nsAutoJSValHolder.h"
14 #include "nsCOMPtr.h"
15 #include "nsDebug.h"
16 #include "nsStringGlue.h"
17 #include "nsJSPrincipals.h"
18 #include "nsContentUtils.h"
20 struct JSContext;
21 class JSObject;
22 struct JSPrincipals;
24 namespace mozilla {
25 namespace ipc {
27 class XPCShellEnvironment
29 public:
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() {
47 mQuitting = JS_TRUE;
49 JSBool IsQuitting() {
50 return mQuitting;
53 protected:
54 XPCShellEnvironment();
55 bool Init();
57 private:
58 nsAutoJSValHolder mGlobalHolder;
60 JSBool mQuitting;
63 } /* namespace ipc */
64 } /* namespace mozilla */
66 #endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */