Bug 1069416 - Part 2: Remove JS_HAS_SYMBOLS from js tests. r=evilpie,mrbkap
authorTooru Fujisawa <arai_a@mac.com>
Wed, 28 Jan 2015 13:06:37 +0900
changeset 239551 32e5ed282edbbc44131c6e1077dad64402219ae4
parent 239550 cad25450eff5dec73395b194b05d21ca27dc7344
child 239552 ff4b721149af17ada758f1300359ca1c3af5025d
push id500
push userjoshua.m.grant@gmail.com
push dateThu, 29 Jan 2015 01:48:36 +0000
reviewersevilpie, mrbkap
bugs1069416
milestone38.0a1
Bug 1069416 - Part 2: Remove JS_HAS_SYMBOLS from js tests. r=evilpie,mrbkap
js/src/jit-test/lib/iteration.js
js/src/jit-test/tests/basic/expression-autopsy.js
js/src/jit-test/tests/collections/iterator-proto-surfaces.js
js/src/jit-test/tests/for-of/string-iterator-surfaces.js
js/src/tests/ecma_6/Generators/runtime.js
js/src/tests/js1_8/regress/regress-469625-03.js
js/src/tests/js1_8_5/extensions/decompile-for-of.js
js/src/tests/shell.js
js/xpconnect/tests/chrome/test_xrayToJS.xul
--- a/js/src/jit-test/lib/iteration.js
+++ b/js/src/jit-test/lib/iteration.js
@@ -1,17 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 load(libdir + "asserts.js");
 
-const JS_HAS_SYMBOLS = typeof Symbol === "function";
-const std_iterator = JS_HAS_SYMBOLS ? Symbol.iterator : '@@iterator';
+const std_iterator = Symbol.iterator;
 
 if (typeof assertIteratorResult === 'undefined') {
     var assertIteratorResult = function assertIteratorResult(result, value, done) {
         assertEq(typeof result, "object");
         var expectedProps = ['done', 'value'];
         var actualProps = Object.getOwnPropertyNames(result);
         actualProps.sort(), expectedProps.sort();
         assertDeepEq(actualProps, expectedProps);
--- a/js/src/jit-test/tests/basic/expression-autopsy.js
+++ b/js/src/jit-test/tests/basic/expression-autopsy.js
@@ -105,16 +105,15 @@ for (let tok of ["|", "^", "&", "==", "!
 check("o[!(o)]");
 check("o[~(o)]");
 check("o[+ (o)]");
 check("o[- (o)]");
 
 // A few one off tests
 check_one("6", (function () { 6() }), " is not a function");
 check_one("Array.prototype.reverse.call(...)", (function () { Array.prototype.reverse.call('123'); }), " is read-only");
-var ITERATOR = JS_HAS_SYMBOLS ? "Symbol.iterator" : "'@@iterator'";
-check_one(`(intermediate value)[${ITERATOR}](...).next(...).value`,
+check_one(`(intermediate value)[Symbol.iterator](...).next(...).value`,
           function () { var [{ x }] = [null, {}]; }, " is null");
-check_one(`(intermediate value)[${ITERATOR}](...).next(...).value`,
+check_one(`(intermediate value)[Symbol.iterator](...).next(...).value`,
           function () { ieval("let (x) { var [a, b, [c0, c1]] = [x, x, x]; }") }, " is undefined");
 
 // Check fallback behavior
 assertThrowsInstanceOf(function () { for (let x of undefined) {} }, TypeError);
--- a/js/src/jit-test/tests/collections/iterator-proto-surfaces.js
+++ b/js/src/jit-test/tests/collections/iterator-proto-surfaces.js
@@ -2,17 +2,17 @@
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 
 function test(constructor) {
     var proto = Object.getPrototypeOf(constructor()[std_iterator]());
     var names = Object.getOwnPropertyNames(proto);
     names.sort();
-    assertDeepEq(names, JS_HAS_SYMBOLS ? ['next'] : ['@@iterator', 'next']);
+    assertDeepEq(names, ['next']);
     assertEq(proto.hasOwnProperty(std_iterator), true);
 
     var desc = Object.getOwnPropertyDescriptor(proto, 'next');
     assertEq(desc.configurable, true);
     assertEq(desc.enumerable, false);
     assertEq(desc.writable, true);
 
     assertEq(proto[std_iterator](), proto);
--- a/js/src/jit-test/tests/for-of/string-iterator-surfaces.js
+++ b/js/src/jit-test/tests/for-of/string-iterator-surfaces.js
@@ -51,19 +51,18 @@ assertBuiltinFunction(String.prototype, 
 
 // Test StringIterator.prototype surface
 var iter = ""[std_iterator]();
 var iterProto = Object.getPrototypeOf(iter);
 
 // StringIterator.prototype inherits from Object.prototype
 assertEq(Object.getPrototypeOf(iterProto), Object.prototype);
 
-// Own properties for StringIterator.prototype: "next" and @@iterator
-arraysEqual(Object.getOwnPropertyNames(iterProto).sort(),
-            JS_HAS_SYMBOLS ? ["next"] : ["@@iterator", "next"]);
+// Own properties for StringIterator.prototype: "next"
+arraysEqual(Object.getOwnPropertyNames(iterProto).sort(), ["next"]);
 assertEq(iterProto.hasOwnProperty(std_iterator), true);
 
 // StringIterator.prototype[@@iterator] is a built-in function
 assertBuiltinFunction(iterProto, std_iterator, 0);
 
 // StringIterator.prototype.next is a built-in function
 assertBuiltinFunction(iterProto, "next", 0);
 
--- a/js/src/tests/ecma_6/Generators/runtime.js
+++ b/js/src/tests/ecma_6/Generators/runtime.js
@@ -60,18 +60,16 @@ TestGeneratorFunctionPrototype();
 // a common prototype.
 function TestGeneratorObjectPrototype() {
     assertEq(Object.getPrototypeOf(GeneratorObjectPrototype),
                Object.prototype);
     assertEq(Object.getPrototypeOf((function*(){yield 1}).prototype),
                GeneratorObjectPrototype);
 
     var expected_property_names = ["next", "return", "throw", "constructor"];
-    if (!JS_HAS_SYMBOLS)
-        expected_property_names.push(std_iterator);
     var found_property_names =
         Object.getOwnPropertyNames(GeneratorObjectPrototype);
 
     expected_property_names.sort();
     found_property_names.sort();
 
     assertDeepEq(found_property_names, expected_property_names);
 }
--- a/js/src/tests/js1_8/regress/regress-469625-03.js
+++ b/js/src/tests/js1_8/regress/regress-469625-03.js
@@ -21,18 +21,17 @@ function test()
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
  
   function f(x) {
     var [a, b, [c0, c1]] = [x, x, x];
   }
 
-  var ITERATOR = JS_HAS_SYMBOLS ? "Symbol.iterator" : "'@@iterator'";
-  expect = `TypeError: (intermediate value)[${ITERATOR}](...).next(...).value is null`;
+  expect = `TypeError: (intermediate value)[Symbol.iterator](...).next(...).value is null`;
   actual = 'No Error';
   try
   {
     f(null);
   }
   catch(ex)
   {
     actual = ex + '';
--- a/js/src/tests/js1_8_5/extensions/decompile-for-of.js
+++ b/js/src/tests/js1_8_5/extensions/decompile-for-of.js
@@ -4,18 +4,17 @@ var x;
 function check(code) {
     var s = "no exception thrown";
     try {
         eval(code);
     } catch (exc) {
         s = exc.message;
     }
 
-    var ITERATOR = JS_HAS_SYMBOLS ? "Symbol.iterator" : "'@@iterator'";
-    assertEq(s, `x[${ITERATOR}] is not a function`);
+    assertEq(s, `x[Symbol.iterator] is not a function`);
 }
 
 x = {};
 check("for (var v of x) throw fit;");
 check("[...x]");
 check("Math.hypot(...x)");
 
 x[std_iterator] = "potato";
--- a/js/src/tests/shell.js
+++ b/js/src/tests/shell.js
@@ -872,10 +872,9 @@ function GetContext() {
 }
 function OptLevel( i ) {
   i = Number(i);
   var cx = GetContext();
   cx.setOptimizationLevel(i);
 }
 /* end of Rhino functions */
 
-var JS_HAS_SYMBOLS = typeof Symbol === "function";
-var std_iterator = JS_HAS_SYMBOLS ? Symbol.iterator : "@@iterator";
+var std_iterator = Symbol.iterator;
--- a/js/xpconnect/tests/chrome/test_xrayToJS.xul
+++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul
@@ -140,18 +140,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   // Maintain a static list of the properties that are available on each standard
   // prototype, so that we make sure to audit any new ones to make sure they're
   // Xray-safe.
   //
   // DO NOT CHANGE WTIHOUT REVIEW FROM AN XPCONNECT PEER.
   var version = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo).version;
   var isNightlyBuild = version.endsWith("a1");
   var isReleaseBuild = !version.contains("a");
-  const jsHasSymbols = typeof Symbol === "function";
-  const kIteratorSymbol = jsHasSymbols ? Symbol.iterator : "@@iterator";
   var gPrototypeProperties = {};
   gPrototypeProperties['Date'] =
     ["getTime", "getTimezoneOffset", "getYear", "getFullYear", "getUTCFullYear",
     "getMonth", "getUTCMonth", "getDate", "getUTCDate", "getDay", "getUTCDay",
     "getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds",
     "getUTCSeconds", "getMilliseconds", "getUTCMilliseconds", "setTime",
     "setYear", "setFullYear", "setUTCFullYear", "setMonth", "setUTCMonth",
     "setDate", "setUTCDate", "setHours", "setUTCHours", "setMinutes",
@@ -164,25 +162,25 @@ 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", kIteratorSymbol, "entries", "keys", "constructor"];
+      "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", kIteratorSymbol, "subarray",
+    ["length", "buffer", "byteLength", "byteOffset", Symbol.iterator, "subarray",
      "set", "copyWithin", "find", "findIndex", "forEach","indexOf", "lastIndexOf", "reverse",
      "join", "every", "some", "reduce", "reduceRight", "entries", "keys", "values"];
   if (isNightlyBuild) {
     gPrototypeProperties['TypedArray'].push('includes');
   }
   for (var c of errorObjectClasses) {
       gPrototypeProperties[c] = ["constructor", "name",
                                  // We don't actually resolve these empty data properties
@@ -270,40 +268,36 @@ https://bugzilla.mozilla.org/show_bug.cg
     let xrayProto = Object.getPrototypeOf(xray);
     let localProto = window[classname].prototype;
     let desiredProtoProps = Object.getOwnPropertyNames(localProto).sort();
 
     is(desiredProtoProps.toSource(),
        gPrototypeProperties[classname].filter(id => typeof id === "string").toSource(),
        "A property on the " + classname +
        " prototype has changed! You need a security audit from an XPConnect peer");
-    if (jsHasSymbols) {
-      is(Object.getOwnPropertySymbols(localProto).map(uneval).sort().toSource(),
-         gPrototypeProperties[classname].filter(id => typeof id !== "string").map(uneval).sort().toSource(),
-         "A symbol-keyed property on the " + classname +
-         " prototype has been changed! You need a security audit from an XPConnect peer");
-    }
+    is(Object.getOwnPropertySymbols(localProto).map(uneval).sort().toSource(),
+       gPrototypeProperties[classname].filter(id => typeof id !== "string").map(uneval).sort().toSource(),
+       "A symbol-keyed property on the " + classname +
+       " prototype has been changed! You need a security audit from an XPConnect peer");
 
     let protoProps = filterOut(desiredProtoProps, propsToSkip);
     let protoCallables = protoProps.filter(name => propertyIsGetter(localProto, name, classname) ||
                                                    typeof localProto[name] == 'function' &&
                                                    name != 'constructor');
     ok(protoCallables.length > 0, "Need something to test");
     is(xrayProto, iwin[classname].prototype, "Xray proto is correct");
     is(xrayProto, xray.__proto__, "Proto accessors agree");
     var protoProto = classname == "Object" ? null : iwin.Object.prototype;
     is(Object.getPrototypeOf(xrayProto), protoProto, "proto proto is correct");
     testProtoCallables(protoCallables, xray, xrayProto, localProto);
     is(Object.getOwnPropertyNames(xrayProto).sort().toSource(),
        protoProps.toSource(), "getOwnPropertyNames works");
-    if (jsHasSymbols) {
-      is(Object.getOwnPropertySymbols(xrayProto).map(uneval).sort().toSource(),
-         gPrototypeProperties[classname].filter(id => typeof id !== "string").map(uneval).sort().toSource(),
-         protoProps.toSource(), "getOwnPropertySymbols works");
-    }
+    is(Object.getOwnPropertySymbols(xrayProto).map(uneval).sort().toSource(),
+       gPrototypeProperties[classname].filter(id => typeof id !== "string").map(uneval).sort().toSource(),
+       protoProps.toSource(), "getOwnPropertySymbols works");
 
     is(xrayProto.constructor, iwin[classname], "constructor property works");
 
     xrayProto.expando = 42;
     is(xray.expando, 42, "Xrayed instances see proto expandos");
     is(xray2.expando, 42, "Xrayed instances see proto expandos");
   }
 
@@ -325,21 +319,19 @@ https://bugzilla.mozilla.org/show_bug.cg
   var uniqueSymbol;
 
   function testObject() {
     testXray('Object', Cu.unwaiveXrays(Cu.waiveXrays(iwin).Object.create(new iwin.Object())),
              new iwin.Object(), []);
 
     // Construct an object full of tricky things.
     let symbolProps = '';
-    if (jsHasSymbols) {
-      uniqueSymbol = iwin.eval('var uniqueSymbol = Symbol("uniqueSymbol"); uniqueSymbol');
-      symbolProps = `, [uniqueSymbol]: 43,
-                     [Symbol.for("registrySymbolProp")]: 44`;
-    }
+    uniqueSymbol = iwin.eval('var uniqueSymbol = Symbol("uniqueSymbol"); uniqueSymbol');
+    symbolProps = `, [uniqueSymbol]: 43,
+                   [Symbol.for("registrySymbolProp")]: 44`;
     var trickyObject =
       iwin.eval(`(function() {
                  var o = new Object({
                    primitiveProp: 42, objectProp: { foo: 2 },
                    xoProp: top.location, hasOwnProperty: 10,
                    get getterProp() { return 2; },
                    set setterProp(x) { },
                    get getterSetterProp() { return 3; },
@@ -361,21 +353,19 @@ https://bugzilla.mozilla.org/show_bug.cg
     // instance, and therefore has a vestigial .length. But we don't want to
     // show that over Xrays, and generally want .length to just appear as an
     // |own| data property. So we add it to the ignore list here, and check it
     // separately.
     let propsToSkip = ['length'];
     testXray('Array', new iwin.Array(20), new iwin.Array(), propsToSkip);
 
     let symbolProps = '';
-    if (jsHasSymbols) {
-      uniqueSymbol = iwin.eval('var uniqueSymbol = Symbol("uniqueSymbol"); uniqueSymbol');
-      symbolProps = `trickyArray[uniqueSymbol] = 43;
-                     trickyArray[Symbol.for("registrySymbolProp")] = 44;`;
-    }
+    uniqueSymbol = iwin.eval('var uniqueSymbol = Symbol("uniqueSymbol"); uniqueSymbol');
+    symbolProps = `trickyArray[uniqueSymbol] = 43;
+                   trickyArray[Symbol.for("registrySymbolProp")] = 44;`;
     var trickyArray =
       iwin.eval(`var trickyArray = [];
                  trickyArray.primitiveProp = 42;
                  trickyArray.objectProp = { foo: 2 };
                  trickyArray.xoProp = top.location;
                  trickyArray.hasOwnProperty = 10;
                  Object.defineProperty(trickyArray, 'getterProp', { get: function() { return 2; }});
                  Object.defineProperty(trickyArray, 'setterProp', { set: function(x) {}});
@@ -418,31 +408,27 @@ https://bugzilla.mozilla.org/show_bug.cg
     is(Cu.unwaiveXrays(trickyObject.wrappedJSObject.xoProp), top.location, "Underlying object has xo property");
 
     // Test getOwnPropertyNames.
     var expectedNames = ['objectProp', 'primitiveProp'];
     if (trickyObject instanceof iwin.Array)
       expectedNames.push('length');
     is(Object.getOwnPropertyNames(trickyObject).sort().toSource(),
        expectedNames.sort().toSource(), "getOwnPropertyNames should be filtered correctly");
-    if (jsHasSymbols) {
-      var expectedSymbols = [Symbol.for("registrySymbolProp"), uniqueSymbol];
-      is(Object.getOwnPropertySymbols(trickyObject).map(uneval).sort().toSource(),
-         expectedSymbols.map(uneval).sort().toSource(),
-         "getOwnPropertySymbols should be filtered correctly");
-    }
+    var expectedSymbols = [Symbol.for("registrySymbolProp"), uniqueSymbol];
+    is(Object.getOwnPropertySymbols(trickyObject).map(uneval).sort().toSource(),
+       expectedSymbols.map(uneval).sort().toSource(),
+       "getOwnPropertySymbols should be filtered correctly");
 
     // Test that cloning uses the Xray view.
     var cloned = Cu.cloneInto(trickyObject, this);
     is(Object.getOwnPropertyNames(cloned).sort().toSource(),
        expectedNames.sort().toSource(), "structured clone should use the Xray view");
-    if (jsHasSymbols) {
-      is(Object.getOwnPropertySymbols(cloned).map(uneval).sort().toSource(),
-         "[]", "structured cloning doesn't clone symbol-keyed properties yet");
-    }
+    is(Object.getOwnPropertySymbols(cloned).map(uneval).sort().toSource(),
+       "[]", "structured cloning doesn't clone symbol-keyed properties yet");
 
     // Test iteration and in-place modification. Beware of 'expando', which is the property
     // we placed on the xray proto.
     var propCount = 0;
     for (let prop in trickyObject) {
       if (prop == 'primitiveProp')
         trickyObject[prop] = trickyObject[prop] - 10;
       if (prop != 'expando')