Bug 1287401 - Enter the callback's compartment before running it in the JS shell's ForwardingPromiseRejectionTrackerCallback. r=jandem
authorTill Schneidereit <till@tillschneidereit.net>
Tue, 19 Jul 2016 03:13:00 +0200
changeset 305793 6b5a1893be9137df17e9c271e0c6a3d0e15c3983
parent 305792 875e441f8b804adaf67ad704171c8b2f04015499
child 305794 6ed62e6074afa9f70dd7921533d2f3b1f7c5e622
push id30467
push usercbook@mozilla.com
push dateWed, 20 Jul 2016 09:21:53 +0000
treeherdermozilla-central@e904e18d7dfc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1287401
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1287401 - Enter the callback's compartment before running it in the JS shell's ForwardingPromiseRejectionTrackerCallback. r=jandem
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -687,16 +687,18 @@ static void
 ForwardingPromiseRejectionTrackerCallback(JSContext* cx, JS::HandleObject promise,
                                           PromiseRejectionHandlingState state, void* data)
 {
     RootedValue callback(cx, GetShellContext(cx)->promiseRejectionTrackerCallback);
     if (callback.isNull()) {
         return;
     }
 
+    AutoCompartment ac(cx, &callback.toObject());
+
     FixedInvokeArgs<2> args(cx);
     args[0].setObject(*promise);
     args[1].setInt32(static_cast<int32_t>(state));
 
     RootedValue rval(cx);
     if (!Call(cx, callback, UndefinedHandleValue, args, &rval))
         JS_ClearPendingException(cx);
 }