Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/ipc/XPCShellEnvironment.h
Line
Count
Source (jump to first uncovered line)
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/. */
4
5
#ifndef _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
6
#define _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_
7
8
#include "base/basictypes.h"
9
10
#include <string>
11
#include <stdio.h>
12
13
#include "nsCOMPtr.h"
14
#include "nsDebug.h"
15
#include "nsString.h"
16
#include "nsJSPrincipals.h"
17
#include "nsContentUtils.h"
18
#include "js/RootingAPI.h"
19
#include "js/TypeDecls.h"
20
21
struct JSPrincipals;
22
23
namespace mozilla {
24
namespace ipc {
25
26
class XPCShellEnvironment
27
{
28
public:
29
    static XPCShellEnvironment* CreateEnvironment();
30
    ~XPCShellEnvironment();
31
32
    void ProcessFile(JSContext *cx, const char *filename, FILE *file, bool forceTTY);
33
    bool EvaluateString(const nsString& aString,
34
                        nsString* aResult = nullptr);
35
36
0
    JSPrincipals* GetPrincipal() {
37
0
        return nsJSPrincipals::get(nsContentUtils::GetSystemPrincipal());
38
0
    }
39
40
0
    JSObject* GetGlobalObject() {
41
0
        return mGlobalHolder;
42
0
    }
43
44
0
    void SetIsQuitting() {
45
0
        mQuitting = true;
46
0
    }
47
0
    bool IsQuitting() {
48
0
        return mQuitting;
49
0
    }
50
51
protected:
52
    XPCShellEnvironment();
53
    bool Init();
54
55
private:
56
    JS::PersistentRooted<JSObject *> mGlobalHolder;
57
58
    bool mQuitting;
59
};
60
61
} /* namespace ipc */
62
} /* namespace mozilla */
63
64
#endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */