Bug 1390106 - Stop using versioned scripts in addon-sdk. r=mossop
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Mon, 14 Aug 2017 20:38:59 +0900
changeset 647058 a70102f1f011d1b1eada3461398c468ee789d0ab
parent 647057 ea6b6c96a66f84f4fa97743100f7404da64a4ac8
child 647059 1eb26b7019757eabd670f8203872076e404dca4e
push id74288
push userhikezoe@mozilla.com
push dateWed, 16 Aug 2017 00:19:57 +0000
reviewersmossop
bugs1390106
milestone57.0a1
Bug 1390106 - Stop using versioned scripts in addon-sdk. r=mossop 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) {