[njs] Fixed TypeError message in ValidateAndApplyPropertyDescriptor().

Dmitry Volyntsev xeioex at nginx.com
Wed Nov 27 16:47:53 UTC 2019


details:   https://hg.nginx.org/njs/rev/24b5c0103726
branches:  
changeset: 1267:24b5c0103726
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Nov 27 18:28:13 2019 +0300
description:
Fixed TypeError message in ValidateAndApplyPropertyDescriptor().

For Symbol key when object is not extensible.

diffstat:

 src/njs_object_prop.c    |  1 +
 src/njs_value.c          |  1 +
 src/test/njs_unit_test.c |  7 +++++++
 3 files changed, 9 insertions(+), 0 deletions(-)

diffs (46 lines):

diff -r 4b2b845c3bad -r 24b5c0103726 src/njs_object_prop.c
--- a/src/njs_object_prop.c	Wed Nov 27 16:51:29 2019 +0300
+++ b/src/njs_object_prop.c	Wed Nov 27 18:28:13 2019 +0300
@@ -158,6 +158,7 @@ njs_object_prop_define(njs_vm_t *vm, njs
     if (njs_fast_path(ret == NJS_DECLINED)) {
 
         if (!njs_object(object)->extensible) {
+            njs_key_string_get(vm, &pq.key,  &pq.lhq.key);
             njs_type_error(vm, "Cannot add property \"%V\", "
                            "object is not extensible", &pq.lhq.key);
             return NJS_ERROR;
diff -r 4b2b845c3bad -r 24b5c0103726 src/njs_value.c
--- a/src/njs_value.c	Wed Nov 27 16:51:29 2019 +0300
+++ b/src/njs_value.c	Wed Nov 27 18:28:13 2019 +0300
@@ -1125,6 +1125,7 @@ njs_value_property_set(njs_vm_t *vm, njs
     }
 
     if (njs_slow_path(!njs_object(value)->extensible)) {
+        njs_key_string_get(vm, &pq.key,  &pq.lhq.key);
         njs_type_error(vm, "Cannot add property \"%V\", "
                        "object is not extensible", &pq.lhq.key);
         return NJS_ERROR;
diff -r 4b2b845c3bad -r 24b5c0103726 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c	Wed Nov 27 16:51:29 2019 +0300
+++ b/src/test/njs_unit_test.c	Wed Nov 27 18:28:13 2019 +0300
@@ -11962,6 +11962,10 @@ static njs_unit_test_t  njs_test[] =
                  "Object.defineProperty(o, 'b', {value:1})"),
       njs_str("TypeError: Cannot add property \"b\", object is not extensible") },
 
+    { njs_str("var o = Object.preventExtensions({});"
+                 "Object.defineProperty(o, Symbol.unscopables, {})"),
+      njs_str("TypeError: Cannot add property \"Symbol(Symbol.unscopables)\", object is not extensible") },
+
     { njs_str("var o = Object.preventExtensions({a:1});"
                  "Object.defineProperties(o, {b:{value:1}})"),
       njs_str("TypeError: Cannot add property \"b\", object is not extensible") },
@@ -11975,6 +11979,9 @@ static njs_unit_test_t  njs_test[] =
     { njs_str("var o = Object.preventExtensions({a:1}); o.b = 1; o.b"),
       njs_str("TypeError: Cannot add property \"b\", object is not extensible") },
 
+    { njs_str("var o = Object.preventExtensions({a:1}); o[Symbol.unscopables] = 1"),
+      njs_str("TypeError: Cannot add property \"Symbol(Symbol.unscopables)\", object is not extensible") },
+
     { njs_str("Object.preventExtensions()"),
       njs_str("undefined") },
 


More information about the nginx-devel mailing list