Bug 862849 - Remove __iterator__ use from the devtools. r=vp
☠☠ backed out by 1bab2224b51a ☠ ☠
authorBrandon Benvie <bbenvie@mozilla.com>
Fri, 18 Oct 2013 12:28:40 -0700
changeset 166576 69ebfb936442e2c08c41b281d7a8eb65f0210c9c
parent 166575 987ac1967cbeff0b1cc205287e8175062cc59e7c
child 166577 b185e2dd95d49dc60a82173b173726c198de78f6
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvp
bugs862849
milestone27.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 862849 - Remove __iterator__ use from the devtools. r=vp
browser/devtools/debugger/CmdDebugger.jsm
browser/devtools/debugger/debugger-panes.js
browser/devtools/debugger/debugger-toolbar.js
browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js
browser/devtools/netmonitor/netmonitor-view.js
browser/devtools/scratchpad/test/browser_scratchpad_inspect.js
browser/devtools/shared/widgets/VariablesView.jsm
browser/devtools/shared/widgets/ViewHelpers.jsm
browser/devtools/webconsole/test/head.js
--- a/browser/devtools/debugger/CmdDebugger.jsm
+++ b/browser/devtools/debugger/CmdDebugger.jsm
@@ -32,18 +32,18 @@ XPCOMUtils.defineLazyModuleGetter(this, 
  *           - lineText: the text of the line at the breakpoint.
  *           - truncatedLineText: lineText truncated to MAX_LINE_TEXT_LENGTH.
  */
 function getAllBreakpoints(dbg) {
   let breakpoints = [];
   let sources = dbg._view.Sources;
   let { trimUrlLength: trim } = dbg.panelWin.SourceUtils;
 
-  for (let source in sources) {
-    for (let { attachment: breakpoint } in source) {
+  for (let source of sources) {
+    for (let { attachment: breakpoint } of source) {
       breakpoints.push({
         url: source.value,
         label: source.label + ":" + breakpoint.line,
         lineNumber: breakpoint.line,
         lineText: breakpoint.text,
         truncatedLineText: trim(breakpoint.text, MAX_LINE_TEXT_LENGTH, "end")
       });
     }
--- a/browser/devtools/debugger/debugger-panes.js
+++ b/browser/devtools/debugger/debugger-panes.js
@@ -227,18 +227,18 @@ SourcesView.prototype = Heritage.extend(
    * @param object aLocation [optional]
    *        @see DebuggerController.Breakpoints.addBreakpoint
    * @param array aStore [optional]
    *        A list in which to store the corresponding breakpoints.
    * @return array
    *         The corresponding breakpoints if found, an empty array otherwise.
    */
   getOtherBreakpoints: function(aLocation = {}, aStore = []) {
-    for (let source in this) {
-      for (let breakpointItem in source) {
+    for (let source of this) {
+      for (let breakpointItem of source) {
         let { url, line } = breakpointItem.attachment;
         if (url != aLocation.url || line != aLocation.line) {
           aStore.push(breakpointItem);
         }
       }
     }
     return aStore;
   },
@@ -1364,17 +1364,17 @@ WatchExpressionsView.prototype = Heritag
    *
    * @param Variable aVar
    *        The variable representing the watch expression evaluation.
    * @param string aExpression
    *        The new watch expression text.
    */
   switchExpression: function(aVar, aExpression) {
     let expressionItem =
-      [i for (i in this) if (i.attachment.currentExpression == aVar.name)][0];
+      [i for (i of this) if (i.attachment.currentExpression == aVar.name)][0];
 
     // Remove the watch expression if it's going to be empty or a duplicate.
     if (!aExpression || this.getAllStrings().indexOf(aExpression) != -1) {
       this.deleteExpression(aVar);
       return;
     }
 
     // Save the watch expression code string.
@@ -1390,17 +1390,17 @@ WatchExpressionsView.prototype = Heritag
    * This function is called whenever a watch expression's value is edited in
    * the variables view container.
    *
    * @param Variable aVar
    *        The variable representing the watch expression evaluation.
    */
   deleteExpression: function(aVar) {
     let expressionItem =
-      [i for (i in this) if (i.attachment.currentExpression == aVar.name)][0];
+      [i for (i of this) if (i.attachment.currentExpression == aVar.name)][0];
 
     // Remove the watch expression.
     this.remove(expressionItem);
 
     // Synchronize with the controller's watch expressions store.
     DebuggerController.StackFrames.syncWatchExpressions();
   },
 
@@ -2022,17 +2022,17 @@ GlobalSearchView.prototype = Heritage.ex
    * Creates global search results entries and adds them to this container.
    *
    * @param GlobalResults aGlobalResults
    *        An object containing all source results, grouped by source location.
    */
   _createGlobalResultsUI: function(aGlobalResults) {
     let i = 0;
 
-    for (let sourceResults in aGlobalResults) {
+    for (let sourceResults of aGlobalResults) {
       if (i++ == 0) {
         this._createSourceResultsUI(sourceResults);
       } else {
         // Dispatch subsequent document manipulation operations, to avoid
         // blocking the main thread when a large number of search results
         // is found, thus giving the impression of faster searching.
         Services.tm.currentThread.dispatch({ run:
           this._createSourceResultsUI.bind(this, sourceResults)
@@ -2147,17 +2147,17 @@ GlobalSearchView.prototype = Heritage.ex
 
   _splitter: null,
   _currentlyFocusedMatch: -1,
   _forceExpandResults: false
 });
 
 /**
  * An object containing all source results, grouped by source location.
- * Iterable via "for (let [location, sourceResults] in globalResults) { }".
+ * Iterable via "for (let [location, sourceResults] of globalResults) { }".
  */
 function GlobalResults() {
   this._store = [];
   SourceResults._itemsByElement = new Map();
   LineResults._itemsByElement = new Map();
 }
 
 GlobalResults.prototype = {
@@ -2174,17 +2174,17 @@ GlobalResults.prototype = {
   /**
    * Gets the number of source results in this store.
    */
   get matchCount() this._store.length
 };
 
 /**
  * An object containing all the matched lines for a specific source.
- * Iterable via "for (let [lineNumber, lineResults] in sourceResults) { }".
+ * Iterable via "for (let [lineNumber, lineResults] of sourceResults) { }".
  *
  * @param string aUrl
  *        The target source url.
  * @param GlobalResults aGlobalResults
  *        An object containing all source results, grouped by source location.
  */
 function SourceResults(aUrl, aGlobalResults) {
   this.url = aUrl;
@@ -2315,17 +2315,17 @@ SourceResults.prototype = {
   _target: null,
   _arrow: null,
   _resultsHeader: null,
   _resultsContainer: null
 };
 
 /**
  * An object containing all the matches for a specific line.
- * Iterable via "for (let chunk in lineResults) { }".
+ * Iterable via "for (let chunk of lineResults) { }".
  *
  * @param number aLine
  *        The target line in the source.
  * @param SourceResults aSourceResults
  *        An object containing all the matched lines for a specific source.
  */
 function LineResults(aLine, aSourceResults) {
   this.line = aLine;
@@ -2460,19 +2460,19 @@ LineResults.prototype = {
   _sourceResults: null,
   _store: null,
   _target: null
 };
 
 /**
  * A generator-iterator over the global, source or line results.
  */
-GlobalResults.prototype.__iterator__ =
-SourceResults.prototype.__iterator__ =
-LineResults.prototype.__iterator__ = function() {
+GlobalResults.prototype.iterator =
+SourceResults.prototype.iterator =
+LineResults.prototype.iterator = function() {
   for (let item of this._store) {
     yield item;
   }
 };
 
 /**
  * Gets the item associated with the specified element.
  *
--- a/browser/devtools/debugger/debugger-toolbar.js
+++ b/browser/devtools/debugger/debugger-toolbar.js
@@ -610,17 +610,17 @@ StackFramesView.prototype = Heritage.ext
   _onSelect: function(e) {
     let stackframeItem = this.selectedItem;
     if (stackframeItem) {
       // The container is not empty and an actual item was selected.
       DebuggerController.StackFrames.selectFrame(stackframeItem.attachment.depth);
 
       // Update the context menu to show the currently selected stackframe item
       // as a checked entry.
-      for (let otherItem in this) {
+      for (let otherItem of this) {
         if (otherItem != stackframeItem) {
           otherItem.attachment.popup.menuitem.removeAttribute("checked");
         } else {
           otherItem.attachment.popup.menuitem.setAttribute("checked", "");
         }
       }
     }
   },
--- a/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js
+++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js
@@ -102,18 +102,18 @@ function test() {
         gDebuggee.document.querySelector("button"),
         gDebuggee);
     });
 
     return finished;
   }
 
   function initialChecks() {
-    for (let source in gSources) {
-      for (let breakpoint in source) {
+    for (let source of gSources) {
+      for (let breakpoint of source) {
         ok(gBreakpoints._getAdded(breakpoint.attachment),
           "All breakpoint items should have corresponding promises (1).");
         ok(!gBreakpoints._getRemoving(breakpoint.attachment),
           "All breakpoint items should have corresponding promises (2).");
         ok(breakpoint.attachment.actor,
           "All breakpoint items should have corresponding promises (3).");
         is(!!breakpoint.attachment.disabled, false,
           "All breakpoints should initially be enabled.");
@@ -218,50 +218,50 @@ function test() {
         "There should be a breakpoint client available (6).");
       ok(!gBreakpoints._getRemoving(selectedBreakpoint.attachment),
         "There should be a breakpoint client available (7).");
       ok(selectedBreakpoint.attachment.actor,
         "There should be a breakpoint client available (8).");
       is(!!selectedBreakpoint.attachment.disabled, false,
         "The targetted breakpoint should not have been disabled (" + aIndex + ").");
 
-      for (let source in gSources) {
-        for (let otherBreakpoint in source) {
+      for (let source of gSources) {
+        for (let otherBreakpoint of source) {
           if (otherBreakpoint != selectedBreakpoint) {
             ok(!gBreakpoints._getAdded(otherBreakpoint.attachment),
               "There should be no breakpoint client for a disabled breakpoint (9).");
             is(otherBreakpoint.attachment.disabled, true,
               "Non-targetted breakpoints should have been disabled (10).");
           }
         }
       }
 
       waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 4).then(() => {
-        for (let source in gSources) {
-          for (let someBreakpoint in source) {
+        for (let source of gSources) {
+          for (let someBreakpoint of source) {
             ok(gBreakpoints._getAdded(someBreakpoint.attachment),
               "There should be a breakpoint client for all enabled breakpoints (11).");
             is(someBreakpoint.attachment.disabled, false,
               "All breakpoints should now have been enabled (12).");
           }
         }
 
         waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 5).then(() => {
-          for (let source in gSources) {
-            for (let someBreakpoint in source) {
+          for (let source of gSources) {
+            for (let someBreakpoint of source) {
               ok(!gBreakpoints._getAdded(someBreakpoint.attachment),
                 "There should be no breakpoint client for a disabled breakpoint (13).");
               is(someBreakpoint.attachment.disabled, true,
                 "All breakpoints should now have been disabled (14).");
             }
           }
 
           waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 5).then(() => {
-            for (let source in gSources) {
-              for (let someBreakpoint in source) {
+            for (let source of gSources) {
+              for (let someBreakpoint of source) {
                 ok(gBreakpoints._getAdded(someBreakpoint.attachment),
                   "There should be a breakpoint client for all enabled breakpoints (15).");
                 is(someBreakpoint.attachment.disabled, false,
                   "All breakpoints should now have been enabled (16).");
               }
             }
 
             // Done.
@@ -288,18 +288,18 @@ function test() {
 
   function testDeleteAll() {
     let deferred = promise.defer();
 
     waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 5).then(() => {
       ok(!gSources._selectedBreakpointItem,
         "There should be no breakpoint available after removing all breakpoints.");
 
-      for (let source in gSources) {
-        for (let otherBreakpoint in source) {
+      for (let source of gSources) {
+        for (let otherBreakpoint of source) {
           ok(false, "It's a trap!");
         }
       }
 
       // Done.
       deferred.resolve()
     });
 
--- a/browser/devtools/netmonitor/netmonitor-view.js
+++ b/browser/devtools/netmonitor/netmonitor-view.js
@@ -1002,17 +1002,17 @@ RequestsMenuView.prototype = Heritage.ex
 
     // Redraw and set the canvas background for each waterfall view.
     this._showWaterfallDivisionLabels(scale);
     this._drawWaterfallBackground(scale);
     this._flushWaterfallBackgrounds();
 
     // Apply CSS transforms to each waterfall in this container totalTime
     // accurately translate and resize as needed.
-    for (let { target, attachment } in this) {
+    for (let { target, attachment } of this) {
       let timingsNode = $(".requests-menu-timings", target);
       let startCapNode = $(".requests-menu-timings-cap.start", target);
       let endCapNode = $(".requests-menu-timings-cap.end", target);
       let totalNode = $(".requests-menu-timings-total", target);
       let direction = window.isRTL ? -1 : 1;
 
       // Render the timing information at a specific horizontal translation
       // based on the delta to the first monitored event network.
@@ -1138,17 +1138,17 @@ RequestsMenuView.prototype = Heritage.ex
     ctx.putImageData(imageData, 0, 0);
     this._cachedWaterfallBackground = "url(" + canvas.toDataURL() + ")";
   },
 
   /**
    * Reapplies the current waterfall background on all request items.
    */
   _flushWaterfallBackgrounds: function() {
-    for (let { target } in this) {
+    for (let { target } of this) {
       let waterfallNode = $(".requests-menu-waterfall", target);
       waterfallNode.style.backgroundImage = this._cachedWaterfallBackground;
     }
   },
 
   /**
    * Hides the overflowing columns in the requests table.
    */
--- a/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js
+++ b/browser/devtools/scratchpad/test/browser_scratchpad_inspect.js
@@ -23,19 +23,19 @@ function runTests()
 
   sp.inspect().then(function() {
     let sidebar = sp.sidebar;
     ok(sidebar.visible, "sidebar is open");
 
 
     let found = false;
 
-    outer: for (let scope in sidebar.variablesView) {
-      for (let [, obj] in scope) {
-        for (let [, prop] in obj) {
+    outer: for (let scope of sidebar.variablesView) {
+      for (let [, obj] of scope) {
+        for (let [, prop] of obj) {
           if (prop.name == "a" && prop.value == "foobarBug636725") {
             found = true;
             break outer;
           }
         }
       }
     }
 
--- a/browser/devtools/shared/widgets/VariablesView.jsm
+++ b/browser/devtools/shared/widgets/VariablesView.jsm
@@ -50,17 +50,17 @@ this.EXPORTED_SYMBOLS = ["VariablesView"
 
 /**
  * Debugger localization strings.
  */
 const STR = Services.strings.createBundle(DBG_STRINGS_URI);
 
 /**
  * A tree view for inspecting scopes, objects and properties.
- * Iterable via "for (let [id, scope] in instance) { }".
+ * Iterable via "for (let [id, scope] of instance) { }".
  * Requires the devtools common.css and debugger.css skin stylesheets.
  *
  * To allow replacing variable or property values in this view, provide an
  * "eval" function property. To allow replacing variable or property names,
  * provide a "switch" function. To handle deleting variables or properties,
  * provide a "delete" function.
  *
  * @param nsIDOMNode aParentNode
@@ -1087,17 +1087,17 @@ VariablesView.getterOrSetterDeleteCallba
   aItem.ownerView.eval(aItem.evaluationMacro(aItem, ""));
 
   return true; // Don't hide the element.
 };
 
 
 /**
  * A Scope is an object holding Variable instances.
- * Iterable via "for (let [name, variable] in instance) { }".
+ * Iterable via "for (let [name, variable] of instance) { }".
  *
  * @param VariablesView aView
  *        The view to contain this scope.
  * @param string aName
  *        The scope's name.
  * @param object aFlags [optional]
  *        Additional options or flags for this scope.
  */
@@ -2037,17 +2037,17 @@ Scope.prototype = {
 // these are instantiated only if needed.
 DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_store", Map);
 DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_enumItems", Array);
 DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_nonEnumItems", Array);
 DevToolsUtils.defineLazyPrototypeGetter(Scope.prototype, "_batchItems", Array);
 
 /**
  * A Variable is a Scope holding Property instances.
- * Iterable via "for (let [name, property] in instance) { }".
+ * Iterable via "for (let [name, property] of instance) { }".
  *
  * @param Scope aScope
  *        The scope to contain this variable.
  * @param string aName
  *        The variable's name.
  * @param object aDescriptor
  *        The variable's descriptor.
  */
@@ -2821,17 +2821,17 @@ Variable.prototype = Heritage.extend(Sco
   _valueString: "",
   _valueClassName: "",
   _prevExpandable: false,
   _prevExpanded: false
 });
 
 /**
  * A Property is a Variable holding additional child Property instances.
- * Iterable via "for (let [name, property] in instance) { }".
+ * Iterable via "for (let [name, property] of instance) { }".
  *
  * @param Variable aVar
  *        The variable to contain this property.
  * @param string aName
  *        The property's name.
  * @param object aDescriptor
  *        The property's descriptor.
  */
@@ -2882,20 +2882,20 @@ Property.prototype = Heritage.extend(Var
       this.ownerView._nonEnumItems.push(this);
     }
   }
 });
 
 /**
  * A generator-iterator over the VariablesView, Scopes, Variables and Properties.
  */
-VariablesView.prototype.__iterator__ =
-Scope.prototype.__iterator__ =
-Variable.prototype.__iterator__ =
-Property.prototype.__iterator__ = function() {
+VariablesView.prototype.iterator =
+Scope.prototype.iterator =
+Variable.prototype.iterator =
+Property.prototype.iterator = function() {
   for (let item of this._store) {
     yield item;
   }
 };
 
 /**
  * Forget everything recorded about added scopes, variables or properties.
  * @see VariablesView.createHierarchy
--- a/browser/devtools/shared/widgets/ViewHelpers.jsm
+++ b/browser/devtools/shared/widgets/ViewHelpers.jsm
@@ -400,17 +400,17 @@ ViewHelpers.Prefs.prototype = {
       set: (aValue) => this._set(aType, [this.root, aPrefName].join("."), aValue)
     });
   }
 };
 
 /**
  * A generic Item is used to describe children present in a Widget.
  * The label, value and description properties are necessarily strings.
- * Iterable via "for (let childItem in parentItem) { }".
+ * Iterable via "for (let childItem of parentItem) { }".
  *
  * @param object aOwnerView
  *        The owner view creating this item.
  * @param any aAttachment
  *        Some attached primitive/object.
  * @param nsIDOMNode | nsIDOMDocumentFragment | array aContents [optional]
  *        A prebuilt node, or an array containing the following properties:
  *        - aLabel: the label displayed in the widget
@@ -508,17 +508,17 @@ Item.prototype = {
    *
    * @param Item aItem
    *        The item describing a target element.
    */
   _untangleItem: function(aItem) {
     if (aItem.finalize) {
       aItem.finalize(aItem);
     }
-    for (let childItem in aItem) {
+    for (let childItem of aItem) {
       aItem.remove(childItem);
     }
 
     this._unlinkItem(aItem);
     aItem._prebuiltTarget = null;
     aItem._target = null;
   },
 
@@ -552,17 +552,17 @@ Item.prototype = {
   _prebuiltTarget: null,
   _target: null,
   finalize: null,
   attachment: null
 };
 
 /**
  * Some generic Widget methods handling Item instances.
- * Iterable via "for (let childItem in wrappedView) { }".
+ * Iterable via "for (let childItem of wrappedView) { }".
  *
  * Usage:
  *   function MyView() {
  *     this.widget = new MyWidget(document.querySelector(".my-node"));
  *   }
  *
  *   MyView.prototype = Heritage.extend(WidgetMethods, {
  *     myMethod: function() {},
@@ -1512,17 +1512,17 @@ this.WidgetMethods = {
    *
    * @param Item aItem
    *        The item describing a target element.
    */
   _untangleItem: function(aItem) {
     if (aItem.finalize) {
       aItem.finalize(aItem);
     }
-    for (let childItem in aItem) {
+    for (let childItem of aItem) {
       aItem.remove(childItem);
     }
 
     this._unlinkItem(aItem);
     aItem._prebuiltTarget = null;
     aItem._target = null;
   },
 
@@ -1637,14 +1637,14 @@ this.WidgetMethods = {
   _widget: null,
   _preferredValue: null,
   _cachedCommandDispatcher: null
 };
 
 /**
  * A generator-iterator over all the items in this container.
  */
-Item.prototype.__iterator__ =
-WidgetMethods.__iterator__ = function() {
+Item.prototype.iterator =
+WidgetMethods.iterator = function() {
   for (let [, item] of this._itemsByElement) {
     yield item;
   }
 };
--- a/browser/devtools/webconsole/test/head.js
+++ b/browser/devtools/webconsole/test/head.js
@@ -442,17 +442,17 @@ function findVariableViewProperties(aVie
   {
     if (aMatched && !aRule.matchedProp) {
       aRule.matchedProp = aProp;
     }
   }
 
   function finder(aRules, aVar, aPromises)
   {
-    for (let [id, prop] in aVar) {
+    for (let [id, prop] of aVar) {
       for (let rule of aRules) {
         let matcher = matchVariablesViewProperty(prop, rule, aOptions);
         aPromises.push(matcher.then(onMatch.bind(null, prop, rule)));
       }
     }
   }
 
   function processExpandRules(aRules)