Bug 796179 - Don't store full source URI in an attribute in the error console, and display it in abbreviated form to the user. r=rcampbell r=Neil
authorSeth Fowler <seth@mozilla.com>
Mon, 12 Nov 2012 11:50:03 -0800
changeset 113007 a557ce61d622e955d3a0981661b3bd57859cd25a
parent 113006 d8fed46ba90d78fb9d27d2a45292f43b93fdc93b
child 113008 fc53121e1685eb9dfd07197c12cd3c22be52c15d
push id23847
push userphilringnalda@gmail.com
push dateTue, 13 Nov 2012 05:07:25 +0000
treeherdermozilla-central@1b0226622e94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrcampbell, Neil
bugs796179
milestone19.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 796179 - Don't store full source URI in an attribute in the error console, and display it in abbreviated form to the user. r=rcampbell r=Neil
toolkit/components/console/content/consoleBindings.xml
--- a/toolkit/components/console/content/consoleBindings.xml
+++ b/toolkit/components/console/content/consoleBindings.xml
@@ -18,16 +18,22 @@
         <xul:vbox class="console-rows" role="console-rows" xbl:inherits="dir=sortOrder"/>
       </xul:vbox>
     </content>
   
     <implementation>
       <field name="limit" readonly="true">
         250
       </field>
+
+      <field name="hrefMaxLength" readonly="true">
+        <!-- Limit displayed script error source URL to avoid performance issues. (Bug 796179) -->
+        200
+      </field>
+
       <field name="_showChromeErrors">-1</field>
 
       <property name="showChromeErrors">
         <getter><![CDATA[
           if (this._showChromeErrors != -1)
             return this._showChromeErrors;
 
           try {
@@ -187,25 +193,30 @@
       <method name="appendError">
         <parameter name="aObject"/>
         <body><![CDATA[
           var row = this.createConsoleRow();
           var nsIScriptError = Components.interfaces.nsIScriptError;
           
           // Is this error actually just a non-fatal warning?
           var warning = aObject.flags & nsIScriptError.warningFlag != 0;
-  
+
           var typetext = warning ? "typeWarning" : "typeError";
           row.setAttribute("typetext", this.mStrBundle.getString(typetext));
           row.setAttribute("type", warning ? "warning" : "error");
           row.setAttribute("msg", aObject.errorMessage);
           row.setAttribute("category", aObject.category);
           row.setAttribute("time", this.properFormatTime(aObject.timeStamp));
           if (aObject.lineNumber || aObject.sourceName) {
-            row.setAttribute("href", aObject.sourceName);
+            if (aObject.sourceName.length <= this.hrefMaxLength) {
+              row.setAttribute("href", aObject.sourceName);
+            } else {
+              row.setAttribute("href", aObject.sourceName.substring(0, this.hrefMaxLength) + '…');
+            }
+            row.mSourceName = aObject.sourceName;
             row.setAttribute("line", aObject.lineNumber);
           } else {
             row.setAttribute("hideSource", "true");
           }
           if (aObject.sourceLine) {
             row.setAttribute("code", aObject.sourceLine.replace(/\s/g, " "));
             if (aObject.columnNumber) {
               row.setAttribute("col", aObject.columnNumber);
@@ -305,20 +316,21 @@
           this.mConsoleRowBox = newRows;
           this.selectedItem = null;
         ]]></body>
       </method>
 
       <method name="filterElement">
         <parameter name="aRow" />
         <body><![CDATA[
-          let anyMatch = ["msg", "href", "line", "code"].some(function (key) {
-            return (aRow.hasAttribute(key) && 
+          let anyMatch = ["msg", "line", "code"].some(function (key) {
+            return (aRow.hasAttribute(key) &&
                     this.stringMatchesFilters(aRow.getAttribute(key), this.mFilter));
-          }, this);
+          }, this) || (aRow.mSourceName &&
+                       this.stringMatchesFilters(aRow.mSourceName, this.mFilter));
 
           if (anyMatch) {
             aRow.classList.remove("filtered-by-string")
           } else {
             aRow.classList.add("filtered-by-string")
           }
         ]]></body>
       </method>
@@ -439,29 +451,31 @@
               <xul:spacer flex="1"/>
             </xul:box>
           </xul:vbox>
         </xul:vbox>
       </xul:box>
     </content>
 
     <implementation>
+      <field name="mSourceName">null</field>
+
       <method name="toString">
         <body><![CDATA[
           let msg = "";
           let strBundle = this._ConsoleBox.mStrBundle;
 
           if (this.hasAttribute("time"))
             msg += strBundle.getFormattedString("errTime", [this.getAttribute("time")]) + "\n";
 
           msg += this.getAttribute("typetext") + " " + this.getAttribute("msg");
 
-          if (this.hasAttribute("line") && this.hasAttribute("href")) {
+          if (this.hasAttribute("line") && this.mSourceName) {
             msg += "\n" + strBundle.getFormattedString("errFile",
-                                        [this.getAttribute("href")]) + "\n";
+                                        [this.mSourceName]) + "\n";
             if (this.hasAttribute("col")) {
               msg += strBundle.getFormattedString("errLineCol",
                          [this.getAttribute("line"), this.getAttribute("col")]);
             } else
               msg += strBundle.getFormattedString("errLine", [this.getAttribute("line")]);
           }
 
           if (this.hasAttribute("code"))
@@ -494,23 +508,23 @@
           return this.getAttribute("msg");
         ]]></body>
       </method>
     </implementation>
   </binding>
 
   <binding id="console-error-source" extends="xul:box">
     <content>
-      <xul:label class="text-link" xbl:inherits="href,value=href" crop="right"/>
+      <xul:label class="text-link" xbl:inherits="value=href" crop="right"/>
     </content>
 
     <handlers>
       <handler event="click" phase="capturing" button="0" preventdefault="true">
         <![CDATA[
-          var url = this.getAttribute("href");
+          var url = document.getBindingParent(this).mSourceName;
           url = url.substring(url.lastIndexOf(" ") + 1);
           var line = getAttribute("line");
           gViewSourceUtils.viewSource(url, null, null, line);
         ]]>
       </handler>
     </handlers>
   </binding>