Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 82da738

Browse files
[JSC] Rename item() to at() and move it behind a flag
https://bugs.webkit.org/show_bug.cgi?id=217942 Reviewed by Yusuke Suzuki. JSTests: * stress/at-method.js: Renamed from JSTests/stress/item-method.js. * test262/config.yaml: Add skips until the feature is renamed. Source/JavaScriptCore: {Array, %TypedArray%}.prototype.item is official web-incompatible, but it is expected to be renamed to `at` instead of being scrapped entirely: tc39/proposal-relative-indexing-method#34 This patch performs the renaming, but does so behind a runtime flag since this has yet to achieve consensus. * builtins/ArrayPrototype.js: (at): (item): Deleted. * builtins/TypedArrayPrototype.js: (at): (item): Deleted. * runtime/ArrayPrototype.cpp: (JSC::ArrayPrototype::finishCreation): * runtime/JSTypedArrayViewPrototype.cpp: (JSC::JSTypedArrayViewPrototype::finishCreation): * runtime/OptionsList.h: LayoutTests: * inspector/model/remote-object-get-properties-expected.txt: * js/array-unscopables-properties-expected.txt: * js/Object-getOwnPropertyNames-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@268760 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 5229a9c commit 82da738

16 files changed

+88
-35
lines changed

JSTests/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2020-10-20 Ross Kirsling <[email protected]>
2+
3+
[JSC] Rename item() to at() and move it behind a flag
4+
https://bugs.webkit.org/show_bug.cgi?id=217942
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
* stress/at-method.js: Renamed from JSTests/stress/item-method.js.
9+
* test262/config.yaml: Add skips until the feature is renamed.
10+
111
2020-10-19 Alexey Shvayka <[email protected]>
212

313
[WebIDL] %Interface%.prototype.constructor should be defined on [[Set]] receiver
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ requireOptions("--useAtMethod=1")
2+
13
function shouldBe(actual, expected) {
24
if (actual !== expected)
35
throw new Error(`expected ${expected} but got ${actual}`);
@@ -15,35 +17,35 @@ function shouldThrowTypeError(func) {
1517
throw new Error('Expected TypeError!');
1618
}
1719

18-
shouldBe(Array.prototype.item.length, 1);
19-
shouldThrowTypeError(() => Array.prototype.item.call(undefined));
20-
shouldThrowTypeError(() => Array.prototype.item.call(null));
20+
shouldBe(Array.prototype.at.length, 1);
21+
shouldThrowTypeError(() => Array.prototype.at.call(undefined));
22+
shouldThrowTypeError(() => Array.prototype.at.call(null));
2123

2224
const array = [42, 'b', true];
2325
// intentionally go one too far to ensure that we get undefined instead of wrapping
2426
for (let i = 0; i <= array.length; i++) {
25-
shouldBe(array.item(i), array[i]);
26-
shouldBe(array.item(-i - 1), array[array.length - i - 1]);
27+
shouldBe(array.at(i), array[i]);
28+
shouldBe(array.at(-i - 1), array[array.length - i - 1]);
2729
}
28-
shouldBe(array.item(), array[0]);
29-
shouldBe(array.item(null), array[0]);
30-
shouldBe(array.item({ valueOf: () => -1 }), array[array.length - 1]);
30+
shouldBe(array.at(), array[0]);
31+
shouldBe(array.at(null), array[0]);
32+
shouldBe(array.at({ valueOf: () => -1 }), array[array.length - 1]);
3133

3234
const weirdArrayLike = { length: 1, get '0'() { return 3; }, get '1'() { throw 'oops'; } };
33-
shouldBe(Array.prototype.item.call(weirdArrayLike, 0), 3);
34-
shouldBe(Array.prototype.item.call(weirdArrayLike, 1), undefined);
35+
shouldBe(Array.prototype.at.call(weirdArrayLike, 0), 3);
36+
shouldBe(Array.prototype.at.call(weirdArrayLike, 1), undefined);
3537

3638
for (const TA of [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]) {
37-
shouldBe(TA.prototype.item.length, 1);
38-
shouldThrowTypeError(() => TA.prototype.item.call([]));
39+
shouldBe(TA.prototype.at.length, 1);
40+
shouldThrowTypeError(() => TA.prototype.at.call([]));
3941

4042
const ta = [1, 2, 3];
4143
// intentionally go one too far to ensure that we get undefined instead of wrapping
4244
for (let i = 0; i <= ta.length; i++) {
43-
shouldBe(ta.item(i), ta[i]);
44-
shouldBe(ta.item(-i - 1), ta[ta.length - i - 1]);
45+
shouldBe(ta.at(i), ta[i]);
46+
shouldBe(ta.at(-i - 1), ta[ta.length - i - 1]);
4547
}
46-
shouldBe(ta.item(), ta[0]);
47-
shouldBe(ta.item(null), ta[0]);
48-
shouldBe(ta.item({ valueOf: () => -1 }), ta[ta.length - 1]);
48+
shouldBe(ta.at(), ta[0]);
49+
shouldBe(ta.at(null), ta[0]);
50+
shouldBe(ta.at({ valueOf: () => -1 }), ta[ta.length - 1]);
4951
}

JSTests/stress/unscopables.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ requireOptions("--useAtMethod=1")
2+
13
function test(actual, expected) {
24
if (actual !== expected)
35
throw new Error('bad value: ' + actual);
@@ -9,7 +11,7 @@ function test(actual, expected) {
911

1012
test(typeof unscopables, "object");
1113
test(unscopables.__proto__, undefined);
12-
test(String(Object.keys(unscopables).sort()), "copyWithin,entries,fill,find,findIndex,flat,flatMap,includes,item,keys,values");
14+
test(String(Object.keys(unscopables).sort()), "at,copyWithin,entries,fill,find,findIndex,flat,flatMap,includes,keys,values");
1315
}());
1416

1517
(function () {

JSTests/test262/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ skip:
2727
- top-level-await
2828
- Intl.ListFormat
2929

30+
# remove once it's been renamed in test262
31+
- Array.prototype.item
32+
- TypedArray.prototype.item
33+
3034
# remove once it's no longer in test262
3135
- String.prototype.item
3236
paths:

LayoutTests/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2020-10-20 Ross Kirsling <[email protected]>
2+
3+
[JSC] Rename item() to at() and move it behind a flag
4+
https://bugs.webkit.org/show_bug.cgi?id=217942
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
* inspector/model/remote-object-get-properties-expected.txt:
9+
* js/array-unscopables-properties-expected.txt:
10+
* js/Object-getOwnPropertyNames-expected.txt:
11+
* js/script-tests/Object-getOwnPropertyNames.js:
12+
* js/script-tests/array-unscopables-properties.js:
13+
114
2020-10-20 Diego Pino Garcia <[email protected]>
215

316
[GLIB][GTK] Unreviewed test gardening. Gardened several flaky crash tests.

LayoutTests/inspector/model/remote-object-get-properties-expected.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ ALL PROPERTIES:
8585
findIndex
8686
includes
8787
copyWithin
88-
item
8988
constructor
9089
Symbol(Symbol.iterator)
9190
Symbol(Symbol.unscopables)
@@ -139,7 +138,6 @@ OWN PROPERTIES:
139138
findIndex
140139
includes
141140
copyWithin
142-
item
143141
constructor
144142
Symbol(Symbol.iterator)
145143
Symbol(Symbol.unscopables)
@@ -178,7 +176,6 @@ DISPLAYABLE PROPERTIES:
178176
findIndex
179177
includes
180178
copyWithin
181-
item
182179
constructor
183180
Symbol(Symbol.iterator)
184181
Symbol(Symbol.unscopables)
@@ -217,7 +214,6 @@ ALL PROPERTIES:
217214
findIndex
218215
includes
219216
copyWithin
220-
item
221217
constructor
222218
Symbol(Symbol.iterator)
223219
Symbol(Symbol.unscopables)

LayoutTests/js/Object-getOwnPropertyNames-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ PASS getSortedOwnPropertyNames(Object.prototype) is ['__defineGetter__', '__defi
4747
PASS getSortedOwnPropertyNames(Function) is ['length', 'name', 'prototype']
4848
PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']
4949
PASS getSortedOwnPropertyNames(Array) is ['from', 'isArray', 'length', 'name', 'of', 'prototype']
50-
PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'item', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
50+
PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
5151
PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']
5252
PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', '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']
5353
PASS getSortedOwnPropertyNames(Boolean) is ['length', 'name', 'prototype']

LayoutTests/js/array-unscopables-properties-expected.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ PASS Array.prototype[Symbol.unscopables]["includes"] is true
4242
PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "includes").writable is true
4343
PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "includes").enumerable is true
4444
PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "includes").configurable is true
45-
PASS Array.prototype[Symbol.unscopables]["item"] is true
46-
PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "item").writable is true
47-
PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "item").enumerable is true
48-
PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "item").configurable is true
4945
PASS Array.prototype[Symbol.unscopables]["keys"] is true
5046
PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "keys").writable is true
5147
PASS Object.getOwnPropertyDescriptor(Array.prototype[Symbol.unscopables], "keys").enumerable is true

LayoutTests/js/script-tests/Object-getOwnPropertyNames.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var expectedPropertyNamesSet = {
5656
"Function": "['length', 'name', 'prototype']",
5757
"Function.prototype": "['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']",
5858
"Array": "['from', 'isArray', 'length', 'name', 'of', 'prototype']",
59-
"Array.prototype": "['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'item', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",
59+
"Array.prototype": "['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",
6060
"String": "['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']",
6161
"String.prototype": "['anchor', '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']",
6262
"Boolean": "['length', 'name', 'prototype']",

LayoutTests/js/script-tests/array-unscopables-properties.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ let expectedEntries = [
1515
"flat",
1616
"flatMap",
1717
"includes",
18-
"item",
1918
"keys",
2019
"values"
2120
];

0 commit comments

Comments
 (0)