diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc index 660fc7ffa2..d071cbf7f9 100644 --- a/src/runtime/runtime-debug.cc +++ b/src/runtime/runtime-debug.cc @@ -2500,18 +2500,21 @@ class EvaluationContextBuilder { outer_info_ = handle(function->shared()); Handle inner_context; - // The "this" binding, if any, can't be bound via "with". If we need to, - // add another node onto the outer context to bind "this". - if (!MaterializeReceiver(isolate, outer_context, function, frame) - .ToHandle(&outer_context)) - return; - bool stop = false; for (ScopeIterator it(isolate, frame, inlined_jsframe_index); !it.Failed() && !it.Done() && !stop; it.Next()) { ScopeIterator::ScopeType scope_type = it.Type(); if (scope_type == ScopeIterator::ScopeTypeLocal) { + Handle parent_context = + it.HasContext() ? it.CurrentContext() : outer_context; + + // The "this" binding, if any, can't be bound via "with". If we need + // to, add another node onto the outer context to bind "this". + if (!MaterializeReceiver(isolate, parent_context, function, frame) + .ToHandle(&parent_context)) + return; + Handle materialized_function = NewJSObjectWithNullProto(isolate); @@ -2525,8 +2528,6 @@ class EvaluationContextBuilder { .ToHandle(&materialized_function)) return; - Handle parent_context = - it.HasContext() ? it.CurrentContext() : outer_context; Handle with_context = isolate->factory()->NewWithContext( function, parent_context, materialized_function); diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index 1b831d44d8..3b6bfc5bf7 100644 --- a/test/mjsunit/mjsunit.status +++ b/test/mjsunit/mjsunit.status @@ -118,6 +118,7 @@ 'regress/regress-crbug-107996': [PASS, NO_VARIANTS], 'regress/regress-crbug-171715': [PASS, NO_VARIANTS], 'regress/regress-crbug-222893': [PASS, NO_VARIANTS], + 'regress/regress-crbug-491943': [PASS, NO_VARIANTS], 'regress/regress-325676': [PASS, NO_VARIANTS], 'debug-evaluate-closure': [PASS, NO_VARIANTS], 'debug-evaluate-with': [PASS, NO_VARIANTS], diff --git a/test/mjsunit/regress/regress-crbug-491943.js b/test/mjsunit/regress/regress-crbug-491943.js new file mode 100644 index 0000000000..c87d1301b7 --- /dev/null +++ b/test/mjsunit/regress/regress-crbug-491943.js @@ -0,0 +1,25 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug + +var Debug = debug.Debug; +var receiver = null; + +Debug.setListener(function(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Break) return; + receiver = exec_state.frame(0).evaluate('this').value(); +}); + + +function f() { + var context_local = 1; + (function() { return context_local; })(); + debugger; +} + +var expected = {}; +f.call(expected); + +assertEquals(expected, receiver);