summaryrefslogtreecommitdiffstats
path: root/js/xpconnect
diff options
context:
space:
mode:
Diffstat (limited to 'js/xpconnect')
-rw-r--r--js/xpconnect/shell/moz.build16
-rw-r--r--js/xpconnect/shell/xpcshell.cpp11
-rw-r--r--js/xpconnect/src/ExportHelpers.cpp11
-rw-r--r--js/xpconnect/src/XPCJSContext.cpp26
-rw-r--r--js/xpconnect/src/XPCShellImpl.cpp18
-rw-r--r--js/xpconnect/src/XPCWrappedNative.cpp7
-rw-r--r--js/xpconnect/tests/unit/test_exportFunction.js3
7 files changed, 20 insertions, 72 deletions
diff --git a/js/xpconnect/shell/moz.build b/js/xpconnect/shell/moz.build
index ecc796f7f..d4f5d55af 100644
--- a/js/xpconnect/shell/moz.build
+++ b/js/xpconnect/shell/moz.build
@@ -35,22 +35,6 @@ if CONFIG['_MSC_VER']:
if CONFIG['OS_ARCH'] == 'WINNT':
RCINCLUDE = 'xpcshell.rc'
- if CONFIG['MOZ_SANDBOX']:
- # For sandbox includes and the include dependencies those have
- LOCAL_INCLUDES += [
- '/security/sandbox/chromium',
- '/security/sandbox/chromium-shim',
- ]
-
- USE_LIBS += [
- 'sandbox_s',
- ]
-
- DELAYLOAD_DLLS += [
- 'winmm.dll',
- 'user32.dll',
- ]
-
DELAYLOAD_DLLS += [
'xul.dll',
]
diff --git a/js/xpconnect/shell/xpcshell.cpp b/js/xpconnect/shell/xpcshell.cpp
index ba979bc69..4eef3f6bf 100644
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -22,9 +22,6 @@
#define XRE_DONT_PROTECT_DLL_LOAD
#define XRE_WANT_ENVIRON
#include "nsWindowsWMain.cpp"
-#ifdef MOZ_SANDBOX
-#include "mozilla/sandboxing/SandboxInitialization.h"
-#endif
#endif
#ifdef MOZ_WIDGET_GTK
@@ -53,13 +50,7 @@ main(int argc, char** argv, char** envp)
DllBlocklist_Initialize();
#endif
- XREShellData shellData;
-#if defined(XP_WIN) && defined(MOZ_SANDBOX)
- shellData.sandboxBrokerServices =
- mozilla::sandboxing::GetInitializedBrokerServices();
-#endif
-
- int result = XRE_XPCShellMain(argc, argv, envp, &shellData);
+ int result = XRE_XPCShellMain(argc, argv, envp);
#ifdef XP_MACOSX
FinishAutoreleasePool();
diff --git a/js/xpconnect/src/ExportHelpers.cpp b/js/xpconnect/src/ExportHelpers.cpp
index 3dbf83e3b..e574e708c 100644
--- a/js/xpconnect/src/ExportHelpers.cpp
+++ b/js/xpconnect/src/ExportHelpers.cpp
@@ -329,11 +329,20 @@ NewFunctionForwarder(JSContext* cx, HandleId idArg, HandleObject callable,
if (id == JSID_VOIDHANDLE)
id = GetJSIDByIndex(cx, XPCJSContext::IDX_EMPTYSTRING);
+ // If our callable is a (possibly wrapped) function, we can give
+ // the exported thing the right number of args.
+ unsigned nargs = 0;
+ RootedObject unwrapped(cx, js::UncheckedUnwrap(callable));
+ if (unwrapped) {
+ if (JSFunction* fun = JS_GetObjectFunction(unwrapped))
+ nargs = JS_GetFunctionArity(fun);
+ }
+
// We have no way of knowing whether the underlying function wants to be a
// constructor or not, so we just mark all forwarders as constructors, and
// let the underlying function throw for construct calls if it wants.
JSFunction* fun = js::NewFunctionByIdWithReserved(cx, FunctionForwarder,
- 0, JSFUN_CONSTRUCTOR, id);
+ nargs, JSFUN_CONSTRUCTOR, id);
if (!fun)
return false;
diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp
index f5f6a11bb..f352607d4 100644
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -59,10 +59,6 @@
#include "nsIXULRuntime.h"
#include "nsJSPrincipals.h"
-#if defined(MOZ_JEMALLOC4)
-#include "mozmemory.h"
-#endif
-
#ifdef XP_WIN
#include <windows.h>
#endif
@@ -147,18 +143,6 @@ public:
mActive = false;
}
} else {
-#if defined(MOZ_JEMALLOC4)
- if (mPurge) {
- /* Jemalloc purges dirty pages regularly during free() when the
- * ratio of dirty pages compared to active pages is higher than
- * 1 << lg_dirty_mult. A high ratio can have an impact on
- * performance, so we use the default ratio of 8, but force a
- * regular purge of all remaining dirty pages, after cycle
- * collection. */
- Telemetry::AutoTimer<Telemetry::MEMORY_FREE_PURGED_PAGES_MS> timer;
- jemalloc_free_dirty_pages();
- }
-#endif
mActive = false;
}
return NS_OK;
@@ -1544,12 +1528,6 @@ XPCJSContext::~XPCJSContext()
delete mDyingWrappedNativeProtoMap;
mDyingWrappedNativeProtoMap = nullptr;
-#ifdef MOZ_ENABLE_PROFILER_SPS
- // Tell the profiler that the context is gone
- if (PseudoStack* stack = mozilla_get_pseudo_stack())
- stack->sampleContext(nullptr);
-#endif
-
Preferences::UnregisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this);
}
@@ -3398,10 +3376,6 @@ XPCJSContext::Initialize()
JS_AddWeakPointerCompartmentCallback(cx, WeakPointerCompartmentCallback, this);
JS_SetWrapObjectCallbacks(cx, &WrapObjectCallbacks);
js::SetPreserveWrapperCallback(cx, PreserveWrapper);
-#ifdef MOZ_ENABLE_PROFILER_SPS
- if (PseudoStack* stack = mozilla_get_pseudo_stack())
- stack->sampleContext(cx);
-#endif
JS_SetAccumulateTelemetryCallback(cx, AccumulateTelemetryCallback);
js::SetActivityCallback(cx, ActivityCallback, this);
JS_AddInterruptCallback(cx, InterruptCallback);
diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp
index 45d00d390..a6432856d 100644
--- a/js/xpconnect/src/XPCShellImpl.cpp
+++ b/js/xpconnect/src/XPCShellImpl.cpp
@@ -44,9 +44,6 @@
#ifdef XP_WIN
#include "mozilla/widget/AudioSession.h"
#include <windows.h>
-#if defined(MOZ_SANDBOX)
-#include "SandboxBroker.h"
-#endif
#endif
// all this crap is needed to do the interactive shell stuff
@@ -1235,11 +1232,8 @@ GetCurrentWorkingDirectory(nsAString& workingDirectory)
static JSSecurityCallbacks shellSecurityCallbacks;
int
-XRE_XPCShellMain(int argc, char** argv, char** envp,
- const XREShellData* aShellData)
+XRE_XPCShellMain(int argc, char** argv, char** envp)
{
- MOZ_ASSERT(aShellData);
-
JSContext* cx;
int result = 0;
nsresult rv;
@@ -1484,16 +1478,6 @@ XRE_XPCShellMain(int argc, char** argv, char** envp,
// Plugin may require audio session if installed plugin can initialize
// asynchronized.
AutoAudioSession audioSession;
-
-#if defined(MOZ_SANDBOX)
- // Required for sandboxed child processes.
- if (aShellData->sandboxBrokerServices) {
- SandboxBroker::Initialize(aShellData->sandboxBrokerServices);
- } else {
- NS_WARNING("Failed to initialize broker services, sandboxed "
- "processes will fail to start.");
- }
-#endif
#endif
{
diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp
index acf92f3c3..a12e36baa 100644
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -1785,9 +1785,12 @@ CallMethodHelper::ConvertIndependentParam(uint8_t i)
// indirectly, regardless of in/out-ness.
if (type_tag == nsXPTType::T_JSVAL) {
// Root the value.
- dp->val.j.setUndefined();
- if (!js::AddRawValueRoot(mCallContext, &dp->val.j, "XPCWrappedNative::CallMethod param"))
+ dp->val.j.asValueRef().setUndefined();
+ if (!js::AddRawValueRoot(mCallContext, &dp->val.j.asValueRef(),
+ "XPCWrappedNative::CallMethod param"))
+ {
return false;
+ }
}
// Flag cleanup for anything that isn't self-contained.
diff --git a/js/xpconnect/tests/unit/test_exportFunction.js b/js/xpconnect/tests/unit/test_exportFunction.js
index 830816342..9e1bf2082 100644
--- a/js/xpconnect/tests/unit/test_exportFunction.js
+++ b/js/xpconnect/tests/unit/test_exportFunction.js
@@ -10,12 +10,14 @@ function run_test() {
epsb.do_check_true = do_check_true;
epsb.do_check_eq = do_check_eq;
subsb.do_check_true = do_check_true;
+ subsb.do_check_eq = do_check_eq;
// Exporting should work if prinicipal of the source sandbox
// subsumes the principal of the target sandbox.
Cu.evalInSandbox("(" + function() {
var wasCalled = false;
this.funToExport = function(expectedThis, a, obj, native, mixed, callback) {
+ do_check_eq(arguments.callee.length, 6);
do_check_eq(a, 42);
do_check_eq(obj, subsb.tobecloned);
do_check_eq(obj.cloned, "cloned");
@@ -53,6 +55,7 @@ function run_test() {
invokedCallback = false;
callback = function() { invokedCallback = true; };
imported(this, 42, tobecloned, native, mixed, callback);
+ do_check_eq(imported.length, 6);
do_check_true(invokedCallback);
}.toSource() + ")()", subsb);