summaryrefslogtreecommitdiff
path: root/test/js-native-api/test_object
Commit message (Collapse)AuthorAgeFilesLines
* n-api: support for object freeze/sealShelley Vohr2020-10-072-0/+66
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/35359 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
* n-api: support type-tagging objectsGabriel Schulhof2020-07-312-0/+59
| | | | | | | | | | | | | | | | | | | | `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>
* n-api: define release 6Gabriel Schulhof2020-03-092-3/+0
| | | | | | | | | | | | | | Mark all N-APIs that have been added since version 5 as stable. PR-URL: https://github.com/nodejs/node/pull/32058 Fixes: https://github.com/nodejs/abi-stable-node/issues/393 Co-Authored-By: legendecas <legendecas@gmail.com> Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* test: cover property n-api null casesGabriel Schulhof2020-01-255-0/+465
| | | | | | | | | | | Add test coverage for passing `NULL` to each parameter of `napi.*(propert|element)` and `napi_set_prototype`. In the case of `napi_define_properties` also test setting various initializer fields to `NULL`. PR-URL: https://github.com/nodejs/node/pull/31488 Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* n-api: add napi_get_all_property_nameshimself652020-01-112-1/+36
| | | | | | | | | | | Co-Authored-By: Gabriel Schulhof <gabriel.schulhof@intel.com> PR-URL: https://github.com/nodejs/node/pull/30006 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* n-api: refactor a previous commitOctavian Soldea2019-07-263-159/+79
| | | | | | | | | | | | | | This is a refactoring of https://github.com/nodejs/node/issues/27628 following https://github.com/nodejs/node/pull/28505. This change factors out functions `add_last_status()` and `add_returned_status()` so they may be reused in the tests for passing information about the last error status and/or a returned `napi_status` to JavaScript. PR-URL: https://github.com/nodejs/node/pull/28848 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
* test: pass null params to napi_xxx_property()Octavian Soldea2019-05-132-0/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | For napi_set_property(), each one of the following arguments is checked: napi_env env, napi_value object, napi_value key, napi_value* value. For napi_has_property(), each one of the following arguments is checked: napi_env env, napi_value object, napi_value key, bool* result For napi_get_property, each one of the following arguments is checked: napi_env env, napi_value object, napi_value key, napi_value* result PR-URL: https://github.com/nodejs/node/pull/27628 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* n-api: make napi_get_property_names return stringsAnna Henningsen2019-05-062-0/+43
| | | | | | | | | | | | The documentation says that this method returns an array of strings. Currently, it does not do so for indices. Resolve that by telling V8 explicitly to convert to string. PR-URL: https://github.com/nodejs/node/pull/27524 Fixes: https://github.com/nodejs/node/issues/27496 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
* test: cover napi_get/set/has_named_property()Gabriel Schulhof2019-04-052-0/+111
| | | | | | | | Add test coverage for these N-APIs. PR-URL: https://github.com/nodejs/node/pull/26947 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* test: partition N-API testsGabriel Schulhof2018-12-043-0/+449
Partition test/addons-napi into test/js-native-api and test/node-api to isolate the Node.js-agnostic portion of the N-API tests from the Node.js-specific portion. PR-URL: https://github.com/nodejs/node/pull/24557 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>