Bug 1253246 - Handle DebugScopeProxies around unqualified varobjs in setname. (r=jorendorff)
authorShu-yu Guo <shu@rfrn.org>
Tue, 22 Mar 2016 16:19:52 -0700
changeset 289989 4ec87322b994b6624ff3338ce3479e2bda40c7bf
parent 289988 741f7c1ea3da067cedf66cf8b323248a55d17614
child 289990 6c3d92cbde28b6921e2525e91d7199c718b33169
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1253246
milestone48.0a1
Bug 1253246 - Handle DebugScopeProxies around unqualified varobjs in setname. (r=jorendorff)
js/src/jit-test/tests/debug/bug1253246.js
js/src/vm/Interpreter-inl.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/bug1253246.js
@@ -0,0 +1,5 @@
+var g = newGlobal();
+var dbg = new Debugger(g);
+
+dbg.onDebuggerStatement = (frame) => { frame.eval("c = 42;"); };
+g.evalReturningScope("'use strict'; debugger;");
--- a/js/src/vm/Interpreter-inl.h
+++ b/js/src/vm/Interpreter-inl.h
@@ -273,19 +273,23 @@ SetNameOperation(JSContext* cx, JSScript
     // In strict mode, assigning to an undeclared global variable is an
     // error. To detect this, we call NativeSetProperty directly and pass
     // Unqualified. It stores the error, if any, in |result|.
     bool ok;
     ObjectOpResult result;
     RootedId id(cx, NameToId(name));
     RootedValue receiver(cx, ObjectValue(*scope));
     if (scope->isUnqualifiedVarObj()) {
-        MOZ_ASSERT(!scope->getOps()->setProperty);
-        ok = NativeSetProperty(cx, scope.as<NativeObject>(), id, val, receiver, Unqualified,
-                               result);
+        RootedNativeObject varobj(cx);
+        if (scope->is<DebugScopeObject>())
+            varobj = &scope->as<DebugScopeObject>().scope().as<NativeObject>();
+        else
+            varobj = &scope->as<NativeObject>();
+        MOZ_ASSERT(!varobj->getOps()->setProperty);
+        ok = NativeSetProperty(cx, varobj, id, val, receiver, Unqualified, result);
     } else {
         ok = SetProperty(cx, scope, id, val, receiver, result);
     }
     return ok && result.checkStrictErrorOrWarning(cx, scope, id, strict);
 }
 
 inline bool
 DefLexicalOperation(JSContext* cx, Handle<ClonedBlockObject*> lexicalScope,