mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 11:29:34 +00:00

Add the new status in order to distinguish a state wherein an exception is pending from one wherein the engine is unable to execute JS. We take advantage of the new runtime add-on version reporting in order to remain forward compatible with add-ons that do not expect the new status code. PR-URL: https://github.com/nodejs/node/pull/47986 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Signed-off-by: Gabriel Schulhof <gabrielschulhof@gmail.com>
25 lines
941 B
JavaScript
25 lines
941 B
JavaScript
'use strict';
|
|
|
|
// Test that `napi_call_function()` returns `napi_cannot_run_js` in experimental
|
|
// mode and `napi_pending_exception` otherwise. This test calls the add-on's
|
|
// `createRef()` method, which creates a strong reference to a JS function. When
|
|
// the process exits, it calls all reference finalizers. The finalizer for the
|
|
// strong reference created herein will attempt to call `napi_get_property()` on
|
|
// a property of the global object and will abort the process if the API doesn't
|
|
// return the correct status.
|
|
|
|
const { buildType, mustNotCall } = require('../../common');
|
|
const addon_v8 = require(`./build/${buildType}/test_pending_exception`);
|
|
const addon_new = require(`./build/${buildType}/test_cannot_run_js`);
|
|
|
|
function runTests(addon, isVersion8) {
|
|
addon.createRef(mustNotCall());
|
|
}
|
|
|
|
function runAllTests() {
|
|
runTests(addon_v8, /* isVersion8 */ true);
|
|
runTests(addon_new, /* isVersion8 */ false);
|
|
}
|
|
|
|
runAllTests();
|