v8/test/debugger/debug/debug-evaluate-function-var.js
Yang Guo 9f8561be3d Reland "[debugger] Expose reference to the function in debug-evaluate"
This is a reland of 8de427fae8

Original change's description:
> [debugger] Expose reference to the function in debug-evaluate
>
> R=verwaest@chromium.org
>
> Bug: chromium:878723
> Change-Id: Ic07f75f15230018b6d19cd1ee21f4be6dcad6360
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1667408
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#62385}

TBR=jgruber@chromium.org

Bug: chromium:878723
Change-Id: I0386655a9b2632d2d9438e674d4205ce5e5365f5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1679490
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62401}
2019-06-27 06:09:22 +00:00

43 lines
835 B
JavaScript

// Copyright 2019 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.
Debug = debug.Debug
var exception = null;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
var frame = exec_state.frame(0);
try {
assertTrue(frame.evaluate("f").value().startsWith("function f()"));
} catch {
assertTrue(frame.sourceLineText().endsWith("throws"));
}
}
} catch(e) {
exception = e;
print(e, e.stack);
}
};
Debug.setListener(listener);
(function f() {
f;
debugger; // works
})();
(function f() {
() => f;
debugger; // works
})();
(function f() {
debugger; // throws
})();
assertNull(exception);
Debug.setListener(null);