Bug 1069416 - Part 8: Remove JS_HAS_SYMBOLS from Promise-backend.js. r=paolo
authorTooru Fujisawa <arai_a@mac.com>
Wed, 28 Jan 2015 13:06:38 +0900
changeset 226170 3256cb6f0bc92cff4b6377dc3b3f0e290649c217
parent 226169 5f3d5ec3d30b5bf5ca77cf1191488ad58ed84d3f
child 226171 39c448409484df1357a6417f38c9a6965d60b51c
push id54780
push userarai_a@mac.com
push dateWed, 28 Jan 2015 04:08:48 +0000
treeherdermozilla-inbound@3256cb6f0bc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1069416
milestone38.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 1069416 - Part 8: Remove JS_HAS_SYMBOLS from Promise-backend.js. r=paolo
toolkit/modules/Promise-backend.js
--- a/toolkit/modules/Promise-backend.js
+++ b/toolkit/modules/Promise-backend.js
@@ -32,19 +32,16 @@ const STATUS_REJECTED = 2;
 // This N_INTERNALS name allow internal properties of the Promise to be
 // accessed only by this module, while still being visible on the object
 // manually when using a debugger.  This doesn't strictly guarantee that the
 // properties are inaccessible by other code, but provide enough protection to
 // avoid using them by mistake.
 const salt = Math.floor(Math.random() * 100);
 const N_INTERNALS = "{private:internals:" + salt + "}";
 
-const JS_HAS_SYMBOLS = typeof Symbol === "function";
-const ITERATOR_SYMBOL = JS_HAS_SYMBOLS ? Symbol.iterator : "@@iterator";
-
 // We use DOM Promise for scheduling the walker loop.
 const DOMPromise = Promise;
 
 /////// Warn-upon-finalization mechanism
 //
 // One of the difficult problems with promises is locating uncaught
 // rejections. We adopt the following strategy: if a promise is rejected
 // at the time of its garbage-collection *and* if the promise is at the
@@ -512,17 +509,17 @@ Promise.reject = function (aReason)
  *         that is rejected when any of the values are rejected. Its
  *         resolution value will be an array of all resolved values in the
  *         given order, or undefined if aValues is an empty array. The reject
  *         reason will be forwarded from the first promise in the list of
  *         given promises to be rejected.
  */
 Promise.all = function (aValues)
 {
-  if (aValues == null || typeof(aValues[ITERATOR_SYMBOL]) != "function") {
+  if (aValues == null || typeof(aValues[Symbol.iterator]) != "function") {
     throw new Error("Promise.all() expects an iterable.");
   }
 
   return new Promise((resolve, reject) => {
     let values = Array.isArray(aValues) ? aValues : [...aValues];
     let countdown = values.length;
     let resolutionValues = new Array(countdown);
 
@@ -563,17 +560,17 @@ Promise.all = function (aValues)
  *        be resolved or rejected as to the given value or reason.
  *
  * @return A new promise that is fulfilled when any values are resolved or
  *         rejected. Its resolution value will be forwarded from the resolution
  *         value or rejection reason.
  */
 Promise.race = function (aValues)
 {
-  if (aValues == null || typeof(aValues[ITERATOR_SYMBOL]) != "function") {
+  if (aValues == null || typeof(aValues[Symbol.iterator]) != "function") {
     throw new Error("Promise.race() expects an iterable.");
   }
 
   return new Promise((resolve, reject) => {
     for (let value of aValues) {
       Promise.resolve(value).then(resolve, reject);
     }
   });