Uncaught TypeError: Cannot set property 'name' of undefined

60 views
Skip to first unread message

jonathan hill

unread,
Jul 14, 2015, 8:05:33 AM7/14/15
to fir...@googlegroups.com
Hello all,

I have recently installed firebug lite locally in a work project I am working on. I get the above error on line 23329 of firebug-lite-debug.js having run the script for the first time on chrome. This appears to be a bug in firebug lite. Has anyone else encountered the same issue and can anyone suggest a solution.

It would appear to have something to do with the way firebug is trying to call the stack trace. see below

 this.trace = function()
    {
        var getFuncName = function getFuncName (f)
        {
            if (f.getName instanceof Function)
            {
                return f.getName();
            }
            if (f.name) // in FireFox, Function objects have a name property...
            {
                return f.name;
            }
            
            var name = f.toString().match(/function\s*([_$\w\d]*)/)[1];
            return name || "anonymous";
        };
        
        var wasVisited = function(fn)
        {
            for (var i=0, l=frames.length; i<l; i++)
            {
                if (frames[i].fn == fn)
                {
                    return true;
                }
            }
            
            return false;
        };
        
        traceRecursion++;
        
        if (traceRecursion > 1)
        {
            traceRecursion--;
            return;
        }
    
        var frames = [];
        
        for (var fn = arguments.callee.caller.caller; fn; fn = fn.caller)
        {
            if (wasVisited(fn)) break;
            
            var args = [];
            
            for (var i = 0, l = fn.arguments.length; i < l; ++i)
            {
                args.push({value: fn.arguments[i]});
            }

            frames.push({fn: fn, name: getFuncName(fn), args: args});
        }
        
        
        // ****************************************************************************************
        
        try
        {
            (0)();
        }
        catch(e)
        {
            var result = e;
            
            var stack = 
                result.stack || // Firefox / Google Chrome 
                result.stacktrace || // Opera
                "";
            
            stack = stack.replace(/\n\r|\r\n/g, "\n"); // normalize line breaks
            var items = stack.split(/[\n\r]/);
            
            // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
            // Google Chrome
            if (FBL.isSafari)
            {
                //var reChromeStackItem = /^\s+at\s+([^\(]+)\s\((.*)\)$/;
                //var reChromeStackItem = /^\s+at\s+(.*)((?:http|https|ftp|file):\/\/.*)$/;
                var reChromeStackItem = /^\s+at\s+(.*)((?:http|https|ftp|file):\/\/.*)$/;
                
                var reChromeStackItemName = /\s*\($/;
                var reChromeStackItemValue = /^(.+)\:(\d+\:\d+)\)?$/;
                
                var framePos = 0;
                for (var i=4, length=items.length; i<length; i++, framePos++)
                {
                    var frame = frames[framePos];
                    var item = items[i];
                    var match = item.match(reChromeStackItem);
                    
                    //Firebug.Console.log("["+ framePos +"]--------------------------");
                    //Firebug.Console.log(item);
                    //Firebug.Console.log("................");
                    
                    if (match)
                    {
                        var name = match[1];
                        if (name)
                        {
                            name = name.replace(reChromeStackItemName, "");
                            frame.name = name; 
                        }
                        
                        //Firebug.Console.log("name: "+name);
                        
                        var value = match[2].match(reChromeStackItemValue);
                        if (value)
                        {
                            frame.href = value[1];
                            frame.lineNo = value[2];
                            
                            //Firebug.Console.log("url: "+value[1]);
                            //Firebug.Console.log("line: "+value[2]);
                        }
                        //else
                        //    Firebug.Console.log(match[2]);
                        
                    }             
                }
            }
            /**/
            
            // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
            else if (FBL.isFirefox)
            {
                // Firefox
                var reFirefoxStackItem = /^(.*)@(.*)$/;
                var reFirefoxStackItemValue = /^(.+)\:(\d+)$/;
                
                var framePos = 0;
                for (var i=2, length=items.length; i<length; i++, framePos++)
                {
                    var frame = frames[framePos] || {};
                    var item = items[i];
                    var match = item.match(reFirefoxStackItem);
                    
                    if (match)
                    {
                        var name = match[1];
                        
                        //Firebug.Console.logFormatted("name: "+name);
                        
                        var value = match[2].match(reFirefoxStackItemValue);
                        if (value)
                        {
                            frame.href = value[1];
                            frame.lineNo = value[2];
                            
                            //Firebug.Console.log("href: "+ value[1]);
                            //Firebug.Console.log("line: " + value[2]);
                        }
                        //else
                        //    Firebug.Console.logFormatted([match[2]]);
                    }                
                }
            }
            /**/
            
            // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
            /*
            else if (FBL.isOpera)
            {
                // Opera
                var reOperaStackItem = /^\s\s(?:\.\.\.\s\s)?Line\s(\d+)\sof\s(.+)$/;
                var reOperaStackItemValue = /^linked\sscript\s(.+)$/;
                
                for (var i=0, length=items.length; i<length; i+=2)
                {
                    var item = items[i];
                    
                    var match = item.match(reOperaStackItem);
                    
                    if (match)
                    {
                        //Firebug.Console.log(match[1]);
                        
                        var value = match[2].match(reOperaStackItemValue);
                        
                        if (value)
                        {
                            //Firebug.Console.log(value[1]);
                        }
                        //else
                        //    Firebug.Console.log(match[2]);
                        
                        //Firebug.Console.log("--------------------------");
                    }                
                }
            }
            /**/
        }
        
        //console.log(stack);
        //console.dir(frames);
        Firebug.Console.log({frames: frames}, context, "stackTrace", FirebugReps.StackTrace);
        
        traceRecursion--;
    };

Thanks,

jonathan
Reply all
Reply to author
Forward
0 new messages