Changeset 750

Show
Ignore:
Timestamp:
07/04/08 12:27:21 (5 months ago)
Author:
aranti..@gmail.com
Message:

Refs #122

  • Incorporate the suggested patch to restore Firebug 1.2 console compatibility.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/components/greasemonkey.js

    r749 r750  
    393393 
    394394  getFirebugConsole: function(unsafeContentWin, chromeWin) { 
    395     var firebugConsoleCtor = null; 
    396     var firebugContext = null; 
    397  
    398     if (chromeWin && chromeWin.FirebugConsole) { 
    399       firebugConsoleCtor = chromeWin.FirebugConsole; 
    400       firebugContext = chromeWin.top.TabWatcher 
    401         .getContextByWindow(unsafeContentWin); 
    402  
    403       // on first load (of multiple tabs) the context might not exist 
    404       if (!firebugContext) firebugConsoleCtor = null; 
    405     } 
    406  
    407     if (firebugConsoleCtor && firebugContext) { 
    408       return new firebugConsoleCtor(firebugContext, unsafeContentWin); 
    409     } else { 
    410       return null; 
    411     } 
     395    if (!chromeWin) return null; 
     396    var firebugConsole = null; 
     397    var firebugContext = chromeWin.top.TabWatcher && 
     398      chromeWin.top.TabWatcher.getContextByWindow(unsafeContentWin); 
     399    // on first load (of multiple tabs) the context might not exist 
     400    if (!firebugContext) return null; 
     401    if (chromeWin.FirebugConsole) { // < Firebug 1.2 
     402      firebugConsole =  
     403        new chromeWin.FirebugConsole(firebugContext, unsafeContentWin); 
     404    } else if (chromeWin.Firebug.Console) { // >= Firebug 1.2 
     405      var firebug = chromeWin.Firebug.Console; 
     406      firebugConsole = {}; 
     407      var commands = ["log", "debug", "info", "warn", "error"]; 
     408      commands.forEach(function(command) { 
     409        firebugConsole[command] = function() { 
     410          firebug.logFormatted.call( 
     411            firebug, Array.slice(arguments), firebugContext, command 
     412          ); 
     413        } 
     414      }); 
     415    } 
     416    return firebugConsole; 
    412417  } 
    413418};