Bug 1928997: Update tabs icon in Unified Search popup r=desktop-theme-reviewers,daleh...
[gecko.git] / js / xpconnect / shell / xpcshell.cpp
blob02de402743c0e79a7c557b8bbc5ad5239ffc7ad5
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. */
9 #include <stdio.h>
11 #include "mozilla/Bootstrap.h"
12 #include "XREShellData.h"
14 #ifdef XP_MACOSX
15 # include "xpcshellMacUtils.h"
16 #endif
17 #ifdef XP_WIN
18 # include "mozilla/WindowsDllBlocklist.h"
20 # include <windows.h>
21 # include <shlobj.h>
23 // we want a wmain entry point
24 # define XRE_WANT_ENVIRON
25 # include "nsWindowsWMain.cpp"
26 # ifdef MOZ_SANDBOX
27 # include "mozilla/sandboxing/SandboxInitialization.h"
28 # endif
29 #endif
31 #ifdef MOZ_WIDGET_GTK
32 # include <gtk/gtk.h>
33 #endif
35 #include "BaseProfiler.h"
37 #ifdef LIBFUZZER
38 # include "FuzzerDefs.h"
39 #endif
41 int main(int argc, char** argv, char** envp) {
42 #ifdef MOZ_WIDGET_GTK
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);
47 #endif
49 #ifdef XP_MACOSX
50 InitAutoreleasePool();
51 #endif
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();
59 #endif
61 char aLocal;
62 mozilla::baseprofiler::profiler_init(&aLocal);
64 XREShellData shellData;
65 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
66 shellData.sandboxBrokerServices =
67 mozilla::sandboxing::GetInitializedBrokerServices();
68 #endif
70 auto bootstrapResult = mozilla::GetBootstrap();
71 if (bootstrapResult.isErr()) {
72 return 2;
75 mozilla::Bootstrap::UniquePtr bootstrap = bootstrapResult.unwrap();
77 #ifdef LIBFUZZER
78 shellData.fuzzerDriver = fuzzer::FuzzerDriver;
79 #endif
80 #ifdef AFLFUZZ
81 shellData.fuzzerDriver = afl_interface_raw;
82 #endif
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();
90 #endif
92 #ifdef XP_MACOSX
93 FinishAutoreleasePool();
94 #endif
96 return result;