Bug 962857 - Fix for debugger mistakenly detecting .jsm files are minified. r=fitzgen
authorHubert B Manilla <b4bomsy@gmail.com>
Mon, 17 Mar 2014 10:43:19 -0400
changeset 192133 ec77797d0a47d48d85a11d90ebbb750e989ba860
parent 192132 9a2844261651c5d9e82234f5627a00dec3d7fa46
child 192134 ef4ee2255eebe629dc932e62ee20f43c0714e86b
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs962857
milestone30.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 962857 - Fix for debugger mistakenly detecting .jsm files are minified. r=fitzgen
browser/devtools/debugger/debugger-panes.js
--- a/browser/devtools/debugger/debugger-panes.js
+++ b/browser/devtools/debugger/debugger-panes.js
@@ -2,18 +2,19 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* 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/. */
 
 "use strict";
 
 // Used to detect minification for automatic pretty printing
-const SAMPLE_SIZE = 30; // no of lines
-const INDENT_COUNT_THRESHOLD = 20; // percentage
+const SAMPLE_SIZE = 50; // no of lines
+const INDENT_COUNT_THRESHOLD = 5; // percentage
+const CHARACTER_LIMIT = 250; // line character limit
 
 /**
  * Functions handling the sources UI.
  */
 function SourcesView() {
   dumpn("SourcesView was instantiated");
 
   this.togglePrettyPrint = this.togglePrettyPrint.bind(this);
@@ -1495,31 +1496,38 @@ let SourceUtils = {
       return this._minifiedCache.get(sourceClient);
     }
 
     let isMinified;
     let lineEndIndex = 0;
     let lineStartIndex = 0;
     let lines = 0;
     let indentCount = 0;
+    let overCharLimit = false;
 
     // Strip comments.
     aText = aText.replace(/\/\*[\S\s]*?\*\/|\/\/(.+|\n)/g, "");
 
     while (lines++ < SAMPLE_SIZE) {
       lineEndIndex = aText.indexOf("\n", lineStartIndex);
       if (lineEndIndex == -1) {
          break;
       }
       if (/^\s+/.test(aText.slice(lineStartIndex, lineEndIndex))) {
         indentCount++;
       }
+      // For files with no indents but are not minified.
+      if ((lineEndIndex - lineStartIndex) > CHARACTER_LIMIT) {
+        overCharLimit = true;
+        break;
+      }
       lineStartIndex = lineEndIndex + 1;
     }
-    isMinified = ((indentCount / lines ) * 100) < INDENT_COUNT_THRESHOLD;
+    isMinified = ((indentCount / lines ) * 100) < INDENT_COUNT_THRESHOLD ||
+                 overCharLimit;
 
     this._minifiedCache.set(sourceClient, isMinified);
     return isMinified;
   },
 
   /**
    * Clears the labels, groups and minify cache, populated by methods like
    * SourceUtils.getSourceLabel or Source Utils.getSourceGroup.