Get text URLs (or URI) of all tabs in e10s

Hi all, is there any way to get the URLs/URIs of each tab without having to dip into framescripts. I know we can grab the currently focused URI with gBrowser.currentURI, that doesn’t use any framescript stuff.

I have tried iterating over all tabs and haven’t found anything useful:

        var cntTabs = gBrowser.tabs.length;
        for (var i=0; i<cntTabs; i++) {
            console.log(gBrowser.tabs[i])
        }

tabs are just tabs. Nothing to see here, move right along :slightly_smiling:

You want browsers. You can get a browser from a tab using linkedBrowser, or you can just directly loop through the browsers property of gBrowser. Each browser has a currentURI just like the currentURI on gBrowser. I think this is what you’re looking for.

1 Like

Ah and it’s totally e10s safe to access tab.linkedBrowser.currentURI?

The tabbrowser and browser elements are all in the chrome process (despite the tabbrowser having an ID of content!), but some of their properties are CPOWs or shims to content objects. Most obviously contentWindow and contentDocument.

However currentURI is a simple javascript property and can safely be used. It is actually retrieved from the content process for you (and everyone else) and stored on the browser object. Don’t try to use documentURI, and obviously don’t try to access things like contentWindow.location.

1 Like

Superb thank you very much!