node/test/js-native-api
Chengzhong Wu 8ff16fd8c0
node-api: fix immediate napi_remove_wrap test
As documented in napi_wrap section, the returned reference must be
deleted with `napi_delete_reference` in response to the finalize
callback, in which `napi_unwrap` and `napi_remove_wrap` is not
available.

When the reference needs to be deleted early, it should be
deleted after the wrapped value is not accessed with `napi_unwrap`
and `napi_remove_wrap` too.

This test is previously added in response to duplicating the test
https://github.com/nodejs/node-addon-api/blob/main/test/objectwrap_constructor_exception.cc
in the node-addon-api. As Napi::ObjectWrap<> is a subclass of
Napi::Reference<>, napi_remove_wrap in the destructor of
Napi::ObjectWrap<> is called before napi_delete_reference in the
destructor of Napi::Reference<>.

PR-URL: https://github.com/nodejs/node/pull/45406
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2022-11-21 15:20:41 -05:00
..
2_function_arguments
3_callbacks
4_object_factory
5_function_factory
6_object_wrap
7_factory_wrap
8_passing_wrapped
test_array
test_bigint
test_constructor
test_conversions
test_dataview
test_date
test_error
test_exception test: pass data into napi_create_external 2022-04-02 23:57:33 +01:00
test_function
test_general node-api: handle no support for external buffers 2022-11-10 09:45:37 -03:00
test_handle_scope
test_instance_data
test_new_target
test_number
test_object src: fix napi_check_object_type_tag() 2022-07-14 15:22:46 -04:00
test_promise
test_properties node-api: add node_api_symbol_for() 2022-01-24 16:35:07 -05:00
test_reference node-api: emit uncaught-exception on unhandled tsfn callbacks 2022-05-27 13:32:08 -04:00
test_reference_double_free node-api: fix immediate napi_remove_wrap test 2022-11-21 15:20:41 -05:00
test_string
test_symbol test: replace commented out expectations with tests 2022-01-29 10:01:10 +00:00
test_typedarray
.gitignore
common.c
common.h node-api,src: fix module registration in MSVC C++ 2022-04-07 09:40:07 -04:00
entry_point.c
testcfg.py