Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

deps: revert v8 Array.prototype.values() removal #25328

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/v8/src/array-iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ function ExtendArrayPrototype() {
%CheckIsBootstrapping();

InstallFunctions($Array.prototype, DONT_ENUM, $Array(
// No 'values' since it breaks webcompat: http://crbug.com/409858
'entries', ArrayEntries,
'values', ArrayValues,
'keys', ArrayKeys
));

Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,7 @@ function SetUpArray() {
find: true,
findIndex: true,
keys: true,
values: true,
};
%AddNamedProperty($Array.prototype, symbolUnscopables, unscopables,
DONT_ENUM | READ_ONLY);
Expand Down
17 changes: 10 additions & 7 deletions deps/v8/test/mjsunit/es6/array-iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ function assertHasOwnProperty(object, name, attrs) {

function TestArrayPrototype() {
assertHasOwnProperty(Array.prototype, 'entries', DONT_ENUM);
assertHasOwnProperty(Array.prototype, 'values', DONT_ENUM);
assertHasOwnProperty(Array.prototype, 'keys', DONT_ENUM);
assertHasOwnProperty(Array.prototype, Symbol.iterator, DONT_ENUM);

assertEquals(Array.prototype.values, Array.prototype[Symbol.iterator]);
}
TestArrayPrototype();

Expand All @@ -58,7 +61,7 @@ function assertIteratorResult(value, done, result) {

function TestValues() {
var array = ['a', 'b', 'c'];
var iterator = array[Symbol.iterator]();
var iterator = array.values();
assertIteratorResult('a', false, iterator.next());
assertIteratorResult('b', false, iterator.next());
assertIteratorResult('c', false, iterator.next());
Expand All @@ -72,7 +75,7 @@ TestValues();

function TestValuesMutate() {
var array = ['a', 'b', 'c'];
var iterator = array[Symbol.iterator]();
var iterator = array.values();
assertIteratorResult('a', false, iterator.next());
assertIteratorResult('b', false, iterator.next());
assertIteratorResult('c', false, iterator.next());
Expand Down Expand Up @@ -139,17 +142,17 @@ TestEntriesMutate();

function TestArrayIteratorPrototype() {
var array = [];
var iterator = array.keys();
var iterator = array.values();

var ArrayIteratorPrototype = iterator.__proto__;

assertEquals(ArrayIteratorPrototype, array[Symbol.iterator]().__proto__);
assertEquals(ArrayIteratorPrototype, array.values().__proto__);
assertEquals(ArrayIteratorPrototype, array.keys().__proto__);
assertEquals(ArrayIteratorPrototype, array.entries().__proto__);

assertEquals(Object.prototype, ArrayIteratorPrototype.__proto__);

assertEquals('Array Iterator', %_ClassOf(array[Symbol.iterator]()));
assertEquals('Array Iterator', %_ClassOf(array.values()));
assertEquals('Array Iterator', %_ClassOf(array.keys()));
assertEquals('Array Iterator', %_ClassOf(array.entries()));

Expand All @@ -166,7 +169,7 @@ function TestForArrayValues() {
var buffer = [];
var array = [0, 'a', true, false, null, /* hole */, undefined, NaN];
var i = 0;
for (var value of array[Symbol.iterator]()) {
for (var value of array.values()) {
buffer[i++] = value;
}

Expand Down Expand Up @@ -239,7 +242,7 @@ TestForArrayValues();

function TestNonOwnSlots() {
var array = [0];
var iterator = array[Symbol.iterator]();
var iterator = array.values();
var object = {__proto__: iterator};

assertThrows(function() {
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/test/mjsunit/es6/typed-array-iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function TestTypedArrayPrototype(constructor) {
assertFalse(constructor.prototype.propertyIsEnumerable(Symbol.iterator));

assertEquals(Array.prototype.entries, constructor.prototype.entries);
assertEquals(Array.prototype[Symbol.iterator], constructor.prototype.values);
assertEquals(Array.prototype.values, constructor.prototype.values);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Symbol.iterator tests should still be here though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply did a revert on the commit that removed Array.prototype.values(). What the v8 team does with their tests is their own business :-)

assertEquals(Array.prototype.keys, constructor.prototype.keys);
assertEquals(Array.prototype[Symbol.iterator], constructor.prototype[Symbol.iterator]);
assertEquals(Array.prototype.values, constructor.prototype[Symbol.iterator]);
}
constructors.forEach(TestTypedArrayPrototype);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ PASS getSortedOwnPropertyNames(Object.prototype) is ['__defineGetter__', '__defi
PASS getSortedOwnPropertyNames(Function) is ['arguments', 'caller', 'length', 'name', 'prototype']
PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']
PASS getSortedOwnPropertyNames(Array) is ['arguments', 'caller', 'isArray', 'length', 'name', 'observe', 'prototype', 'unobserve']
PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'entries', 'every', 'filter', 'forEach', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift']
PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'entries', 'every', 'filter', 'forEach', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
PASS getSortedOwnPropertyNames(String) is ['arguments', 'caller', 'fromCharCode', 'length', 'name', 'prototype']
PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'concat', 'constructor', 'fixed', 'fontcolor', 'fontsize', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'normalize', 'replace', 'search', 'slice', 'small', 'split', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']
PASS getSortedOwnPropertyNames(Boolean) is ['arguments', 'caller', 'length', 'name', 'prototype']
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var expectedPropertyNamesSet = {
"Function": "['arguments', 'caller', 'length', 'name', 'prototype']",
"Function.prototype": "['apply', 'arguments', 'bind', 'call', 'caller', 'constructor', 'length', 'name', 'toString']",
"Array": "['arguments', 'caller', 'isArray', 'length', 'name', 'observe', 'prototype', 'unobserve']",
"Array.prototype": "['concat', 'constructor', 'entries', 'every', 'filter', 'forEach', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift']",
"Array.prototype": "['concat', 'constructor', 'entries', 'every', 'filter', 'forEach', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",
"String": "['arguments', 'caller', 'fromCharCode', 'length', 'name', 'prototype']",
"String.prototype": "['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'concat', 'constructor', 'fixed', 'fontcolor', 'fontsize', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'normalize', 'replace', 'search', 'slice', 'small', 'split', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']",
"Boolean": "['arguments', 'caller', 'length', 'name', 'prototype']",
Expand Down
36 changes: 36 additions & 0 deletions test/simple/test-regress-GH-25324.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// Regression test for https://github.com/joyent/node/issues/25324.

var common = require('../common');
var assert = require('assert');
var array = ['foo', 'bar', 'baz'];
var iterator = array.values();

var nbValues = array.length;
var nbIterated = 0;

for (var letter of iterator) {
++nbIterated;
}

assert.equal(nbIterated, nbValues);