Bug 1292569 - Remove legacy generators from im/. r=clokep
authoraleth <aleth@instantbird.org>
Tue, 09 Aug 2016 20:46:26 +0200
changeset 25782 bc541ec44b099e32dfac2eb7a196883b161d53bc
parent 25781 2d98b9270327955eb9a20893ec1b943ecb106835
child 25783 cf69eee353d3126887db17c3266d4bfa8a961d63
push id1771
push userclokep@gmail.com
push dateMon, 14 Nov 2016 17:47:53 +0000
treeherdercomm-beta@399ae9d71595 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersclokep
bugs1292569
Bug 1292569 - Remove legacy generators from im/. r=clokep
im/content/account.js
im/content/accountWizard.js
im/content/accounts.js
im/content/addbuddy.js
im/content/debug/debug.js
im/content/debug/fake/fake.js
im/content/joinchat.js
im/content/proxies.js
im/content/utilities.js
im/modules/ibCore.jsm
--- a/im/content/account.js
+++ b/im/content/account.js
@@ -182,17 +182,17 @@ var account = {
         branch.setComplexValue(autoJoinPref, Ci.nsISupportsString, str);
       }
     }
 
     if (this.proto.usePurpleProxy &&
         this.account.proxyInfo.key != this.proxy.key)
       this.account.proxyInfo = this.proxy;
 
-    for (let opt in this.getProtoOptions()) {
+    for (let opt of this.getProtoOptions()) {
       var name = this.proto.id + "-" + opt.name;
       var val = this.getValue(name);
       switch (opt.type) {
       case Ci.prplIPref.typeBool:
         if (val != opt.getBool())
           this.account.setBool(opt.name, val);
         break;
       case Ci.prplIPref.typeInt:
@@ -208,17 +208,17 @@ var account = {
           this.account.setString(opt.name, val);
         break;
       default:
         throw "unknown preference type " + opt.type;
       }
     }
   },
 
-  getProtoOptions: function account_getProtoOptions() {
+  getProtoOptions: function* account_getProtoOptions() {
     let options = this.proto.getOptions();
     while (options.hasMoreElements()) {
       let opt = options.getNext();
       let returnOpt = {
         get name() { return opt.name; },
         get label() { return opt.label; },
         get type() { return opt.type; },
         get masked() { return opt.masked; },
--- a/im/content/accountWizard.js
+++ b/im/content/accountWizard.js
@@ -135,17 +135,17 @@ var accountWizard = {
 
     let vbox = document.getElementById("userNameBox");
     // remove anything that may be there for another protocol
     let child;
     while (vbox.hasChildNodes())
       vbox.lastChild.remove();
 
     let splits = [];
-    for (let split in this.getProtoUserSplits())
+    for (let split of this.getProtoUserSplits())
       splits.push(split);
 
     let label = bundle.getString("accountUsername");
     this.userNameBoxes = [this.insertUsernameField("name", label, vbox)];
     this.userNameBoxes[0].emptyText = emptyText;
 
     for (let i = 0; i < splits.length; ++i) {
       this.userNameBoxes.push({value: splits[i].separator});
@@ -299,17 +299,17 @@ var accountWizard = {
 /* FIXME
     if (this.proto.newMailNotification)
       rows.appendChild(this.createSummaryRow("Notify of new mails:",
                                              this.getValue("newMailNotification")));
 */
 
     let id = this.proto.id;
     this.prefs = [ ];
-    for (let opt in this.getProtoOptions()) {
+    for (let opt of this.getProtoOptions()) {
       let name = opt.name;
       let eltName = id + "-" + name;
       let val = this.getValue(eltName);
       // The value will be undefined if the proto specific groupbox has never been opened
       if (val === undefined)
         continue;
       switch (opt.type) {
       case opt.typeBool:
@@ -400,17 +400,17 @@ var accountWizard = {
     if ("value" in elt)
       return elt.value;
     // If the groupbox has never been opened, the binding isn't attached
     // so the attributes don't exist. The calling code in showSummary
     // has a special handling of the undefined value for this case.
     return undefined;
   },
 
-  getIter: function(aEnumerator) {
+  getIter: function*(aEnumerator) {
     while (aEnumerator.hasMoreElements())
       yield aEnumerator.getNext();
   },
   getProtocols: function aw_getProtocols() {
     return this.getIter(Services.core.getProtocols());
   },
   getProtoOptions: function aw_getProtoOptions() {
     return this.getIter(this.proto.getOptions());
@@ -499,17 +499,17 @@ var accountWizard = {
 
   showProtocolPage: function() {
     let protoList = document.getElementById("protolist");
     if (protoList.itemCount > 0)
       return;
 
     accountWizard.setGetMoreProtocols();
     let protos = [];
-    for (let proto in accountWizard.getProtocols())
+    for (let proto of accountWizard.getProtocols())
       protos.push(proto);
     protos.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
 
     protos.forEach(function(proto) {
       let item = protoList.appendItem(proto.name, proto.id);
       item.setAttribute("image", proto.iconBaseURI + "icon.png");
       item.setAttribute("class", "listitem-iconic");
     });
--- a/im/content/accounts.js
+++ b/im/content/accounts.js
@@ -30,17 +30,17 @@ var gAccountManager = {
   _disabledDelay: 500,
   disableTimerID: 0,
   _connectedLabelInterval: 0,
   load: function am_load() {
     // Wait until the password service is ready before offering anything.
     Services.logins.initializationPromise.then(() => {
       this.accountList = document.getElementById("accountlist");
       let defaultID;
-      for (let acc in this.getAccounts()) {
+      for (let acc of this.getAccounts()) {
         var elt = document.createElement("richlistitem");
         this.accountList.appendChild(elt);
         elt.build(acc);
         if (!defaultID && acc.firstConnectionState == acc.FIRST_CONNECTION_CRASHED)
           defaultID = acc.id;
       }
       for (let event of events)
         Services.obs.addObserver(this, event, false);
@@ -71,17 +71,17 @@ var gAccountManager = {
   unload: function am_unload() {
     clearInterval(this._connectedLabelInterval);
     for (let event of events)
       Services.obs.removeObserver(this, event);
   },
   _updateAccountList: function am__updateAccountList() {
     let accountList = this.accountList;
     let i = 0;
-    for (let acc in this.getAccounts()) {
+    for (let acc of this.getAccounts()) {
       let oldItem = accountList.getItemAtIndex(i);
       if (oldItem.id != acc.id) {
         let accElt = document.getElementById(acc.id);
         accountList.insertBefore(accElt, oldItem);
         accElt.restoreItems();
       }
       ++i;
     }
@@ -464,33 +464,33 @@ var gAccountManager = {
       newIndex = 0;
     else if (newIndex >= accountList.itemCount)
       newIndex = accountList.itemCount - 1;
     array.splice(newIndex, 0, selectedID);
 
     Services.prefs.setCharPref("messenger.accounts", array.join(","));
   },
 
-  getAccounts: function am_getAccounts() {
+  getAccounts: function* am_getAccounts() {
     let accounts = Services.accounts.getAccounts();
     while (accounts.hasMoreElements())
       yield accounts.getNext();
   },
 
   openDialog: function am_openDialog(aUrl, aArgs) {
     this.modalDialog = true;
     window.openDialog(aUrl, "", "chrome,modal,titlebar,centerscreen", aArgs);
     this.modalDialog = false;
   },
   setAutoLoginNotification: function am_setAutoLoginNotification() {
     var as = Services.accounts;
     var autoLoginStatus = as.autoLoginStatus;
     let isOffline = false;
     let crashCount = 0;
-    for (let acc in this.getAccounts())
+    for (let acc of this.getAccounts())
       if (acc.autoLogin && acc.firstConnectionState == acc.FIRST_CONNECTION_CRASHED)
         ++crashCount;
 
     if (autoLoginStatus == as.AUTOLOGIN_ENABLED && crashCount == 0) {
       let status = Services.core.globalUserStatus.statusType;
       this.setOffline(isOffline || status == Ci.imIStatusInfo.STATUS_OFFLINE);
       return;
     }
@@ -550,17 +550,17 @@ var gAccountManager = {
       ioService.offline = false;
     }
 
     Services.accounts.processAutoLogin();
 
     gAccountManager.accountList.selectedItem.buttons.setFocus();
   },
   processCrashedAccountsLogin: function am_processCrashedAccountsLogin() {
-    for (let acc in gAccountManager.getAccounts())
+    for (let acc of gAccountManager.getAccounts())
       if (acc.disconnected && acc.autoLogin &&
           acc.firstConnectionState == acc.FIRST_CONNECTION_CRASHED)
         acc.connect();
 
     let notification = document.getElementById("accountsNotificationBox")
                                .getNotificationWithValue("autoLoginStatus");
     if (notification)
       notification.close();
--- a/im/content/addbuddy.js
+++ b/im/content/addbuddy.js
@@ -6,17 +6,17 @@
 var addBuddy = {
   onload: function ab_onload() {
     this.buildAccountList();
     this.buildTagList();
   },
 
   buildAccountList: function ab_buildAccountList() {
     var accountList = document.getElementById("accountlist");
-    for (let acc in getIter(Services.accounts.getAccounts())) {
+    for (let acc of getIter(Services.accounts.getAccounts())) {
       if (!acc.connected)
         continue;
       var proto = acc.protocol;
       var item = accountList.appendItem(acc.name, acc.id, proto.name);
       item.setAttribute("image", proto.iconBaseURI + "icon.png");
       item.setAttribute("class", "menuitem-iconic");
     }
     if (!accountList.itemCount) {
--- a/im/content/debug/debug.js
+++ b/im/content/debug/debug.js
@@ -40,19 +40,19 @@ var debug = {
   }
 };
 
 window.addEventListener("load", debug.load);
 
 function debug_enumerateProtocols()
 {
   dump("trying to enumerate protocols:\n");
-  for (let proto in getIter(Services.core.getProtocols())) {
+  for (let proto of getIter(Services.core.getProtocols())) {
     dump(" " + proto.name + " " + proto.id + "\n");
-    for (let opt in getIter(proto.getOptions())) {
+    for (let opt of getIter(proto.getOptions())) {
       var type = { };
       type[opt.typeBool] = ["bool", opt.getBool];
       type[opt.typeInt] = ["int", opt.getInt];
       type[opt.typeString] = ["string", opt.getString];
       dump("  ("+ type[opt.type][0] + ") "  +
            opt.name + (opt.masked ? "(masked)" : "") + "\t" +
            type[opt.type][1]() + "\n");
     }
--- a/im/content/debug/fake/fake.js
+++ b/im/content/debug/fake/fake.js
@@ -316,17 +316,17 @@ var fake = {
       return;
 
     var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
                             .getService(Components.interfaces.nsIPromptService);
     if (!prompts.confirm(window, "Are you sure you want to delete all accounts?",
                          "You are about to delete your accounts. Are you sure?"))
       throw "user aborted the operation";
 
-    for (let acc in getIter(Services.accounts.getAccounts()))
+    for (let acc of getIter(Services.accounts.getAccounts()))
       Services.accounts.deleteAccount(acc.id);
   }
 };
 
 this.addEventListener("load", fake.load);
 
 var gLastAccountId = 0;
 function Account(aName, aProto)
--- a/im/content/joinchat.js
+++ b/im/content/joinchat.js
@@ -4,17 +4,17 @@
 
 Components.utils.import("resource:///modules/imWindows.jsm");
 
 var autoJoinPref = "autoJoin";
 
 var joinChat = {
   onload: function jc_onload() {
     var accountList = document.getElementById("accountlist");
-    for (let acc in getIter(Services.accounts.getAccounts())) {
+    for (let acc of getIter(Services.accounts.getAccounts())) {
       if (!acc.connected || !acc.canJoinChat)
         continue;
       var proto = acc.protocol;
       var item = accountList.appendItem(acc.name, acc.id, proto.name);
       item.setAttribute("image", proto.iconBaseURI + "icon.png");
       item.setAttribute("class", "menuitem-iconic");
       item.account = acc;
     }
@@ -37,17 +37,17 @@ var joinChat = {
     joinChat._fields = [];
     joinChat._account = acc;
 
     let protoId = acc.protocol.id;
     document.getElementById("autojoin").hidden =
       !(protoId == "prpl-irc" || protoId == "prpl-jabber" ||
       protoId == "prpl-gtalk");
 
-    for (let field in getIter(acc.getChatRoomFields())) {
+    for (let field of getIter(acc.getChatRoomFields())) {
       let row = document.createElement("row");
 
       let label = document.createElement("label");
       let text = field.label;
       let match = /_(.)/.exec(text);
       if (match) {
         label.setAttribute("accesskey", match[1]);
         text = text.replace(/_/, "");
--- a/im/content/proxies.js
+++ b/im/content/proxies.js
@@ -47,17 +47,17 @@ var gProxies = {
     var envproxy = environment.get("HTTP_PROXY") ||
                    environment.get("http_proxy") ||
                    environment.get("HTTPPROXY");
     if (envproxy)
       document.getElementById("envProxy").textContent = envproxy;
 
     var proxies = getIter(pcs.getProxies());
     var proxyList = document.getElementById("proxylist");
-    for (let proxy in proxies) {
+    for (let proxy of proxies) {
       let item = document.createElement("richlistitem");
       item.setAttribute("proxy", "true");
       proxyList.insertBefore(item, document.getElementById("newProxy"));
       item.proxy = proxy;
     }
 
     var key = null;
     if (!account)
@@ -134,17 +134,17 @@ var gProxies = {
       if (!host || !port) {
         promptService.alert(window, bundle.getString("proxies.alert.invalidInput.title"),
                             bundle.getString("proxies.alert.invalidInput.message"));
         return false;
       }
       var user = this.getValue("username");
       var pass = this.getValue("password");
       var proxies = getIter(pcs.getProxies());
-      for (let proxy in proxies) {
+      for (let proxy of proxies) {
         if (proxy.type == type && proxy.port == port &&
             proxy.host == host && proxy.username == user) {
           if (proxy.password == pass) {
             item.proxy = proxy;
           }
           else {
             if (promptService.confirm(window, bundle.getString("proxies.confirm.passwordUpdate.title"),
                                       bundle.getString("proxies.confirm.passwordUpdate.message"))) {
--- a/im/content/utilities.js
+++ b/im/content/utilities.js
@@ -1,13 +1,13 @@
 /* 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/. */
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 Components.utils.import("resource:///modules/imServices.jsm");
 
-function getIter(aEnumerator)
+function* getIter(aEnumerator)
 {
   while (aEnumerator.hasMoreElements())
     yield aEnumerator.getNext();
 }
--- a/im/modules/ibCore.jsm
+++ b/im/modules/ibCore.jsm
@@ -222,17 +222,17 @@ var Core = {
     // Try to show the debug logs in win, and open a new window if it didn't work.
     if (showPanel(win))
       return;
     win = Services.ww.openWindow(null, "chrome://instantbird/content/instantbird.xul",
                                  "_blank", "chrome,toolbar,resizable", null);
     win.addEventListener("load", showPanel.bind(null, win));
   },
 
-  getIter: function(aEnumerator) {
+  getIter: function*(aEnumerator) {
     while (aEnumerator.hasMoreElements())
       yield aEnumerator.getNext();
   },
   getAccounts: function() { return this.getIter(Services.accounts.getAccounts()); },
 
   /* This function pops up the account manager if no account is
    * connected or connecting.
    * When called during startup (aIsStarting == true), it will also