mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 11:36:57 +00:00

PR-URL: https://github.com/nodejs/node/pull/40907 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
39 lines
931 B
JavaScript
39 lines
931 B
JavaScript
// Copyright 2011 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
|
|
|
|
let listenerComplete = false;
|
|
let exceptionThrown = false;
|
|
|
|
function listener(event, exec_state, event_data, data) {
|
|
try {
|
|
if (event == Debug.DebugEvent.Break) {
|
|
assertEquals(42, exec_state.frame(0).evaluate("42").value());
|
|
// Indicate that all was processed.
|
|
listenerComplete = true;
|
|
}
|
|
} catch (e) {
|
|
exceptionThrown = true;
|
|
};
|
|
};
|
|
|
|
// Add the debug event listener.
|
|
Debug.setListener(listener);
|
|
|
|
assertEquals(
|
|
42,
|
|
(function f() {
|
|
eval("var f = 42");
|
|
debugger;
|
|
return f;
|
|
})()
|
|
);
|
|
|
|
Debug.setListener(null);
|
|
|
|
assertFalse(exceptionThrown, "exception in listener");
|
|
// Make sure that the debug event listener vas invoked.
|
|
assertTrue(listenerComplete, "listener did not run to completion");
|