From 2ac3c08c14d4ab6f0f39cbf204a6e1d1c7420ed0 Mon Sep 17 00:00:00 2001 From: kisbg Date: Wed, 6 Jan 2021 08:44:48 +0100 Subject: [PATCH] Add proxy check in ecma_op_object_put_with_receiver (#4411) JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu --- jerry-core/ecma/operations/ecma-objects.c | 9 +++++++ tests/jerry/es.next/proxy-extension.js | 32 +++++++++++++++++++++++ tests/test262-esnext-excludelist.xml | 1 - 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/jerry/es.next/proxy-extension.js diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index 327776915..77b93348b 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -1523,6 +1523,15 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ } } +#if ENABLED (JERRY_BUILTIN_PROXY) + if (create_new_property + && ecma_is_value_object (receiver) + && ECMA_OBJECT_IS_PROXY (ecma_get_object_from_value (receiver))) + { + return ecma_op_object_put_apply_receiver (receiver, property_name_p, value, is_throw); + } +#endif /* ENABLED (JERRY_BUILTIN_PROXY) */ + if (create_new_property && ecma_op_ordinary_object_is_extensible (object_p)) { diff --git a/tests/jerry/es.next/proxy-extension.js b/tests/jerry/es.next/proxy-extension.js new file mode 100644 index 000000000..0478a30c4 --- /dev/null +++ b/tests/jerry/es.next/proxy-extension.js @@ -0,0 +1,32 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +var target = Object.create(null); +var p = new Proxy(target, { + defineProperty: function() { + return true; + } +}); + +Object.preventExtensions(p); + +try { + p.prop = null; + assert(false) +} +catch(e) +{ + assert(e instanceof TypeError) +} diff --git a/tests/test262-esnext-excludelist.xml b/tests/test262-esnext-excludelist.xml index 79e486dc0..8a7972bed 100644 --- a/tests/test262-esnext-excludelist.xml +++ b/tests/test262-esnext-excludelist.xml @@ -9655,7 +9655,6 @@ -