node/test/js-native-api
Gabriel Schulhof cc7ec889e8 n-api: support type-tagging objects
`napi_instanceof()` is insufficient for reliably establishing the data
type to which a pointer stored with `napi_wrap()` or
`napi_create_external()` inside a JavaScript object points. Thus, we
need a way to "mark" an object with a value that, when later retrieved,
can unambiguously tell us whether it is safe to cast the pointer stored
inside it to a certain structure.

Such a check must survive loading/unloading/multiple instances of an
addon, so we use UUIDs chosen *a priori*.

Fixes: https://github.com/nodejs/node/issues/28164
Co-authored-by: Anna Henningsen <github@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/28237
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
2020-07-31 18:30:30 -07:00
..
2_function_arguments test: partition N-API tests 2018-12-04 13:58:17 -08:00
3_callbacks test: partition N-API tests 2018-12-04 13:58:17 -08:00
4_object_factory test: partition N-API tests 2018-12-04 13:58:17 -08:00
5_function_factory test: partition N-API tests 2018-12-04 13:58:17 -08:00
6_object_wrap n-api: define ECMAScript-compliant accessors on napi_define_class 2019-06-17 12:07:08 +02:00
7_factory_wrap n-api: run all finalizers via SetImmediate() 2020-07-23 23:28:09 -07:00
8_passing_wrapped n-api: run all finalizers via SetImmediate() 2020-07-23 23:28:09 -07:00
test_array benchmark,doc,lib,test: capitalize comments 2019-02-28 18:31:10 +01:00
test_bigint n-api: simplify bigint-from-word creation 2020-07-31 13:45:25 -07:00
test_constructor n-api: refactor a previous commit 2019-07-26 15:09:04 -07:00
test_conversions test: add n-api null checks for conversions 2020-07-08 10:32:16 -07:00
test_dataview test: partition N-API tests 2018-12-04 13:58:17 -08:00
test_date n-api: mark version 5 N-APIs as stable 2019-09-05 09:16:54 -07:00
test_error test: refactor common.expectsError 2019-12-31 15:54:20 +01:00
test_exception n-api: run all finalizers via SetImmediate() 2020-07-23 23:28:09 -07:00
test_function n-api: refactoring napi_create_function testing 2019-07-31 23:19:41 -07:00
test_general n-api: run all finalizers via SetImmediate() 2020-07-23 23:28:09 -07:00
test_handle_scope benchmark,doc,lib,test: capitalize comments 2019-03-10 00:44:40 +01:00
test_instance_data module: deprecate module.parent 2020-05-24 03:38:39 +02:00
test_new_target test: partition N-API tests 2018-12-04 13:58:17 -08:00
test_number n-api: add uint32 test for -1 2020-05-06 23:52:05 -07:00
test_object n-api: support type-tagging objects 2020-07-31 18:30:30 -07:00
test_promise test: partition N-API tests 2018-12-04 13:58:17 -08:00
test_properties n-api: define ECMAScript-compliant accessors on napi_define_properties 2019-06-17 12:06:06 +02:00
test_reference n-api: run all finalizers via SetImmediate() 2020-07-23 23:28:09 -07:00
test_string napi: fix memory corruption vulnerability 2020-06-02 20:35:51 +02:00
test_symbol benchmark,doc,lib: capitalize more comments 2019-03-27 17:20:06 +01:00
test_typedarray src: remove calls to deprecated ArrayBuffer methods 2020-03-21 12:00:57 +01:00
.gitignore test: partition N-API tests 2018-12-04 13:58:17 -08:00
common.c n-api: refactor a previous commit 2019-07-26 15:09:04 -07:00
common.h n-api: refactor a previous commit 2019-07-26 15:09:04 -07:00
entry_point.c test: partition N-API tests 2018-12-04 13:58:17 -08:00
testcfg.py test: partition N-API tests 2018-12-04 13:58:17 -08:00