From 866d7f8d8e4601618d4a94fb8fa7b4219c69bcf6 Mon Sep 17 00:00:00 2001 From: Leo Balter <leonardo.balter@gmail.com> Date: Mon, 13 Mar 2017 13:48:33 -0400 Subject: [PATCH] Improve isEnumerable check with a for-in loop for string names (#880) Ref https://github.com/tc39/test262/pull/879#discussion_r104128520 --- harness/propertyHelper.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/harness/propertyHelper.js b/harness/propertyHelper.js index 8ce65ba86c..5bb1ed4157 100644 --- a/harness/propertyHelper.js +++ b/harness/propertyHelper.js @@ -11,7 +11,22 @@ function isConfigurable(obj, name) { } function isEnumerable(obj, name) { - return Object.prototype.hasOwnProperty.call(obj, name) && + var stringCheck; + + if (typeof name === "string") { + for (var x in obj) { + if (x === name) { + stringCheck = true; + break; + } + } + } else { + // skip it if name is not string, works for Symbol names. + stringCheck = true; + } + + return stringCheck && + Object.prototype.hasOwnProperty.call(obj, name) && Object.prototype.propertyIsEnumerable.call(obj, name); } -- GitLab