summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/debug-evaluate-nested.js
blob: da11b9001c02606cc2e6e000e9531b9f515d7ade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 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.

// Flags: --expose-debug-as debug

Debug = debug.Debug;
ScopeType = debug.ScopeType;
var exception = null;
var nested = false;

function bar() {
  let a = 1;
  (function foo() {
    let b = a;
    with (new Proxy({}, {})) {
      debugger;
    }
  })();
}

function checkScopes(scopes, expectation) {
  assertEquals(scopes.map(s => s.scopeType()), expectation);
}

function listener(event, exec_state, event_data, data) {
  if (event != Debug.DebugEvent.Break) return;
  try {
    if (!nested) {
      nested = true;
      checkScopes(exec_state.frame(0).allScopes(),
                  [ ScopeType.With, ScopeType.Local, ScopeType.Closure,
                    ScopeType.Script, ScopeType.Global ]);
      exec_state.frame(0).evaluate("debugger;");
    } else {
      checkScopes(exec_state.frame(0).allScopes(),
                  [ ScopeType.With, ScopeType.Closure,
                    ScopeType.Script, ScopeType.Global ]);
    }
  } catch (e) {
    exception = e;
    print(e + e.stack);
  }
}

Debug.setListener(listener);
bar();
Debug.setListener(null);
assertNull(exception);