11cb0ef41Sopenharmony_ci#include <js_native_api.h>
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci#include "../common.h"
41cb0ef41Sopenharmony_ci#include "test_null.h"
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_cistatic napi_value SetProperty(napi_env env, napi_callback_info info) {
71cb0ef41Sopenharmony_ci  napi_value return_value, object, key;
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
101cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
111cb0ef41Sopenharmony_ci  NODE_API_CALL(env,
121cb0ef41Sopenharmony_ci      napi_create_string_utf8(env, "someString", NAPI_AUTO_LENGTH, &key));
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  add_returned_status(env,
151cb0ef41Sopenharmony_ci                      "envIsNull",
161cb0ef41Sopenharmony_ci                      return_value,
171cb0ef41Sopenharmony_ci                      "Invalid argument",
181cb0ef41Sopenharmony_ci                      napi_invalid_arg,
191cb0ef41Sopenharmony_ci                      napi_set_property(NULL, object, key, object));
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  napi_set_property(env, NULL, key, object);
221cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci  napi_set_property(env, object, NULL, object);
251cb0ef41Sopenharmony_ci  add_last_status(env, "keyIsNull", return_value);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci  napi_set_property(env, object, key, NULL);
281cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci  return return_value;
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_cistatic napi_value GetProperty(napi_env env, napi_callback_info info) {
341cb0ef41Sopenharmony_ci  napi_value return_value, object, key, prop;
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
371cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
381cb0ef41Sopenharmony_ci  NODE_API_CALL(env,
391cb0ef41Sopenharmony_ci      napi_create_string_utf8(env, "someString", NAPI_AUTO_LENGTH, &key));
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci  add_returned_status(env,
421cb0ef41Sopenharmony_ci                      "envIsNull",
431cb0ef41Sopenharmony_ci                      return_value,
441cb0ef41Sopenharmony_ci                      "Invalid argument",
451cb0ef41Sopenharmony_ci                      napi_invalid_arg,
461cb0ef41Sopenharmony_ci                      napi_get_property(NULL, object, key, &prop));
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci  napi_get_property(env, NULL, key, &prop);
491cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci  napi_get_property(env, object, NULL, &prop);
521cb0ef41Sopenharmony_ci  add_last_status(env, "keyIsNull", return_value);
531cb0ef41Sopenharmony_ci
541cb0ef41Sopenharmony_ci  napi_get_property(env, object, key, NULL);
551cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ci  return return_value;
581cb0ef41Sopenharmony_ci}
591cb0ef41Sopenharmony_ci
601cb0ef41Sopenharmony_cistatic napi_value TestBoolValuedPropApi(napi_env env,
611cb0ef41Sopenharmony_ci    napi_status (*api)(napi_env, napi_value, napi_value, bool*)) {
621cb0ef41Sopenharmony_ci  napi_value return_value, object, key;
631cb0ef41Sopenharmony_ci  bool result;
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
661cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
671cb0ef41Sopenharmony_ci  NODE_API_CALL(env,
681cb0ef41Sopenharmony_ci      napi_create_string_utf8(env, "someString", NAPI_AUTO_LENGTH, &key));
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ci  add_returned_status(env,
711cb0ef41Sopenharmony_ci                      "envIsNull",
721cb0ef41Sopenharmony_ci                      return_value,
731cb0ef41Sopenharmony_ci                      "Invalid argument",
741cb0ef41Sopenharmony_ci                      napi_invalid_arg,
751cb0ef41Sopenharmony_ci                      api(NULL, object, key, &result));
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_ci  api(env, NULL, key, &result);
781cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_ci  api(env, object, NULL, &result);
811cb0ef41Sopenharmony_ci  add_last_status(env, "keyIsNull", return_value);
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_ci  api(env, object, key, NULL);
841cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ci  return return_value;
871cb0ef41Sopenharmony_ci}
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_cistatic napi_value HasProperty(napi_env env, napi_callback_info info) {
901cb0ef41Sopenharmony_ci  return TestBoolValuedPropApi(env, napi_has_property);
911cb0ef41Sopenharmony_ci}
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_cistatic napi_value HasOwnProperty(napi_env env, napi_callback_info info) {
941cb0ef41Sopenharmony_ci  return TestBoolValuedPropApi(env, napi_has_own_property);
951cb0ef41Sopenharmony_ci}
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_cistatic napi_value DeleteProperty(napi_env env, napi_callback_info info) {
981cb0ef41Sopenharmony_ci  return TestBoolValuedPropApi(env, napi_delete_property);
991cb0ef41Sopenharmony_ci}
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_cistatic napi_value SetNamedProperty(napi_env env, napi_callback_info info) {
1021cb0ef41Sopenharmony_ci  napi_value return_value, object;
1031cb0ef41Sopenharmony_ci
1041cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
1051cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
1061cb0ef41Sopenharmony_ci
1071cb0ef41Sopenharmony_ci  add_returned_status(env,
1081cb0ef41Sopenharmony_ci                      "envIsNull",
1091cb0ef41Sopenharmony_ci                      return_value,
1101cb0ef41Sopenharmony_ci                      "Invalid argument",
1111cb0ef41Sopenharmony_ci                      napi_invalid_arg,
1121cb0ef41Sopenharmony_ci                      napi_set_named_property(NULL, object, "key", object));
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ci  napi_set_named_property(env, NULL, "key", object);
1151cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
1161cb0ef41Sopenharmony_ci
1171cb0ef41Sopenharmony_ci  napi_set_named_property(env, object, NULL, object);
1181cb0ef41Sopenharmony_ci  add_last_status(env, "keyIsNull", return_value);
1191cb0ef41Sopenharmony_ci
1201cb0ef41Sopenharmony_ci  napi_set_named_property(env, object, "key", NULL);
1211cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
1221cb0ef41Sopenharmony_ci
1231cb0ef41Sopenharmony_ci  return return_value;
1241cb0ef41Sopenharmony_ci}
1251cb0ef41Sopenharmony_ci
1261cb0ef41Sopenharmony_cistatic napi_value GetNamedProperty(napi_env env, napi_callback_info info) {
1271cb0ef41Sopenharmony_ci  napi_value return_value, object, prop;
1281cb0ef41Sopenharmony_ci
1291cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
1301cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
1311cb0ef41Sopenharmony_ci
1321cb0ef41Sopenharmony_ci  add_returned_status(env,
1331cb0ef41Sopenharmony_ci                      "envIsNull",
1341cb0ef41Sopenharmony_ci                      return_value,
1351cb0ef41Sopenharmony_ci                      "Invalid argument",
1361cb0ef41Sopenharmony_ci                      napi_invalid_arg,
1371cb0ef41Sopenharmony_ci                      napi_get_named_property(NULL, object, "key", &prop));
1381cb0ef41Sopenharmony_ci
1391cb0ef41Sopenharmony_ci  napi_get_named_property(env, NULL, "key", &prop);
1401cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
1411cb0ef41Sopenharmony_ci
1421cb0ef41Sopenharmony_ci  napi_get_named_property(env, object, NULL, &prop);
1431cb0ef41Sopenharmony_ci  add_last_status(env, "keyIsNull", return_value);
1441cb0ef41Sopenharmony_ci
1451cb0ef41Sopenharmony_ci  napi_get_named_property(env, object, "key", NULL);
1461cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
1471cb0ef41Sopenharmony_ci
1481cb0ef41Sopenharmony_ci  return return_value;
1491cb0ef41Sopenharmony_ci}
1501cb0ef41Sopenharmony_ci
1511cb0ef41Sopenharmony_cistatic napi_value HasNamedProperty(napi_env env, napi_callback_info info) {
1521cb0ef41Sopenharmony_ci  napi_value return_value, object;
1531cb0ef41Sopenharmony_ci  bool result;
1541cb0ef41Sopenharmony_ci
1551cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
1561cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
1571cb0ef41Sopenharmony_ci
1581cb0ef41Sopenharmony_ci  add_returned_status(env,
1591cb0ef41Sopenharmony_ci                      "envIsNull",
1601cb0ef41Sopenharmony_ci                      return_value,
1611cb0ef41Sopenharmony_ci                      "Invalid argument",
1621cb0ef41Sopenharmony_ci                      napi_invalid_arg,
1631cb0ef41Sopenharmony_ci                      napi_has_named_property(NULL, object, "key", &result));
1641cb0ef41Sopenharmony_ci
1651cb0ef41Sopenharmony_ci  napi_has_named_property(env, NULL, "key", &result);
1661cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
1671cb0ef41Sopenharmony_ci
1681cb0ef41Sopenharmony_ci  napi_has_named_property(env, object, NULL, &result);
1691cb0ef41Sopenharmony_ci  add_last_status(env, "keyIsNull", return_value);
1701cb0ef41Sopenharmony_ci
1711cb0ef41Sopenharmony_ci  napi_has_named_property(env, object, "key", NULL);
1721cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
1731cb0ef41Sopenharmony_ci
1741cb0ef41Sopenharmony_ci  return return_value;
1751cb0ef41Sopenharmony_ci}
1761cb0ef41Sopenharmony_ci
1771cb0ef41Sopenharmony_cistatic napi_value SetElement(napi_env env, napi_callback_info info) {
1781cb0ef41Sopenharmony_ci  napi_value return_value, object;
1791cb0ef41Sopenharmony_ci
1801cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
1811cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
1821cb0ef41Sopenharmony_ci
1831cb0ef41Sopenharmony_ci  add_returned_status(env,
1841cb0ef41Sopenharmony_ci                      "envIsNull",
1851cb0ef41Sopenharmony_ci                      return_value,
1861cb0ef41Sopenharmony_ci                      "Invalid argument",
1871cb0ef41Sopenharmony_ci                      napi_invalid_arg,
1881cb0ef41Sopenharmony_ci                      napi_set_element(NULL, object, 0, object));
1891cb0ef41Sopenharmony_ci
1901cb0ef41Sopenharmony_ci  napi_set_element(env, NULL, 0, object);
1911cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
1921cb0ef41Sopenharmony_ci
1931cb0ef41Sopenharmony_ci  napi_set_property(env, object, 0, NULL);
1941cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
1951cb0ef41Sopenharmony_ci
1961cb0ef41Sopenharmony_ci  return return_value;
1971cb0ef41Sopenharmony_ci}
1981cb0ef41Sopenharmony_ci
1991cb0ef41Sopenharmony_cistatic napi_value GetElement(napi_env env, napi_callback_info info) {
2001cb0ef41Sopenharmony_ci  napi_value return_value, object, prop;
2011cb0ef41Sopenharmony_ci
2021cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
2031cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
2041cb0ef41Sopenharmony_ci
2051cb0ef41Sopenharmony_ci  add_returned_status(env,
2061cb0ef41Sopenharmony_ci                      "envIsNull",
2071cb0ef41Sopenharmony_ci                      return_value,
2081cb0ef41Sopenharmony_ci                      "Invalid argument",
2091cb0ef41Sopenharmony_ci                      napi_invalid_arg,
2101cb0ef41Sopenharmony_ci                      napi_get_element(NULL, object, 0, &prop));
2111cb0ef41Sopenharmony_ci
2121cb0ef41Sopenharmony_ci  napi_get_property(env, NULL, 0, &prop);
2131cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
2141cb0ef41Sopenharmony_ci
2151cb0ef41Sopenharmony_ci  napi_get_property(env, object, 0, NULL);
2161cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
2171cb0ef41Sopenharmony_ci
2181cb0ef41Sopenharmony_ci  return return_value;
2191cb0ef41Sopenharmony_ci}
2201cb0ef41Sopenharmony_ci
2211cb0ef41Sopenharmony_cistatic napi_value TestBoolValuedElementApi(napi_env env,
2221cb0ef41Sopenharmony_ci    napi_status (*api)(napi_env, napi_value, uint32_t, bool*)) {
2231cb0ef41Sopenharmony_ci  napi_value return_value, object;
2241cb0ef41Sopenharmony_ci  bool result;
2251cb0ef41Sopenharmony_ci
2261cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
2271cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
2281cb0ef41Sopenharmony_ci
2291cb0ef41Sopenharmony_ci  add_returned_status(env,
2301cb0ef41Sopenharmony_ci                      "envIsNull",
2311cb0ef41Sopenharmony_ci                      return_value,
2321cb0ef41Sopenharmony_ci                      "Invalid argument",
2331cb0ef41Sopenharmony_ci                      napi_invalid_arg,
2341cb0ef41Sopenharmony_ci                      api(NULL, object, 0, &result));
2351cb0ef41Sopenharmony_ci
2361cb0ef41Sopenharmony_ci  api(env, NULL, 0, &result);
2371cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
2381cb0ef41Sopenharmony_ci
2391cb0ef41Sopenharmony_ci  api(env, object, 0, NULL);
2401cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
2411cb0ef41Sopenharmony_ci
2421cb0ef41Sopenharmony_ci  return return_value;
2431cb0ef41Sopenharmony_ci}
2441cb0ef41Sopenharmony_ci
2451cb0ef41Sopenharmony_cistatic napi_value HasElement(napi_env env, napi_callback_info info) {
2461cb0ef41Sopenharmony_ci  return TestBoolValuedElementApi(env, napi_has_element);
2471cb0ef41Sopenharmony_ci}
2481cb0ef41Sopenharmony_ci
2491cb0ef41Sopenharmony_cistatic napi_value DeleteElement(napi_env env, napi_callback_info info) {
2501cb0ef41Sopenharmony_ci  return TestBoolValuedElementApi(env, napi_delete_element);
2511cb0ef41Sopenharmony_ci}
2521cb0ef41Sopenharmony_ci
2531cb0ef41Sopenharmony_cistatic napi_value DefineProperties(napi_env env, napi_callback_info info) {
2541cb0ef41Sopenharmony_ci  napi_value object, return_value;
2551cb0ef41Sopenharmony_ci
2561cb0ef41Sopenharmony_ci  napi_property_descriptor desc = {
2571cb0ef41Sopenharmony_ci    "prop", NULL, DefineProperties, NULL, NULL, NULL, napi_enumerable, NULL
2581cb0ef41Sopenharmony_ci  };
2591cb0ef41Sopenharmony_ci
2601cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &object));
2611cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
2621cb0ef41Sopenharmony_ci
2631cb0ef41Sopenharmony_ci  add_returned_status(env,
2641cb0ef41Sopenharmony_ci                      "envIsNull",
2651cb0ef41Sopenharmony_ci                      return_value,
2661cb0ef41Sopenharmony_ci                      "Invalid argument",
2671cb0ef41Sopenharmony_ci                      napi_invalid_arg,
2681cb0ef41Sopenharmony_ci                      napi_define_properties(NULL, object, 1, &desc));
2691cb0ef41Sopenharmony_ci
2701cb0ef41Sopenharmony_ci  napi_define_properties(env, NULL, 1, &desc);
2711cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
2721cb0ef41Sopenharmony_ci
2731cb0ef41Sopenharmony_ci  napi_define_properties(env, object, 1, NULL);
2741cb0ef41Sopenharmony_ci  add_last_status(env, "descriptorListIsNull", return_value);
2751cb0ef41Sopenharmony_ci
2761cb0ef41Sopenharmony_ci  desc.utf8name = NULL;
2771cb0ef41Sopenharmony_ci  napi_define_properties(env, object, 1, NULL);
2781cb0ef41Sopenharmony_ci  add_last_status(env, "utf8nameIsNull", return_value);
2791cb0ef41Sopenharmony_ci  desc.utf8name = "prop";
2801cb0ef41Sopenharmony_ci
2811cb0ef41Sopenharmony_ci  desc.method = NULL;
2821cb0ef41Sopenharmony_ci  napi_define_properties(env, object, 1, NULL);
2831cb0ef41Sopenharmony_ci  add_last_status(env, "methodIsNull", return_value);
2841cb0ef41Sopenharmony_ci  desc.method = DefineProperties;
2851cb0ef41Sopenharmony_ci
2861cb0ef41Sopenharmony_ci  return return_value;
2871cb0ef41Sopenharmony_ci}
2881cb0ef41Sopenharmony_ci
2891cb0ef41Sopenharmony_cistatic napi_value GetPropertyNames(napi_env env, napi_callback_info info) {
2901cb0ef41Sopenharmony_ci  napi_value return_value, props;
2911cb0ef41Sopenharmony_ci
2921cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
2931cb0ef41Sopenharmony_ci
2941cb0ef41Sopenharmony_ci  add_returned_status(env,
2951cb0ef41Sopenharmony_ci                      "envIsNull",
2961cb0ef41Sopenharmony_ci                      return_value,
2971cb0ef41Sopenharmony_ci                      "Invalid argument",
2981cb0ef41Sopenharmony_ci                      napi_invalid_arg,
2991cb0ef41Sopenharmony_ci                      napi_get_property_names(NULL, return_value, &props));
3001cb0ef41Sopenharmony_ci
3011cb0ef41Sopenharmony_ci  napi_get_property_names(env, NULL, &props);
3021cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
3031cb0ef41Sopenharmony_ci
3041cb0ef41Sopenharmony_ci  napi_get_property_names(env, return_value, NULL);
3051cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
3061cb0ef41Sopenharmony_ci
3071cb0ef41Sopenharmony_ci  return return_value;
3081cb0ef41Sopenharmony_ci}
3091cb0ef41Sopenharmony_ci
3101cb0ef41Sopenharmony_cistatic napi_value GetAllPropertyNames(napi_env env, napi_callback_info info) {
3111cb0ef41Sopenharmony_ci  napi_value return_value, props;
3121cb0ef41Sopenharmony_ci
3131cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
3141cb0ef41Sopenharmony_ci
3151cb0ef41Sopenharmony_ci  add_returned_status(env,
3161cb0ef41Sopenharmony_ci                      "envIsNull",
3171cb0ef41Sopenharmony_ci                      return_value,
3181cb0ef41Sopenharmony_ci                      "Invalid argument",
3191cb0ef41Sopenharmony_ci                      napi_invalid_arg,
3201cb0ef41Sopenharmony_ci                      napi_get_all_property_names(NULL,
3211cb0ef41Sopenharmony_ci                                                  return_value,
3221cb0ef41Sopenharmony_ci                                                  napi_key_own_only,
3231cb0ef41Sopenharmony_ci                                                  napi_key_writable,
3241cb0ef41Sopenharmony_ci                                                  napi_key_keep_numbers,
3251cb0ef41Sopenharmony_ci                                                  &props));
3261cb0ef41Sopenharmony_ci
3271cb0ef41Sopenharmony_ci  napi_get_all_property_names(env,
3281cb0ef41Sopenharmony_ci                              NULL,
3291cb0ef41Sopenharmony_ci                              napi_key_own_only,
3301cb0ef41Sopenharmony_ci                              napi_key_writable,
3311cb0ef41Sopenharmony_ci                              napi_key_keep_numbers,
3321cb0ef41Sopenharmony_ci                              &props);
3331cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
3341cb0ef41Sopenharmony_ci
3351cb0ef41Sopenharmony_ci  napi_get_all_property_names(env,
3361cb0ef41Sopenharmony_ci                              return_value,
3371cb0ef41Sopenharmony_ci                              napi_key_own_only,
3381cb0ef41Sopenharmony_ci                              napi_key_writable,
3391cb0ef41Sopenharmony_ci                              napi_key_keep_numbers,
3401cb0ef41Sopenharmony_ci                              NULL);
3411cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
3421cb0ef41Sopenharmony_ci
3431cb0ef41Sopenharmony_ci  return return_value;
3441cb0ef41Sopenharmony_ci}
3451cb0ef41Sopenharmony_ci
3461cb0ef41Sopenharmony_cistatic napi_value GetPrototype(napi_env env, napi_callback_info info) {
3471cb0ef41Sopenharmony_ci  napi_value return_value, proto;
3481cb0ef41Sopenharmony_ci
3491cb0ef41Sopenharmony_ci  NODE_API_CALL(env, napi_create_object(env, &return_value));
3501cb0ef41Sopenharmony_ci
3511cb0ef41Sopenharmony_ci  add_returned_status(env,
3521cb0ef41Sopenharmony_ci                      "envIsNull",
3531cb0ef41Sopenharmony_ci                      return_value,
3541cb0ef41Sopenharmony_ci                      "Invalid argument",
3551cb0ef41Sopenharmony_ci                      napi_invalid_arg,
3561cb0ef41Sopenharmony_ci                      napi_get_prototype(NULL, return_value, &proto));
3571cb0ef41Sopenharmony_ci
3581cb0ef41Sopenharmony_ci  napi_get_prototype(env, NULL, &proto);
3591cb0ef41Sopenharmony_ci  add_last_status(env, "objectIsNull", return_value);
3601cb0ef41Sopenharmony_ci
3611cb0ef41Sopenharmony_ci  napi_get_prototype(env, return_value, NULL);
3621cb0ef41Sopenharmony_ci  add_last_status(env, "valueIsNull", return_value);
3631cb0ef41Sopenharmony_ci
3641cb0ef41Sopenharmony_ci  return return_value;
3651cb0ef41Sopenharmony_ci}
3661cb0ef41Sopenharmony_ci
3671cb0ef41Sopenharmony_civoid init_test_null(napi_env env, napi_value exports) {
3681cb0ef41Sopenharmony_ci  napi_value test_null;
3691cb0ef41Sopenharmony_ci
3701cb0ef41Sopenharmony_ci  const napi_property_descriptor test_null_props[] = {
3711cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("setProperty", SetProperty),
3721cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("getProperty", GetProperty),
3731cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("hasProperty", HasProperty),
3741cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("hasOwnProperty", HasOwnProperty),
3751cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("deleteProperty", DeleteProperty),
3761cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("setNamedProperty", SetNamedProperty),
3771cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("getNamedProperty", GetNamedProperty),
3781cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("hasNamedProperty", HasNamedProperty),
3791cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("setElement", SetElement),
3801cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("getElement", GetElement),
3811cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("hasElement", HasElement),
3821cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("deleteElement", DeleteElement),
3831cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("defineProperties", DefineProperties),
3841cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("getPropertyNames", GetPropertyNames),
3851cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("getAllPropertyNames", GetAllPropertyNames),
3861cb0ef41Sopenharmony_ci    DECLARE_NODE_API_PROPERTY("getPrototype", GetPrototype),
3871cb0ef41Sopenharmony_ci  };
3881cb0ef41Sopenharmony_ci
3891cb0ef41Sopenharmony_ci  NODE_API_CALL_RETURN_VOID(env, napi_create_object(env, &test_null));
3901cb0ef41Sopenharmony_ci  NODE_API_CALL_RETURN_VOID(env, napi_define_properties(
3911cb0ef41Sopenharmony_ci      env, test_null, sizeof(test_null_props) / sizeof(*test_null_props),
3921cb0ef41Sopenharmony_ci      test_null_props));
3931cb0ef41Sopenharmony_ci
3941cb0ef41Sopenharmony_ci  const napi_property_descriptor test_null_set = {
3951cb0ef41Sopenharmony_ci    "testNull", NULL, NULL, NULL, NULL, test_null, napi_enumerable, NULL
3961cb0ef41Sopenharmony_ci  };
3971cb0ef41Sopenharmony_ci
3981cb0ef41Sopenharmony_ci  NODE_API_CALL_RETURN_VOID(env,
3991cb0ef41Sopenharmony_ci      napi_define_properties(env, exports, 1, &test_null_set));
4001cb0ef41Sopenharmony_ci}
401