1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* XPConnect JavaScript interactive shell. */
11 #include "mozilla/Bootstrap.h"
12 #include "XREShellData.h"
15 # include "xpcshellMacUtils.h"
18 # include "mozilla/WindowsDllBlocklist.h"
23 // we want a wmain entry point
24 # define XRE_WANT_ENVIRON
25 # include "nsWindowsWMain.cpp"
27 # include "mozilla/sandboxing/SandboxInitialization.h"
35 #include "BaseProfiler.h"
38 # include "FuzzerDefs.h"
41 int main(int argc
, char** argv
, char** envp
) {
43 // A default display may or may not be required for xpcshell tests, and so
44 // is not created here. Instead we set the command line args, which is a
45 // fairly cheap operation.
46 gtk_parse_args(&argc
, &argv
);
50 InitAutoreleasePool();
53 // unbuffer stdout so that output is in the correct order; note that stderr
54 // is unbuffered by default
55 setbuf(stdout
, nullptr);
57 #ifdef HAS_DLL_BLOCKLIST
58 DllBlocklist_Initialize();
62 mozilla::baseprofiler::profiler_init(&aLocal
);
64 XREShellData shellData
;
65 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
66 shellData
.sandboxBrokerServices
=
67 mozilla::sandboxing::GetInitializedBrokerServices();
70 auto bootstrapResult
= mozilla::GetBootstrap();
71 if (bootstrapResult
.isErr()) {
75 mozilla::Bootstrap::UniquePtr bootstrap
= bootstrapResult
.unwrap();
78 shellData
.fuzzerDriver
= fuzzer::FuzzerDriver
;
81 shellData
.fuzzerDriver
= afl_interface_raw
;
84 int result
= bootstrap
->XRE_XPCShellMain(argc
, argv
, envp
, &shellData
);
86 mozilla::baseprofiler::profiler_shutdown();
88 #if defined(DEBUG) && defined(HAS_DLL_BLOCKLIST)
89 DllBlocklist_Shutdown();
93 FinishAutoreleasePool();