v8/test/debugger/debug/es6/debug-scope-default-param-with-eval.js
jgruber 1834ab7246 [debug-wrapper] Adapt tests, breakpoint.actual_location
Adapted various tests to restrictions of inspector protocol:

* osr-typing-debug-change: Don't set function variable value.
* debug-evaluate-locals: Add variable introduced by eval, run typeof
  inside evaluate().
* regress-419663: Don't set duplicate breakpoints.
* regress-crbug-465298: Compare against function name instead of value.
* regress-crbug-621361: Make evaluate return string results.
* debug-script: Various counts were off due to new way tests are called.
                Added new inspector script type.

Breakpoints now contain the actual break position, and remote object
reconstruction has been extended a bit.

BUG=v8:5530

Review-Url: https://codereview.chromium.org/2505363002
Cr-Commit-Position: refs/heads/master@{#41129}
2016-11-21 09:29:17 +00:00

61 lines
1.7 KiB
JavaScript

// Copyright 2016 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.
// Test that the parameter initialization block scope set up for
// sloppy eval is visible to the debugger.
var Debug = debug.Debug;
var exception = null;
var break_count = 0;
function call_for_break() {
return 5;
}
function test(x = eval("var y = 7; debugger; y") + call_for_break()) {
return x;
}
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var frame = exec_state.frame(0);
var block_scope;
if (break_count++ == 0) {
// Inside eval.
assertEquals([ debug.ScopeType.Eval,
debug.ScopeType.Block,
debug.ScopeType.Closure,
debug.ScopeType.Script,
debug.ScopeType.Global ],
frame.allScopes().map(s => s.scopeType()));
exec_state.prepareStep(Debug.StepAction.StepOut);
block_scope = frame.scope(1);
} else {
// Outside of eval.
assertEquals([ debug.ScopeType.Block,
debug.ScopeType.Local,
debug.ScopeType.Script,
debug.ScopeType.Global ],
frame.allScopes().map(s => s.scopeType()));
block_scope = frame.scope(0);
}
assertTrue(block_scope.scopeObject().propertyNames().includes('y'));
assertEquals(7, block_scope.scopeObject().property('y').value().value());
} catch (e) {
print(e);
exception = e;
}
}
Debug.setListener(listener);
assertEquals(12, test());
Debug.setListener(null);
assertNull(exception);
assertEquals(2, break_count);