[JSC] Enable Array#groupBy and Array#groupByToMap
https://bugs.webkit.org/show_bug.cgi?id=235549

Reviewed by Ross Kirsling.

JSTests:

* stress/unscopables.js:

Source/JavaScriptCore:

* runtime/OptionsList.h:

LayoutTests:

* inspector/model/remote-object-get-properties-expected.txt:
* js/Object-getOwnPropertyNames-expected.txt:
* js/array-unscopables-properties-expected.txt:
* js/script-tests/Object-getOwnPropertyNames.js:
* js/script-tests/array-unscopables-properties.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288538 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog
index 2aca087..d1eaf11 100644
--- a/JSTests/ChangeLog
+++ b/JSTests/ChangeLog
@@ -1,5 +1,14 @@
 2022-01-24  Yusuke Suzuki  <ysuzuki@apple.com>
 
+        [JSC] Enable Array#groupBy and Array#groupByToMap
+        https://bugs.webkit.org/show_bug.cgi?id=235549
+
+        Reviewed by Ross Kirsling.
+
+        * stress/unscopables.js:
+
+2022-01-24  Yusuke Suzuki  <ysuzuki@apple.com>
+
         [JSC] Support import assertion syntax
         https://bugs.webkit.org/show_bug.cgi?id=235312
 
diff --git a/JSTests/stress/unscopables.js b/JSTests/stress/unscopables.js
index 88490db..18f6bf9 100644
--- a/JSTests/stress/unscopables.js
+++ b/JSTests/stress/unscopables.js
@@ -11,7 +11,7 @@
 
     test(typeof unscopables, "object");
     test(unscopables.__proto__, undefined);
-    test(String(Object.keys(unscopables).sort()), "at,copyWithin,entries,fill,find,findIndex,findLast,findLastIndex,flat,flatMap,includes,keys,values");
+    test(String(Object.keys(unscopables).sort()), "at,copyWithin,entries,fill,find,findIndex,findLast,findLastIndex,flat,flatMap,groupBy,groupByToMap,includes,keys,values");
 }());
 
 (function () {
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a375555..eb2ad1b 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2022-01-24  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        [JSC] Enable Array#groupBy and Array#groupByToMap
+        https://bugs.webkit.org/show_bug.cgi?id=235549
+
+        Reviewed by Ross Kirsling.
+
+        * inspector/model/remote-object-get-properties-expected.txt:
+        * js/Object-getOwnPropertyNames-expected.txt:
+        * js/array-unscopables-properties-expected.txt:
+        * js/script-tests/Object-getOwnPropertyNames.js:
+        * js/script-tests/array-unscopables-properties.js:
+
 2022-01-24  Patrick Angle  <pangle@apple.com>
 
         Web Inspector: [Flexbox] Add instrumentation/protocol bits for flex layout containers
diff --git a/LayoutTests/inspector/model/remote-object-get-properties-expected.txt b/LayoutTests/inspector/model/remote-object-get-properties-expected.txt
index 110cf3e..ad795d5 100644
--- a/LayoutTests/inspector/model/remote-object-get-properties-expected.txt
+++ b/LayoutTests/inspector/model/remote-object-get-properties-expected.txt
@@ -74,6 +74,8 @@
     indexOf
     lastIndexOf
     filter
+    groupBy
+    groupByToMap
     flat
     flatMap
     reduce
@@ -130,6 +132,8 @@
     indexOf
     lastIndexOf
     filter
+    groupBy
+    groupByToMap
     flat
     flatMap
     reduce
@@ -171,6 +175,8 @@
     indexOf
     lastIndexOf
     filter
+    groupBy
+    groupByToMap
     flat
     flatMap
     reduce
@@ -212,6 +218,8 @@
     indexOf
     lastIndexOf
     filter
+    groupBy
+    groupByToMap
     flat
     flatMap
     reduce
diff --git a/LayoutTests/js/Object-getOwnPropertyNames-expected.txt b/LayoutTests/js/Object-getOwnPropertyNames-expected.txt
index 07b08f9..aa01bb0 100644
--- a/LayoutTests/js/Object-getOwnPropertyNames-expected.txt
+++ b/LayoutTests/js/Object-getOwnPropertyNames-expected.txt
@@ -47,7 +47,7 @@
 PASS getSortedOwnPropertyNames(Function) is ['length', 'name', 'prototype']
 PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']
 PASS getSortedOwnPropertyNames(Array) is ['from', 'isArray', 'length', 'name', 'of', 'prototype']
-PASS getSortedOwnPropertyNames(Array.prototype) is ['at', 'concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'findLast', 'findLastIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
+PASS getSortedOwnPropertyNames(Array.prototype) is ['at', 'concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'findLast', 'findLastIndex', 'flat', 'flatMap', 'forEach', 'groupBy', 'groupByToMap', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
 PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']
 PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'at', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'matchAll', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'replaceAll', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimEnd', 'trimLeft', 'trimRight', 'trimStart', 'valueOf']
 PASS getSortedOwnPropertyNames(Boolean) is ['length', 'name', 'prototype']
diff --git a/LayoutTests/js/array-unscopables-properties-expected.txt b/LayoutTests/js/array-unscopables-properties-expected.txt
index fd51b88..1037d8b 100644
--- a/LayoutTests/js/array-unscopables-properties-expected.txt
+++ b/LayoutTests/js/array-unscopables-properties-expected.txt
@@ -50,6 +50,14 @@
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "flatMap").writable is true
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "flatMap").enumerable is true
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "flatMap").configurable is true
+PASS Array.prototype[Symbol.unscopables]["groupBy"] is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "groupBy").writable is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "groupBy").enumerable is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "groupBy").configurable is true
+PASS Array.prototype[Symbol.unscopables]["groupByToMap"] is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "groupByToMap").writable is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "groupByToMap").enumerable is true
+PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "groupByToMap").configurable is true
 PASS Array.prototype[Symbol.unscopables]["includes"] is true
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "includes").writable is true
 PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "includes").enumerable is true
diff --git a/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js b/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
index b7a73b3..2610c45 100644
--- a/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
+++ b/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
@@ -56,7 +56,7 @@
     "Function": "['length', 'name', 'prototype']",
     "Function.prototype": "['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']",
     "Array": "['from', 'isArray', 'length', 'name', 'of', 'prototype']",
-    "Array.prototype": "['at', 'concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'findLast', 'findLastIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",
+    "Array.prototype": "['at', 'concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'findLast', 'findLastIndex', 'flat', 'flatMap', 'forEach', 'groupBy', 'groupByToMap', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",
     "String": "['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']",
     "String.prototype": "['anchor', 'at', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'matchAll', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'replaceAll', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimEnd', 'trimLeft', 'trimRight', 'trimStart', 'valueOf']",
     "Boolean": "['length', 'name', 'prototype']",
diff --git a/LayoutTests/js/script-tests/array-unscopables-properties.js b/LayoutTests/js/script-tests/array-unscopables-properties.js
index 2c6dc3e..9ce541b 100644
--- a/LayoutTests/js/script-tests/array-unscopables-properties.js
+++ b/LayoutTests/js/script-tests/array-unscopables-properties.js
@@ -17,6 +17,8 @@
     "findLastIndex",
     "flat",
     "flatMap",
+    "groupBy",
+    "groupByToMap",
     "includes",
     "keys",
     "values"
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 39be9cd..f2b73e3 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,12 @@
+2022-01-24  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        [JSC] Enable Array#groupBy and Array#groupByToMap
+        https://bugs.webkit.org/show_bug.cgi?id=235549
+
+        Reviewed by Ross Kirsling.
+
+        * runtime/OptionsList.h:
+
 2022-01-24  Cameron McCormack  <heycam@apple.com>
 
         Remove VM::stringCache
diff --git a/Source/JavaScriptCore/runtime/OptionsList.h b/Source/JavaScriptCore/runtime/OptionsList.h
index c88af85..3bfd421 100644
--- a/Source/JavaScriptCore/runtime/OptionsList.h
+++ b/Source/JavaScriptCore/runtime/OptionsList.h
@@ -538,7 +538,7 @@
     /* Feature Flags */\
     \
     v(Bool, useArrayFindLastMethod, true, Normal, "Expose the findLast() and findLastIndex() methods on Array and %TypedArray%.") \
-    v(Bool, useArrayGroupByMethod, false, Normal, "Expose the groupBy() and groupByToMap() methods on Array.") \
+    v(Bool, useArrayGroupByMethod, true, Normal, "Expose the groupBy() and groupByToMap() methods on Array.") \
     v(Bool, useAtMethod, true, Normal, "Expose the at() method on Array, %TypedArray%, and String.") \
     v(Bool, useHasOwn, true, Normal, "Expose the Object.hasOwn method") \
     v(Bool, useImportAssertion, false, Normal, "Enable import assertion.") \