Bug 1274193 part 11 - Make GetOutermostEnclosingFunctionOfScriptedCaller per-compartment and use GO_THROUGH_SAVED. r=luke
☠☠ backed out by b8dbe70e2500 ☠ ☠
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 25 May 2016 10:38:34 +0200
changeset 298924 b47a1a49cda2c961c45d851b85df1b2cf97d0a57
parent 298923 51b1f2343ad9544921e68859dfbe9d3c79b00951
child 298925 2d60e772249dfeb1b49802fe7ad01791498bb8df
push id30286
push userkwierso@gmail.com
push dateWed, 25 May 2016 22:33:39 +0000
treeherdermozilla-central@1012461fa7bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1274193
milestone49.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 1274193 part 11 - Make GetOutermostEnclosingFunctionOfScriptedCaller per-compartment and use GO_THROUGH_SAVED. r=luke
js/src/jsfriendapi.cpp
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -398,33 +398,38 @@ JS_FRIEND_API(bool)
 js::RunningWithTrustedPrincipals(JSContext* cx)
 {
     return cx->runningWithTrustedPrincipals();
 }
 
 JS_FRIEND_API(JSFunction*)
 js::GetOutermostEnclosingFunctionOfScriptedCaller(JSContext* cx)
 {
-    ScriptFrameIter iter(cx, FrameIter::STOP_AT_SAVED);
+    ScriptFrameIter iter(cx, FrameIter::GO_THROUGH_SAVED);
 
     // Skip eval frames.
     while (!iter.done() && iter.isEvalFrame())
         ++iter;
 
     if (iter.done())
         return nullptr;
 
     if (!iter.isFunctionFrame())
         return nullptr;
 
+    if (iter.compartment() != cx->compartment())
+        return nullptr;
+
     RootedFunction curr(cx, iter.callee(cx));
     for (StaticScopeIter<NoGC> i(curr); !i.done(); i++) {
         if (i.type() == StaticScopeIter<NoGC>::Function)
             curr = &i.fun();
     }
+
+    assertSameCompartment(cx, curr);
     return curr;
 }
 
 JS_FRIEND_API(JSFunction*)
 js::DefineFunctionWithReserved(JSContext* cx, JSObject* objArg, const char* name, JSNative call,
                                unsigned nargs, unsigned attrs)
 {
     RootedObject obj(cx, objArg);