diff --git a/deps/chakrashim/include/v8.h b/deps/chakrashim/include/v8.h index f34821d6027..2c83cad106f 100644 --- a/deps/chakrashim/include/v8.h +++ b/deps/chakrashim/include/v8.h @@ -99,8 +99,10 @@ class PropertyDescriptor; } namespace jsrt { - JsErrorCode CreateV8PropertyDescriptor(JsValueRef descriptor, - v8::PropertyDescriptor* result); +class IsolateShim; + +JsErrorCode CreateV8PropertyDescriptor(JsValueRef descriptor, + v8::PropertyDescriptor* result); } namespace v8 { @@ -377,6 +379,7 @@ class Local { friend JsErrorCode jsrt::CreateV8PropertyDescriptor( JsValueRef descriptor, v8::PropertyDescriptor* result); + friend class jsrt::IsolateShim; template friend class FunctionCallbackInfo; template friend class MaybeLocal; template friend class PersistentBase; diff --git a/deps/chakrashim/src/jsrtisolateshim.cc b/deps/chakrashim/src/jsrtisolateshim.cc index 7977f2c1011..5b71016538b 100644 --- a/deps/chakrashim/src/jsrtisolateshim.cc +++ b/deps/chakrashim/src/jsrtisolateshim.cc @@ -643,6 +643,27 @@ JsValueRef IsolateShim::GetChakraInspectorShimJsArrayBuffer() { return chakraInspectorShimArrayBuffer; } +void CHAKRA_CALLBACK IsolateShim::PromiseRejectionCallback( + JsValueRef promise, JsValueRef reason, bool handled, void *callbackState) { + CHAKRA_VERIFY(callbackState != nullptr); + v8::PromiseRejectCallback callback = + reinterpret_cast(callbackState); + + v8::PromiseRejectMessage message( + promise, + handled ? v8::kPromiseHandlerAddedAfterReject : + v8::kPromiseRejectWithNoHandler, + reason, + v8::Local()); + + callback(message); +} + +void IsolateShim::SetPromiseRejectCallback(v8::PromiseRejectCallback callback) { + JsSetHostPromiseRejectionTracker(IsolateShim::PromiseRejectionCallback, + reinterpret_cast(callback)); +} + /*static*/ bool IsolateShim::RunSingleStepOfReverseMoveLoop(v8::Isolate* isolate, uint64_t* moveMode, diff --git a/deps/chakrashim/src/jsrtisolateshim.h b/deps/chakrashim/src/jsrtisolateshim.h index a398ae54e08..46110f209f0 100644 --- a/deps/chakrashim/src/jsrtisolateshim.h +++ b/deps/chakrashim/src/jsrtisolateshim.h @@ -161,6 +161,8 @@ class IsolateShim { return isIdleGcScheduled; } + void SetPromiseRejectCallback(v8::PromiseRejectCallback callback); + private: // Construction/Destruction should go thru New/Dispose explicit IsolateShim(JsRuntimeHandle runtime); @@ -168,6 +170,8 @@ class IsolateShim { static v8::Isolate * ToIsolate(IsolateShim * isolate); static void CHAKRA_CALLBACK JsContextBeforeCollectCallback(JsRef contextRef, void *data); + static void CHAKRA_CALLBACK PromiseRejectionCallback( + JsValueRef promise, JsValueRef reason, bool handled, void *callbackState); JsRuntimeHandle runtime; JsPropertyIdRef symbolPropertyIdRefs[CachedSymbolPropertyIdRef::SymbolCount]; diff --git a/deps/chakrashim/src/v8isolate.cc b/deps/chakrashim/src/v8isolate.cc index dfb86d90331..04d780b7b6a 100644 --- a/deps/chakrashim/src/v8isolate.cc +++ b/deps/chakrashim/src/v8isolate.cc @@ -112,7 +112,7 @@ Local Isolate::GetCurrentContext() { } void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { - // CHAKRA does not support this explicit callback + jsrt::IsolateShim::FromIsolate(this)->SetPromiseRejectCallback(callback); } void Isolate::SetPromiseHook(PromiseHook hook) { diff --git a/test/message/message.status b/test/message/message.status index d9ec70f421a..f6d51ce1fd7 100644 --- a/test/message/message.status +++ b/test/message/message.status @@ -23,4 +23,3 @@ esm_display_syntax_error : SKIP esm_display_syntax_error_import : SKIP esm_display_syntax_error_import_module : SKIP esm_display_syntax_error_module : SKIP -unhandled_promise_trace_warnings : SKIP diff --git a/test/message/unhandled_promise_trace_warnings.chakracore.out b/test/message/unhandled_promise_trace_warnings.chakracore.out new file mode 100644 index 00000000000..c79ace2fd10 --- /dev/null +++ b/test/message/unhandled_promise_trace_warnings.chakracore.out @@ -0,0 +1,45 @@ +(node:*) UnhandledPromiseRejectionWarning: Error: This was rejected + at * (*test*message*unhandled_promise_trace_warnings.js:*) + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * + at * +(node:*) Error: This was rejected + at * (*test*message*unhandled_promise_trace_warnings.js:*) + at * + at * + at * + at * + at * + at * + at * + at * +(node:*) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. + at * + at * + at * + at * + at * + at * + at * + at * +(node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1) + at * + at handledRejection (internal/process/promises.js:*) + at Promise.prototype.then (native code:0:0) + at Promise.prototype.catch (native code:0:0) + at Anonymous function (*test*message*unhandled_promise_trace_warnings.js:*) + at * + at * + at * diff --git a/test/message/unhandled_promise_trace_warnings.out b/test/message/unhandled_promise_trace_warnings.v8.out similarity index 100% rename from test/message/unhandled_promise_trace_warnings.out rename to test/message/unhandled_promise_trace_warnings.v8.out diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 99f9bc1e5d9..6a5651a8d35 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -63,9 +63,7 @@ test-performance-function : SKIP test-performance-gc : SKIP test-process-env-symbols : SKIP test-promise-internal-creation : SKIP -test-promises-unhandled-rejections : SKIP test-promises-unhandled-symbol-rejections : SKIP -test-promises-warning-on-unhandled-rejection : SKIP test-regress-GH-12371 : SKIP test-repl : SKIP test-repl-inspector : SKIP diff --git a/test/sequential/sequential.status b/test/sequential/sequential.status index 54d68cda4ae..d9639e54c5b 100644 --- a/test/sequential/sequential.status +++ b/test/sequential/sequential.status @@ -34,6 +34,7 @@ test-inspector-async-call-stack-abort : SKIP test-inspector-async-hook-setup-at-inspect-brk : SKIP test-inspector-async-stack-traces-promise-then : SKIP test-inspector-async-stack-traces-set-interval : SKIP +test-inspector-bindings : SKIP test-inspector-break-when-eval : SKIP test-inspector-contexts : SKIP test-inspector-scriptparsed-context : SKIP diff --git a/test/sequential/test-inspector-debug-brk-flag.js b/test/sequential/test-inspector-debug-brk-flag.js index 61eb4f97c65..a1531b0a219 100644 --- a/test/sequential/test-inspector-debug-brk-flag.js +++ b/test/sequential/test-inspector-debug-brk-flag.js @@ -14,14 +14,20 @@ async function testBreakpointOnStart(session) { { 'method': 'Debugger.setPauseOnExceptions', 'params': { 'state': 'none' } }, { 'method': 'Debugger.setAsyncCallStackDepth', - 'params': { 'maxDepth': 0 } }, - { 'method': 'Profiler.enable' }, - { 'method': 'Profiler.setSamplingInterval', - 'params': { 'interval': 100 } }, + 'params': { 'maxDepth': 0 } } + ]; + + if (process.jsEngine !== 'chakracore') { + commands.push( + { 'method': 'Profiler.enable' }, + { 'method': 'Profiler.setSamplingInterval', + 'params': { 'interval': 100 } }); + } + + commands.push( { 'method': 'Debugger.setBlackboxPatterns', 'params': { 'patterns': [] } }, - { 'method': 'Runtime.runIfWaitingForDebugger' } - ]; + { 'method': 'Runtime.runIfWaitingForDebugger' }); session.send(commands); await session.waitForBreakOnLine(0, session.scriptPath());