Ticket #122: ticket#122.patch

File ticket#122.patch, 1.8 kB (added by mkomu..@gmail.com, 5 months ago)
  • trunk/src/components/greasemonkey.js

    old new  
    407407  }, 
    408408 
    409409  getFirebugConsole: function(unsafeContentWin, chromeWin) { 
    410     var firebugConsoleCtor = null; 
    411     var firebugContext = null; 
    412  
    413     if (chromeWin && chromeWin.FirebugConsole) { 
    414       firebugConsoleCtor = chromeWin.FirebugConsole; 
    415       firebugContext = chromeWin.top.TabWatcher 
    416         .getContextByWindow(unsafeContentWin); 
    417  
    418       // on first load (of multiple tabs) the context might not exist 
    419       if (!firebugContext) firebugConsoleCtor = null; 
     410    if (!chromeWin) return null; 
     411    var firebugConsole = null; 
     412    var firebugContext = chromeWin.top.TabWatcher 
     413      .getContextByWindow(unsafeContentWin); 
     414    // on first load (of multiple tabs) the context might not exist 
     415    if (!firebugContext) return null; 
     416    if (chromeWin.FirebugConsole) { // < Firebug 1.2 
     417      firebugConsole =  
     418        new chromeWin.FirebugConsole(firebugContext, unsafeContentWin); 
     419    } else if (chromeWin.Firebug.Console) { // >= Firebug 1.2 
     420      var firebug = chromeWin.Firebug.Console; 
     421      firebugConsole = {}; 
     422      var commands = ["log", "debug", "info", "warn", "error"]; 
     423      commands.forEach(function(command) { 
     424        firebugConsole[command] = function() { 
     425          firebug.logFormatted.call( 
     426            firebug, Array.slice(arguments), firebugContext, command 
     427          ); 
     428        } 
     429      }); 
    420430    } 
    421  
    422     if (firebugConsoleCtor && firebugContext) { 
    423       return new firebugConsoleCtor(firebugContext, unsafeContentWin); 
    424     } else { 
    425       return null; 
    426     } 
     431    return firebugConsole; 
    427432  } 
    428433}; 
    429434