I'm build an SDK Firefox Add-on that is supposed to read a tab's URL and parse it. To this end, I'm listening to the 'ready' event in lib/main.js,
var tabs = require('sdk/tabs');
tabs.on('open', function(tab){
tab.on('ready', function(tab){
console.log(tab.url);
});
});
as described in Mozilla's documentation.
When debugging with cfx run, this appears to work well for new tabs. The tab that's already open on cfx run, however does not fire the open and ready events.
What's the reason for this and how to fix it?
To list all tabs that were open at the moment of loading the addon you could just use the
tabsobject you got after requiringsdk/tabsSo the code from your example could be transformed to something like this: