I am trying to access the urlbar from addon sdk and cannot get it to work.
This is what I am doing:
var { viewFor } = require("sdk/view/core");
var tab_utils = require("sdk/tabs/utils");
var getBrowser = function(tab) {
return tab_utils.getBrowserForTab(viewFor(tab));
}
tabs.on('ready', function (tab) {
var worker = tab.attach({
contentScriptFile: data.url('back.js')
});
var browser = getBrowser(tab);
console.log(browser.contentWindow.document.getElementById('urlbar'));
});
And it always returns null. What am I doing wrong?