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 389954 6b5a1893be9137df17e9c271e0c6a3d0e15c3983
parent 389953 875e441f8b804adaf67ad704171c8b2f04015499
child 389955 6ed62e6074afa9f70dd7921533d2f3b1f7c5e622
push id23566
push usertkuo@mozilla.com
push dateWed, 20 Jul 2016 10:57:43 +0000
reviewersjandem
bugs1287401
milestone50.0a1
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);
 }