Bug 951632 - Fix shell metadata hook to skip functions from other compartments. r=luke
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 09 Jan 2014 11:07:59 +0100
changeset 178700 b76b2eb15da36f9fb0f3b1754bd28d6f349ca92a
parent 178699 18eeafedd18015db046f4b9a910e85f1e1e5c173
child 178701 1956aaafa45a21b00b824dc11b9a9482671c336b
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs951632
milestone29.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 951632 - Fix shell metadata hook to skip functions from other compartments. r=luke
js/src/builtin/TestingFunctions.cpp
js/src/jit-test/tests/basic/bug951632.js
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -1004,17 +1004,17 @@ ShellObjectMetadataCallback(JSContext *c
     if (!JS_DefineProperty(cx, obj, "stack", ObjectValue(*stack),
                            JS_PropertyStub, JS_StrictPropertyStub, 0))
     {
         return false;
     }
 
     int stackIndex = 0;
     for (NonBuiltinScriptFrameIter iter(cx); !iter.done(); ++iter) {
-        if (iter.isFunctionFrame()) {
+        if (iter.isFunctionFrame() && iter.compartment() == cx->compartment()) {
             if (!JS_DefinePropertyById(cx, stack, INT_TO_JSID(stackIndex), ObjectValue(*iter.callee()),
                                        JS_PropertyStub, JS_StrictPropertyStub, 0))
             {
                 return false;
             }
             stackIndex++;
         }
     }
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug951632.js
@@ -0,0 +1,9 @@
+setObjectMetadataCallback(true);
+var g = newGlobal()
+g.eval("function f(a) { return h(); }");
+g.h = function () {
+    return [1, 2, 3];
+};
+var o = getObjectMetadata(g.f(5));
+assertEq(o.stack.length, 1);
+assertEq(o.stack[0], g.h);