Bug 1111771 - Move all unnamed eval sources to bottom of the source listing in the debugger. r=victorporof, a=sledru
authorJames Long <longster@gmail.com>
Fri, 16 Jan 2015 14:21:00 -0500
changeset 243589 347c33a663de
parent 243588 5e118e867ccf
child 243590 78a8db05e964
push id4406
push userryanvm@gmail.com
push date2015-01-29 21:23 +0000
treeherdermozilla-beta@cf270a9a66ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvictorporof, sledru
bugs1111771
milestone36.0
Bug 1111771 - Move all unnamed eval sources to bottom of the source listing in the debugger. r=victorporof, a=sledru
browser/devtools/debugger/debugger-panes.js
browser/devtools/debugger/test/browser_dbg_sources-eval-01.js
browser/devtools/debugger/test/browser_dbg_sources-eval-02.js
--- a/browser/devtools/debugger/debugger-panes.js
+++ b/browser/devtools/debugger/debugger-panes.js
@@ -5,21 +5,24 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 // Used to detect minification for automatic pretty printing
 const SAMPLE_SIZE = 50; // no of lines
 const INDENT_COUNT_THRESHOLD = 5; // percentage
 const CHARACTER_LIMIT = 250; // line character limit
 
-// Maps known URLs to friendly source group names
+// Maps known URLs to friendly source group names and put them at the
+// bottom of source list.
 const KNOWN_SOURCE_GROUPS = {
   "Add-on SDK": "resource://gre/modules/commonjs/",
 };
 
+KNOWN_SOURCE_GROUPS['evals'] = "eval";
+
 /**
  * Functions handling the sources UI.
  */
 function SourcesView() {
   dumpn("SourcesView was instantiated");
 
   this.togglePrettyPrint = this.togglePrettyPrint.bind(this);
   this.toggleBlackBoxing = this.toggleBlackBoxing.bind(this);
@@ -165,24 +168,32 @@ SourcesView.prototype = Heritage.extend(
       }
     });
   },
 
   _parseUrl: function(aSource) {
     let fullUrl = aSource.url || aSource.introductionUrl;
     let url = fullUrl.split(" -> ").pop();
     let label = aSource.addonPath ? aSource.addonPath : SourceUtils.getSourceLabel(url);
+    let group;
 
     if (!aSource.url && aSource.introductionUrl) {
-      label += ' > eval';
+      label += ' > ' + aSource.introductionType;
+      group = 'evals';
+    }
+    else if(aSource.addonID) {
+      group = aSource.addonID;
+    }
+    else {
+      group = SourceUtils.getSourceGroup(url);
     }
 
     return {
       label: label,
-      group: aSource.addonID ? aSource.addonID : SourceUtils.getSourceGroup(url),
+      group: group,
       unicodeUrl: NetworkHelper.convertToUnicode(unescape(fullUrl))
     };
   },
 
   /**
    * Adds a breakpoint to this sources container.
    *
    * @param object aBreakpointClient
--- a/browser/devtools/debugger/test/browser_dbg_sources-eval-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_sources-eval-01.js
@@ -23,12 +23,17 @@ function test() {
       is(gSources.values.length, 1, "Should have 1 source");
 
       let newSource = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.NEW_SOURCE);
       callInTab(gTab, "evalSource");
       yield newSource;
 
       is(gSources.values.length, 2, "Should have 2 sources");
 
+      let item = gSources.getItemForAttachment(e => e.label.indexOf("> eval") !== -1);
+      ok(item, "Source label is incorrect.");
+      is(item.attachment.group, 'evals',
+         'Source group is incorrect');
+
       yield closeDebuggerAndFinish(gPanel);
     });
   });
 }
--- a/browser/devtools/debugger/test/browser_dbg_sources-eval-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_sources-eval-02.js
@@ -27,17 +27,18 @@ function test() {
       let newSource = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.NEW_SOURCE);
       callInTab(gTab, "evalSourceWithSourceURL");
       yield newSource;
 
       is(gSources.values.length, 2, "Should have 2 sources");
 
       let item = gSources.getItemForAttachment(e => e.label == "bar.js");
       ok(item, "Source label is incorrect.");
-      ok(item.attachment.group === 'http://example.com', 'Source group is incorrect');
+      is(item.attachment.group, 'http://example.com',
+         'Source group is incorrect');
 
       let shown = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN);
       gSources.selectedItem = item;
       yield shown;
 
       ok(gEditor.getText().indexOf('bar = function() {') === 0,
          'Correct source is shown');