[Pkg-mozext-commits] [firebug] 32/82: Hide internals from stacks

David Prévot taffit at moszumanska.debian.org
Mon Mar 31 22:45:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag fbtest-1.11.2
in repository firebug.

commit c64f126feb77acd4bac55837b356f41497fba629
Author: Simon Lindholm <simon.lindholm10 at gmail.com>
Date:   Sun Dec 30 01:46:13 2012 +0100

    Hide internals from stacks
---
 .../content/firebug/console/closureInspector.js    | 17 ++++++++--
 .../content/firebug/console/commandLineExposed.js  | 39 ++++++++++++++++++----
 2 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/extension/content/firebug/console/closureInspector.js b/extension/content/firebug/console/closureInspector.js
index ea9ef71..74c8788 100644
--- a/extension/content/firebug/console/closureInspector.js
+++ b/extension/content/firebug/console/closureInspector.js
@@ -236,10 +236,21 @@ var ClosureInspector =
 
     getClosureWrapper: function(obj, win, context)
     {
-        var env = this.getEnvironmentForObject(win, obj, context);
+        var env, dbg, dglobal;
+        try
+        {
+            env = this.getEnvironmentForObject(win, obj, context);
 
-        var dbg = this.getInactiveDebuggerForContext(context);
-        var dglobal = dbg.addDebuggee(win);
+            dbg = this.getInactiveDebuggerForContext(context);
+            dglobal = dbg.addDebuggee(win);
+        }
+        catch (exc)
+        {
+            // Throw our exception into user-land, and hope it lands safely in
+            // commandLineExposed.js where internals can be hidden.
+            exc._dropFrames = true;
+            throw exc;
+        }
 
         // Return a wrapper for its scoped variables.
         var self = this;
diff --git a/extension/content/firebug/console/commandLineExposed.js b/extension/content/firebug/console/commandLineExposed.js
index c72200b..50b0e0f 100644
--- a/extension/content/firebug/console/commandLineExposed.js
+++ b/extension/content/firebug/console/commandLineExposed.js
@@ -196,11 +196,24 @@ function createFirebugCommandLine(context, win)
         {
             // change source and line number of exeptions from commandline code
             // create new error since properties of nsIXPCException are not modifiable
-            var shouldModify, isXPCException;
-            if (exc.filename == Components.stack.filename)
-                shouldModify = isXPCException = true;
-            else if (exc.fileName == Components.stack.filename)
-                shouldModify = true;
+            var shouldModify = false, isXPCException = false, dropFrames = false;
+            var fileName = exc.filename || exc.fileName, lineNumber;
+            if (fileName.lastIndexOf("chrome:", 0) === 0)
+            {
+                if (fileName === Components.stack.filename)
+                {
+                    shouldModify = true;
+                    if (exc.filename)
+                        isXPCException = true;
+                    lineNumber = exc.lineNumber;
+                }
+                else if (exc._dropFrames)
+                {
+                    dropFrames = true;
+                    lineNumber = findLineNumberInExceptionStack(exc.stack);
+                    shouldModify = (lineNumber !== null);
+                }
+            }
 
             if (shouldModify)
             {
@@ -208,7 +221,7 @@ function createFirebugCommandLine(context, win)
                 result.stack = null;
                 result.source = expr;
                 result.message = exc.message;
-                result.lineNumber = exc.lineNumber - line;
+                result.lineNumber = lineNumber - line;
                 result.fileName = "data:," + encodeURIComponent(expr);
                 if (!isXPCException)
                     result.name = exc.name;
@@ -267,6 +280,20 @@ script.src = evalFileSrc;
 document.documentElement.appendChild(script);
 */
 
+function findLineNumberInExceptionStack(strStack) {
+    if (typeof strStack !== "string")
+        return null;
+    var stack = strStack.split("\n");
+    var fileName = Components.stack.filename, re = /^.*@(.*):(.*)$/;
+    for (var i = 0; i < stack.length; ++i)
+    {
+        var m = re.exec(stack[i]);
+        if (m && m[1] === fileName)
+            return +m[2];
+    }
+    return null;
+}
+
 // ********************************************************************************************* //
 // User Commands
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git



More information about the Pkg-mozext-commits mailing list