Q:

Why is the title and favicon of the window/tab not updating?

I'm playing around with jetpack to change the title (and ideally the favicon) of certain pages.
Firebug is showing that the HTML of the page has been changed correctly but Firefox just won't update the title of the window and/or tab.  
This has to be possible, somehow, since Twitter Search is doing exactly that. It's updating the title as more search results show up, isn't it?
I guess I'm just missing something... any idea?
Example code as suggested in the comment:
function replaceTitle(doc) 
{
    if (doc.location.protocol == "http:" || doc.location.protocol == "https:")
    {

        var host=doc.location.host;
        if(host.indexOf("stackoverflow.com")>=0)
        {
            var title=doc.getElementsByTagName("title")
            console.log(title);

            if(title)
            {
                var val=title[0];
                if(val)
                {
                    console.log("val", val);
                    console.log("valx", val.textContent);
                    val.textContent="Foo";
                    console.log("valz", val.textContent);
                }
            }
        }
    }      
}

var state = "on";

function toggleState()
{
    if( state == "off" )
    {
        jetpack.tabs.onReady(replaceTitle);
        state = "on";
    }
    else
    {
        jetpack.tabs.onReady.unbind(replaceTitle);
        state = "off";
    }
    console.log(state);
    // This is a temporary way of keeping all browser window states
    // in sync. We are working on a better API for this.  
    /*  
    widgets.forEach(function(widget) {
    widget.defaultView.wrappedJSObject.setState(state);
    });
    */
}

jetpack.statusBar.append(
    {
        html: "Boo",
        onReady: function(widget) 
                {
                    console.log("ready");
                    // This is a temporary way of keeping all browser window states
                    // in sync. We are working on a better API for this.
                    /*
                    widgets.push(widget);
                    widget.defaultView.wrappedJSObject.setState(state);
                    */
                    $(widget).click(toggleState);
                },
        onUnload: function(widget) 
                {
                    console.log("unload");
                    /*
                    widgets.splice(widgets.indexOf(widget), 1);
                    */
                },
        width: 42
    });

console.log("Test");

Irritatingly, it doesn't even show logs anymore since jetpack and firebug have been updated in the meantime :p
I'd expect this code to replace the title of stackoverflow.com pages with "Foo" - but this is just an example, replace stackoverflow.com with anything else if that might help, i.e. probably a site with less javascript magic than SO.com.
Update:
I solved the problem with the help of the answer below.
The working example looks like this:
function replaceTitle() 
{
  var doc=this.contentDocument;
  console.log("replaceTitle "+ doc);
  if(doc)
  {
    var location = doc.location;

    if ( (location.protocol == "http:" || location.protocol == "https:")
      && location.host.indexOf("stackoverflow.com") !== -1 )
    {
      doc.title = "Foo";
      console.log("Title set to "+doc.title);
    }      
    else
    {
      console.log("Location "+location);
    }
  }
}

var state = "on";

function toggleState()
{
  if( state == "off" )
  {
    state = "on";
    jetpack.tabs.onReady(replaceTitle);
  }
  else
  {
    state = "off";
    jetpack.tabs.onReady.unbind(replaceTitle);
  }
  console.log(state);
}

jetpack.statusBar.append(
{
  html: "Boo",
  onReady: function(widget) 
    {
      console.log("ready: "+state);
      $(widget).click(toggleState);
    },
  onUnload: function(widget) 
    {
      console.log("unload");
    },
  width: 42
});

console.log("Testing");

A:

might want to try 
function replaceTitle(doc) 
{
  var location = doc.location;

  if ( (location.protocol == "http:" || location.protocol == "https:")
       && location.host.indexOf("stackoverflow.com") !== -1 ) {
    document.title = "Foo";
  }      
}

works for me
http://pastebin.me/4a3550e0dbe19?framepage

