Access urlbar from addon sdk

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?

Try getBrowser(tab).defaultView.gURLBar

You are tapping into the window of the website in the tab, and that doesn’t have a URL bar, the url bar is apart of the “browser chrome window”, not the “tab content window”.

I use gURLBar here: