[njs] Fixed NativeError.prototype.message properties.

Dmitry Volyntsev xeioex at nginx.com
Thu Oct 24 13:24:28 UTC 2019


details:   https://hg.nginx.org/njs/rev/d849bf348b0d
branches:  
changeset: 1201:d849bf348b0d
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu Oct 24 16:17:17 2019 +0300
description:
Fixed NativeError.prototype.message properties.

diffstat:

 src/njs_error.c          |  56 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/test/njs_unit_test.c |   4 ++-
 test/njs_expect_test.exp |   3 ++
 3 files changed, 62 insertions(+), 1 deletions(-)

diffs (139 lines):

diff -r 84cb3fa5d1cc -r d849bf348b0d src/njs_error.c
--- a/src/njs_error.c	Thu Oct 24 16:17:16 2019 +0300
+++ b/src/njs_error.c	Thu Oct 24 16:17:17 2019 +0300
@@ -779,6 +779,14 @@ static const njs_object_prop_t  njs_eval
     },
 
     {
+        .type = NJS_PROPERTY,
+        .name = njs_string("message"),
+        .value = njs_string(""),
+        .writable = 1,
+        .configurable = 1,
+    },
+
+    {
         .type = NJS_PROPERTY_HANDLER,
         .name = njs_string("constructor"),
         .value = njs_prop_handler(njs_object_prototype_create_constructor),
@@ -827,6 +835,14 @@ static const njs_object_prop_t  njs_inte
 
     {
         .type = NJS_PROPERTY,
+        .name = njs_string("message"),
+        .value = njs_string(""),
+        .writable = 1,
+        .configurable = 1,
+    },
+
+    {
+        .type = NJS_PROPERTY,
         .name = njs_string("toString"),
         .value = njs_native_function(njs_internal_error_prototype_to_string, 0),
         .writable = 1,
@@ -853,6 +869,14 @@ static const njs_object_prop_t  njs_rang
     },
 
     {
+        .type = NJS_PROPERTY,
+        .name = njs_string("message"),
+        .value = njs_string(""),
+        .writable = 1,
+        .configurable = 1,
+    },
+
+    {
         .type = NJS_PROPERTY_HANDLER,
         .name = njs_string("constructor"),
         .value = njs_prop_handler(njs_object_prototype_create_constructor),
@@ -880,6 +904,14 @@ static const njs_object_prop_t  njs_refe
     },
 
     {
+        .type = NJS_PROPERTY,
+        .name = njs_string("message"),
+        .value = njs_string(""),
+        .writable = 1,
+        .configurable = 1,
+    },
+
+    {
         .type = NJS_PROPERTY_HANDLER,
         .name = njs_string("constructor"),
         .value = njs_prop_handler(njs_object_prototype_create_constructor),
@@ -907,6 +939,14 @@ static const njs_object_prop_t  njs_synt
     },
 
     {
+        .type = NJS_PROPERTY,
+        .name = njs_string("message"),
+        .value = njs_string(""),
+        .writable = 1,
+        .configurable = 1,
+    },
+
+    {
         .type = NJS_PROPERTY_HANDLER,
         .name = njs_string("constructor"),
         .value = njs_prop_handler(njs_object_prototype_create_constructor),
@@ -934,6 +974,14 @@ static const njs_object_prop_t  njs_type
     },
 
     {
+        .type = NJS_PROPERTY,
+        .name = njs_string("message"),
+        .value = njs_string(""),
+        .writable = 1,
+        .configurable = 1,
+    },
+
+    {
         .type = NJS_PROPERTY_HANDLER,
         .name = njs_string("constructor"),
         .value = njs_prop_handler(njs_object_prototype_create_constructor),
@@ -962,6 +1010,14 @@ static const njs_object_prop_t  njs_uri_
 
     {
         .type = NJS_PROPERTY,
+        .name = njs_string("message"),
+        .value = njs_string(""),
+        .writable = 1,
+        .configurable = 1,
+    },
+
+    {
+        .type = NJS_PROPERTY,
         .name = njs_string("name"),
         .value = njs_string("URIError"),
         .writable = 1,
diff -r 84cb3fa5d1cc -r d849bf348b0d src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c	Thu Oct 24 16:17:16 2019 +0300
+++ b/src/test/njs_unit_test.c	Thu Oct 24 16:17:17 2019 +0300
@@ -8710,11 +8710,13 @@ static njs_unit_test_t  njs_test[] =
         "   var name2 = (inst = e('e'), inst.name = 'E', inst.toString() === 'E: e');"
         "   var name3 = (inst = e('e'), inst.name = '', inst.toString() === 'e');"
         "   var name4 = e().toString() === `${e.prototype.name}`;"
+        "   var name_prop = Object.getOwnPropertyDescriptor(e.prototype, 'message');"
+        "   name_prop = name_prop.writable && !name_prop.enumerable && name_prop.configurable;"
         "   var own_proto_ctor = e.prototype.hasOwnProperty('constructor');"
         ""
         "   return proto && proto2 && iproto && iproto2 "
         "          && tpof && ctor && msg && name && name2 && name3 && name4 "
-        "          && own_proto_ctor;"
+        "          && name_prop && own_proto_ctor;"
         "};"
         "["
         "  EvalError,"
diff -r 84cb3fa5d1cc -r d849bf348b0d test/njs_expect_test.exp
--- a/test/njs_expect_test.exp	Thu Oct 24 16:17:16 2019 +0300
+++ b/test/njs_expect_test.exp	Thu Oct 24 16:17:17 2019 +0300
@@ -766,6 +766,9 @@ njs_test {
      "Error: loading exception\r\n    at module \\(loading_exception.js:1\\)"}
     {"import lib3 from 'lib1.js'\r\n"
      "undefined\r\n"}
+} "-p test/module/"
+
+njs_test {
     {"import m from 'export_name.js'\r\n"
      "undefined\r\n"}
     {"m.prod(3,4)\r\n"


More information about the nginx-devel mailing list