From 1c6f334f62089450ab6df56c76c1dd7cc2468654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20B=C3=A1tyai?= Date: Mon, 25 Nov 2019 11:48:33 +0100 Subject: [PATCH] Fix class name check for WeakMap and WeakSet prototype (#3358) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3357. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu --- jerry-core/ecma/operations/ecma-objects.c | 6 ++++++ tests/jerry/es2015/weakmap.js | 2 ++ tests/jerry/es2015/weakset.js | 2 ++ 3 files changed, 10 insertions(+) diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index 043fdccd4..857badb59 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -2357,6 +2357,12 @@ ecma_object_check_class_name_is_object (ecma_object_t *obj_p) /**< object */ || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_SET_ITERATOR_PROTOTYPE) #endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */ #endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */ +#if ENABLED (JERRY_ES2015_BUILTIN_WEAKMAP) + || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_WEAKMAP_PROTOTYPE) +#endif /* ENABLED (JERRY_ES2015_BUILTIN_WEAKMAP) */ +#if ENABLED (JERRY_ES2015_BUILTIN_WEAKSET) + || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_WEAKSET_PROTOTYPE) +#endif /* ENABLED (JERRY_ES2015_BUILTIN_WEAKSET) */ #if ENABLED (JERRY_ES2015) || ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_SYMBOL_PROTOTYPE) #endif /* ENABLED (JERRY_ES2015) */ diff --git a/tests/jerry/es2015/weakmap.js b/tests/jerry/es2015/weakmap.js index c4ecd73c3..ff4e7286a 100644 --- a/tests/jerry/es2015/weakmap.js +++ b/tests/jerry/es2015/weakmap.js @@ -135,6 +135,8 @@ try { assert (e instanceof TypeError); } +assert (WeakMap.prototype.toString() === "[object WeakMap]"); + WeakMap.prototype.set = function () { throw "abrupt set" }; try { diff --git a/tests/jerry/es2015/weakset.js b/tests/jerry/es2015/weakset.js index f01a8634b..adb9bacab 100644 --- a/tests/jerry/es2015/weakset.js +++ b/tests/jerry/es2015/weakset.js @@ -119,6 +119,8 @@ try { assert (e instanceof TypeError); } +assert (WeakSet.prototype.toString() === "[object WeakSet]"); + WeakSet.prototype.add = function () { throw "abrupt add" }; try {