unstable

tabs/utils

The tabs/utils module contains low-level functions for working with XUL tabs and the XUL tabbrowser object.

API Reference

Functions

activateTab(tab, window)

Set the specified tab as the active, or selected, tab.

tab : tab

A XUL tab element to activate.

window : window

A browser window.

getTabBrowser(window)

Get the tabbrowser element for the given browser window.

window : window

A browser window.

Returns: tabbrowser

getTabContainer(window)

Get the tabbrowser's tabContainer property.

window : window

A browser window.

Returns: tabContainer

getTabs(window)

Returns the tabs for the specified window.

If you omit window, this function will return tabs across all the browser's windows. However, if your add-on has not opted into private browsing, then the function will exclude all tabs that are hosted by private browser windows.

To learn more about private windows, how to opt into private browsing, and how to support private browsing, refer to the documentation for the private-browsing module.

window : nsIWindow

Optional.

Returns: Array

An array of tab elements.

getActiveTab(window)

Given a browser window, get the active, or selected, tab.

window : window

A browser window.

Returns: tab

The currently selected tab.

getOwnerWindow(tab)

Get the browser window that owns the specified tab.

tab : tab

A browser tab.

Returns: window

A browser window.

openTab(window, url, options)

Open a new tab in the specified browser window.

window : window

The browser window in which to open the tab.

url : String

URL for the document to load.

options : object

Options for the new tab. These are currently only applicable to Firefox for Android.

inBackground : boolean

If true, open the new tab, but keep the currently selected tab selected. If false, make the new tab the selected tab. Optional, defaults to false.

pinned : boolean

Pin this tab. Optional, defaults to false.

Returns: tab

The new tab.

isTabOpen(tab)

Test whether the specified tab is open.

tab : tab

A XUL tab element.

Returns: boolean

true if the tab is open, otherwise false.

closeTab(tab)

Close the specified tab.

tab : tab

A XUL tab element.

getURI(tab)

Get the specified tab's URI.

tab : tab

A XUL tab element.

Returns: String

The current URI.

getTabBrowserForTab(tab)

Get the specified tab's tabbrowser.

tab : tab

A XUL tab element.

Returns: tabbrowser

getBrowserForTab(tab)

Get the specified tab's browser.

tab : tab

A XUL tab element.

Returns: browser

getTabTitle(tab)

Get the title of the document hosted by the specified tab, or the tab's label if the tab doesn't host a document.

tab : tab

A XUL tab element.

Returns: String

setTabTitle(tab, title)

Set the title of the document hosted by the specified tab, or the tab's label if the tab doesn't host a document.

tab : tab

A XUL tab element.

title : String

The new title.

getTabContentWindow(tab)

Get the specified tab's content window.

tab : tab

A XUL tab element.

Returns: window

getAllTabContentWindows()

Get all tabs' content windows across all the browsers' windows.

Returns: Array

Array of windows.

getTabForContentWindow(window)

Get the tab element that hosts the specified content window.

window : window
Returns: tab

getTabURL(tab)

Get the specified tab's URL.

tab : tab

A XUL tab element.

Returns: String

The current URI.

setTabURL(tab, url)

Set the specified tab's URL.

tab : tab

A XUL tab element.

url : String

getTabContentType(tab)

Get the contentType of the document hosted by the specified tab.

tab : tab

A XUL tab element.

Returns: String

getSelectedTab(window)

Get the selected tab for the specified browser window.

window : window
Returns: tab

A XUL tab element.