mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 22:04:26 +00:00

PR-URL: https://github.com/nodejs/node/pull/35415 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
// Copyright 2018 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: --ignore-unhandled-promises
|
|
|
|
// Test debug events when we listen to all exceptions and
|
|
// there is a catch handler for the exception thrown in a Promise.
|
|
// We expect a normal Exception debug event to be triggered.
|
|
|
|
Debug = debug.Debug;
|
|
|
|
var expected_events = 1;
|
|
var log = [];
|
|
|
|
|
|
class P extends Promise {
|
|
constructor(...args) {
|
|
super(...args);
|
|
return new Proxy(this, {
|
|
get(target, property, receiver) {
|
|
if (property in target) {
|
|
return Reflect.get(target, property, receiver);
|
|
} else {
|
|
return (...args) =>
|
|
new Promise((resolve, reject) =>
|
|
target.then(v => resolve(v[property](...args)))
|
|
.catch(reject)
|
|
);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
P.resolve({doStuff(){log.push(1)}}).doStuff()
|
|
|
|
function listener(event, exec_state, event_data, data) {}
|
|
|
|
Debug.setBreakOnUncaughtException();
|
|
Debug.setListener(listener);
|
|
|
|
%PerformMicrotaskCheckpoint();
|