Bug 1069063 - Part 2: Make Array.prototype.includes Nightly-only. r=lth
authorTill Schneidereit <till@tillschneidereit.net>
Fri, 21 Nov 2014 16:41:51 +0100
changeset 216861 160459853756b38e1da66d4e6cd766d0372b5443
parent 216860 de99cdf15f9495cef38bc15128f846deec119b78
child 216863 c98a8847f6e2ae576f29f1fcc0b78c358ceb1e47
push id52157
push usertschneidereit@gmail.com
push dateFri, 21 Nov 2014 15:42:34 +0000
treeherdermozilla-inbound@160459853756 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslth
bugs1069063
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1069063 - Part 2: Make Array.prototype.includes Nightly-only. r=lth
js/src/jsarray.cpp
js/src/tests/ecma_7/Array/includes.js
js/xpconnect/tests/chrome/test_xrayToJS.xul
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -3224,17 +3224,19 @@ static const JSFunctionSpec array_method
 
     JS_SELF_HOSTED_FN("fill",        "ArrayFill",        3,0),
 
     JS_SELF_HOSTED_SYM_FN(iterator,  "ArrayValues",      0,0),
     JS_SELF_HOSTED_FN("entries",     "ArrayEntries",     0,0),
     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
 };
 
 static const JSFunctionSpec array_static_methods[] = {
     JS_FN("isArray",            array_isArray,      1,0),
     JS_SELF_HOSTED_FN("lastIndexOf", "ArrayStaticLastIndexOf", 2,0),
     JS_SELF_HOSTED_FN("indexOf",     "ArrayStaticIndexOf", 2,0),
--- a/js/src/tests/ecma_7/Array/includes.js
+++ b/js/src/tests/ecma_7/Array/includes.js
@@ -3,50 +3,52 @@
  * http://creativecommons.org/licenses/publicdomain/
  */
 
 var BUGNUMBER = 1069063;
 var summary = "Implement Array.prototype.includes";
 
 print(BUGNUMBER + ": " + summary);
 
-assertEq(typeof [].includes, "function");
-assertEq([].includes.length, 1);
+if ('includes' in []) {
+    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);
 }
 
 function assertFalse(v) {
     assertEq(v, false);
 }
--- a/js/xpconnect/tests/chrome/test_xrayToJS.xul
+++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul
@@ -164,18 +164,19 @@ https://bugzilla.mozilla.org/show_bug.cg
                                       the JS engine filters it out of getOwnPropertyNames */
     ["constructor", "toSource", "toString", "toLocaleString", "valueOf", "watch",
      "unwatch", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable",
      "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"];
   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",
-      "findIndex", "copyWithin", "fill", "includes", kIteratorSymbol, "entries", "keys", "constructor"];
+      "findIndex", "copyWithin", "fill", kIteratorSymbol, "entries", "keys", "constructor"];
   if (isNightlyBuild) {
+    gPrototypeProperties['Array'].push('includes');
     let pjsMethods = ['mapPar', 'reducePar', 'scanPar', 'scatterPar', 'filterPar'];
     gPrototypeProperties['Array'] = gPrototypeProperties['Array'].concat(pjsMethods);
   }
   for (var c of typedArrayClasses) {
     gPrototypeProperties[c] = ["constructor", "BYTES_PER_ELEMENT"];
   }
   gPrototypeProperties['TypedArray'] =
     ["length", "buffer", "byteLength", "byteOffset", kIteratorSymbol, "subarray",