}
+static bool SetBlockContextVariableValue(Handle<Context> block_context,
+ Handle<String> variable_name,
+ Handle<Object> new_value) {
+ DCHECK(block_context->IsBlockContext());
+ Handle<ScopeInfo> scope_info(ScopeInfo::cast(block_context->extension()));
+
+ return SetContextLocalValue(block_context->GetIsolate(), scope_info,
+ block_context, variable_name, new_value);
+}
+
+
// Create a plain JSObject which materializes the scope for the specified
// catch context.
MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeCatchScope(
return SetClosureVariableValue(isolate_, CurrentContext(),
variable_name, new_value);
case ScopeIterator::ScopeTypeBlock:
- // TODO(2399): should we implement it?
- break;
+ return SetBlockContextVariableValue(CurrentContext(), variable_name,
+ new_value);
case ScopeIterator::ScopeTypeModule:
// TODO(2399): should we implement it?
break;
Debug.clearBreakPoint(bp);
// Get rid of the debug event listener.
Debug.setListener(null);
+
+
+function f1() {
+ {
+ let i = 1;
+ debugger;
+ assertEquals(2, i);
+ }
+}
+
+function f2() {
+ {
+ let i = 1;
+ debugger;
+ assertEquals(2, i);
+ return function() { return i++; }
+ }
+}
+
+var exception;
+Debug.setListener(function (event, exec_state, event_data, data) {
+ try {
+ if (event == Debug.DebugEvent.Break) {
+ var frame = exec_state.frame();
+ assertEquals(1, frame.evaluate("i").value());
+ var allScopes = frame.allScopes();
+ assertEquals(1, allScopes[0].scopeObject().value().i);
+ allScopes[0].setVariableValue("i", 2);
+ }
+ } catch (e) {
+ exception = e;
+ }
+});
+
+exception = null;
+f1();
+assertEquals(null, exception, exception);
+exception = null;
+f2();
+assertEquals(null, exception, exception);