mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-16 13:56:29 +00:00
Bug 1070767 - Enable {Array, %TypedArray%}.prototype.includes in all builds. r=lth
This commit is contained in:
parent
8f93a52f18
commit
8614310b85
@ -3108,10 +3108,7 @@ static const JSFunctionSpec array_methods[] = {
|
||||
JS_SELF_HOSTED_FN("keys", "ArrayKeys", 0,0),
|
||||
|
||||
/* ES7 additions */
|
||||
#ifdef NIGHTLY_BUILD
|
||||
JS_SELF_HOSTED_FN("includes", "ArrayIncludes", 2,0),
|
||||
#endif
|
||||
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
|
@ -11,9 +11,6 @@ const constructors = [
|
||||
];
|
||||
|
||||
for (var constructor of constructors) {
|
||||
if (!("includes" in constructor.prototype))
|
||||
break;
|
||||
|
||||
assertEq(constructor.prototype.includes.length, 1);
|
||||
|
||||
assertEq(new constructor([1, 2, 3]).includes(1), true);
|
||||
|
@ -8,42 +8,40 @@ var summary = "Implement Array.prototype.includes";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
if ('includes' in []) {
|
||||
assertEq(typeof [].includes, "function");
|
||||
assertEq([].includes.length, 1);
|
||||
assertEq(typeof [].includes, "function");
|
||||
assertEq([].includes.length, 1);
|
||||
|
||||
assertTrue([1, 2, 3].includes(2));
|
||||
assertTrue([1,,2].includes(2));
|
||||
assertTrue([1, 2, 3].includes(2, 1));
|
||||
assertTrue([1, 2, 3].includes(2, -2));
|
||||
assertTrue([1, 2, 3].includes(2, -100));
|
||||
assertTrue([Object, Function, Array].includes(Function));
|
||||
assertTrue([-0].includes(0));
|
||||
assertTrue([NaN].includes(NaN));
|
||||
assertTrue([,].includes());
|
||||
assertTrue(staticIncludes("123", "2"));
|
||||
assertTrue(staticIncludes({length: 3, 1: 2}, 2));
|
||||
assertTrue(staticIncludes({length: 3, 1: 2, get 3(){throw ""}}, 2));
|
||||
assertTrue(staticIncludes({length: 3, get 1() {return 2}}, 2));
|
||||
assertTrue(staticIncludes({__proto__: {1: 2}, length: 3}, 2));
|
||||
assertTrue(staticIncludes(new Proxy([1], {get(){return 2}}), 2));
|
||||
assertTrue([1, 2, 3].includes(2));
|
||||
assertTrue([1,,2].includes(2));
|
||||
assertTrue([1, 2, 3].includes(2, 1));
|
||||
assertTrue([1, 2, 3].includes(2, -2));
|
||||
assertTrue([1, 2, 3].includes(2, -100));
|
||||
assertTrue([Object, Function, Array].includes(Function));
|
||||
assertTrue([-0].includes(0));
|
||||
assertTrue([NaN].includes(NaN));
|
||||
assertTrue([,].includes());
|
||||
assertTrue(staticIncludes("123", "2"));
|
||||
assertTrue(staticIncludes({length: 3, 1: 2}, 2));
|
||||
assertTrue(staticIncludes({length: 3, 1: 2, get 3(){throw ""}}, 2));
|
||||
assertTrue(staticIncludes({length: 3, get 1() {return 2}}, 2));
|
||||
assertTrue(staticIncludes({__proto__: {1: 2}, length: 3}, 2));
|
||||
assertTrue(staticIncludes(new Proxy([1], {get(){return 2}}), 2));
|
||||
|
||||
assertFalse([1, 2, 3].includes("2"));
|
||||
assertFalse([1, 2, 3].includes(2, 2));
|
||||
assertFalse([1, 2, 3].includes(2, -1));
|
||||
assertFalse([undefined].includes(NaN));
|
||||
assertFalse([{}].includes({}));
|
||||
assertFalse(staticIncludes({length: 3, 1: 2}, 2, 2));
|
||||
assertFalse(staticIncludes({length: 3, get 0(){delete this[1]}, 1: 2}, 2));
|
||||
assertFalse(staticIncludes({length: -100, 0: 1}, 1));
|
||||
assertFalse([1, 2, 3].includes("2"));
|
||||
assertFalse([1, 2, 3].includes(2, 2));
|
||||
assertFalse([1, 2, 3].includes(2, -1));
|
||||
assertFalse([undefined].includes(NaN));
|
||||
assertFalse([{}].includes({}));
|
||||
assertFalse(staticIncludes({length: 3, 1: 2}, 2, 2));
|
||||
assertFalse(staticIncludes({length: 3, get 0(){delete this[1]}, 1: 2}, 2));
|
||||
assertFalse(staticIncludes({length: -100, 0: 1}, 1));
|
||||
|
||||
assertThrowsInstanceOf(() => staticIncludes(), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes(null), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes({get length(){throw TypeError()}}), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes({length: 3, get 1() {throw TypeError()}}, 2), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes({__proto__: {get 1() {throw TypeError()}}, length: 3}, 2), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes(new Proxy([1], {get(){throw TypeError()}})), TypeError);
|
||||
}
|
||||
assertThrowsInstanceOf(() => staticIncludes(), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes(null), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes({get length(){throw TypeError()}}), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes({length: 3, get 1() {throw TypeError()}}, 2), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes({__proto__: {get 1() {throw TypeError()}}, length: 3}, 2), TypeError);
|
||||
assertThrowsInstanceOf(() => staticIncludes(new Proxy([1], {get(){throw TypeError()}})), TypeError);
|
||||
|
||||
function assertTrue(v) {
|
||||
assertEq(v, true);
|
||||
|
@ -801,9 +801,7 @@ TypedArrayObject::protoFunctions[] = {
|
||||
// Both of these are actually defined to the same object in FinishTypedArrayInit.
|
||||
JS_SELF_HOSTED_FN("values", "TypedArrayValues", 0, JSPROP_DEFINE_LATE),
|
||||
JS_SELF_HOSTED_SYM_FN(iterator, "TypedArrayValues", 0, JSPROP_DEFINE_LATE),
|
||||
#ifdef NIGHTLY_BUILD
|
||||
JS_SELF_HOSTED_FN("includes", "TypedArrayIncludes", 2, 0),
|
||||
#endif
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
|
@ -168,22 +168,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
gPrototypeProperties['Array'] =
|
||||
["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push",
|
||||
"pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf",
|
||||
"forEach", "map", "reduce", "reduceRight", "filter", "some", "every", "find",
|
||||
"includes", "forEach", "map", "reduce", "reduceRight", "filter", "some", "every", "find",
|
||||
"findIndex", "copyWithin", "fill", Symbol.iterator, "entries", "keys", "constructor"];
|
||||
if (isNightlyBuild) {
|
||||
gPrototypeProperties['Array'].push('includes');
|
||||
}
|
||||
for (var c of typedArrayClasses) {
|
||||
gPrototypeProperties[c] = ["constructor", "BYTES_PER_ELEMENT"];
|
||||
}
|
||||
gPrototypeProperties['TypedArray'] =
|
||||
["length", "buffer", "byteLength", "byteOffset", Symbol.iterator, "subarray",
|
||||
"set", "copyWithin", "find", "findIndex", "forEach","indexOf", "lastIndexOf", "reverse",
|
||||
"join", "every", "some", "reduce", "reduceRight", "entries", "keys", "values", "slice",
|
||||
"map", "filter"];
|
||||
if (isNightlyBuild) {
|
||||
gPrototypeProperties['TypedArray'].push('includes');
|
||||
}
|
||||
"set", "copyWithin", "find", "findIndex", "forEach","indexOf", "lastIndexOf", "includes",
|
||||
"reverse", "join", "every", "some", "reduce", "reduceRight", "entries", "keys", "values",
|
||||
"slice", "map", "filter"];
|
||||
for (var c of errorObjectClasses) {
|
||||
gPrototypeProperties[c] = ["constructor", "name",
|
||||
// We don't actually resolve these empty data properties
|
||||
@ -207,10 +201,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
||||
"flags", "global", "ignoreCase", "multiline", "source", "sticky",
|
||||
"lastIndex"];
|
||||
|
||||
if (isNightlyBuild) {
|
||||
gPrototypeProperties['TypedArray'].push('includes');
|
||||
}
|
||||
|
||||
// Sort an array that may contain symbols as well as strings.
|
||||
function sortProperties(arr) {
|
||||
function sortKey(prop) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user