Bug 1390106 - Stop using versioned scripts in addon-sdk. r?gabor draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Mon, 14 Aug 2017 20:38:59 +0900
changeset 645883 8fe01ac6ad6b3c4ede7b68e7234d1d6a9941dd12
parent 645882 dede755fa4af229e4d079ce47f88d8205fa877b1
child 645884 b854d9f6f2ef144f582ed3a5ffad4355e449347b
push id73921
push userVYV03354@nifty.ne.jp
push dateMon, 14 Aug 2017 11:59:07 +0000
reviewersgabor
bugs1390106
milestone57.0a1
Bug 1390106 - Stop using versioned scripts in addon-sdk. r?gabor MozReview-Commit-ID: C5122oYHTWx
addon-sdk/source/lib/sdk/deprecated/window-utils.js
addon-sdk/source/lib/sdk/lang/weak-set.js
addon-sdk/source/lib/sdk/util/collection.js
addon-sdk/source/lib/sdk/util/list.js
--- a/addon-sdk/source/lib/sdk/deprecated/window-utils.js
+++ b/addon-sdk/source/lib/sdk/deprecated/window-utils.js
@@ -26,34 +26,34 @@ function getWindows() {
 }
 
 /**
  * An iterator for XUL windows currently in the application.
  *
  * @return A generator that yields XUL windows exposing the
  *         nsIDOMWindow interface.
  */
-function windowIterator() {
+function* windowIterator() {
   // Bug 752631: We only pass already loaded window in order to avoid
   // breaking XUL windows DOM. DOM is broken when some JS code try
   // to access DOM during "uninitialized" state of the related document.
   let list = getWindows().filter(isDocumentLoaded);
   for (let i = 0, l = list.length; i < l; i++) {
     yield list[i];
   }
 };
 exports.windowIterator = windowIterator;
 
 /**
  * An iterator for browser windows currently open in the application.
  * @returns {Function}
  *    A generator that yields browser windows exposing the `nsIDOMWindow`
  *    interface.
  */
-function browserWindowIterator() {
+function* browserWindowIterator() {
   for (let window of windowIterator()) {
     if (isBrowser(window))
       yield window;
   }
 }
 exports.browserWindowIterator = browserWindowIterator;
 
 function WindowTracker(delegate) {
--- a/addon-sdk/source/lib/sdk/lang/weak-set.js
+++ b/addon-sdk/source/lib/sdk/lang/weak-set.js
@@ -49,17 +49,17 @@ function has(target, value) {
 exports.has = has;
 
 function clear(target) {
   clearLookupFor(target);
   clearRefsFor(target);
 }
 exports.clear = clear;
 
-function iterator(target) {
+function* iterator(target) {
   let refs = getRefsFor(target);
 
   for (let ref of refs) {
     let value = ref.get();
 
     // If `value` is already gc'ed, it would be `null`.
     // The `has` function is using a WeakMap as lookup table, so passing `null`
     // would raise an exception because WeakMap accepts as value only non-null
@@ -67,9 +67,9 @@ function iterator(target) {
     // Plus, if `value` is already gc'ed, we do not have to take it in account
     // during the iteration, and remove it from the references.
     if (value !== null && has(target, value))
       yield value;
     else
       refs.delete(ref);
   }
 }
-exports.iterator = iterator;
+exports[Symbol.iterator] = iterator;
--- a/addon-sdk/source/lib/sdk/util/collection.js
+++ b/addon-sdk/source/lib/sdk/util/collection.js
@@ -52,17 +52,17 @@ exports.addCollectionProperty = function
  */
 function Collection(array) {
   array = array || [];
 
   /**
    * Provides iteration over the collection.  Items are yielded in the order
    * they were added.
    */
-  this.__iterator__ = function Collection___iterator__() {
+  this[Symbol.iterator] = function* Collection___iterator__() {
     let items = array.slice();
     for (let i = 0; i < items.length; i++)
       yield items[i];
   };
 
   /**
    * The number of items in the collection.
    */
--- a/addon-sdk/source/lib/sdk/util/list.js
+++ b/addon-sdk/source/lib/sdk/util/list.js
@@ -32,29 +32,16 @@ const listOptions = {
   },
    /**
     * Returns a string representing this list.
     * @returns {String}
     */
   toString: function toString() {
     return 'List(' + listNS(this).keyValueMap + ')';
   },
-  /**
-   * Custom iterator providing `List`s enumeration behavior.
-   * We cant reuse `_iterator` that is defined by `Iterable` since it provides
-   * iteration in an arbitrary order.
-   * @see https://developer.mozilla.org/en/JavaScript/Reference/Statements/for...in
-   * @param {Boolean} onKeys
-   */
-  __iterator__: function __iterator__(onKeys, onKeyValue) {
-    let array = listNS(this).keyValueMap.slice(0),
-                i = -1;
-    for (let element of array)
-      yield onKeyValue ? [++i, element] : onKeys ? ++i : element;
-  },
 };
 listOptions[Symbol.iterator] = function iterator() {
     return listNS(this).keyValueMap.slice(0)[Symbol.iterator]();
 };
 const List = Class(listOptions);
 exports.List = List;
 
 function addListItem(that, value) {