cfx
Version:
programmatically use cfx with node.js
216 lines (189 loc) • 6.09 kB
Markdown
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
The `tabs/utils` module contains low-level functions for working with
XUL [`tabs`](https://developer.mozilla.org/en-US/docs/XUL/tab) and the XUL [`tabbrowser`](https://developer.mozilla.org/en-US/docs/XUL/tabbrowser)
object.
<api name="activateTab">
Set the specified tab as the active, or
[selected](https://developer.mozilla.org/en-US/docs/XUL/tabbrowser#p-selectedTab),
tab.
tab {tab}
A [XUL `tab` element](https://developer.mozilla.org/en-US/docs/XUL/tab)
to activate.
window {window}
A browser window.
</api>
<api name="getTabBrowser">
Get the [`tabbrowser`](https://developer.mozilla.org/en-US/docs/XUL/tabbrowser)
element for the given browser window.
window {window}
A browser window.
{tabbrowser}
</api>
<api name="getTabContainer">
Get the `tabbrowser`'s
[`tabContainer`](https://developer.mozilla.org/en-US/docs/XUL/tabbrowser#p-tabContainer)
property.
window {window}
A browser window.
{tabContainer}
</api>
<api name="getTabs">
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](modules/sdk/private-browsing.html).
window {nsIWindow}
Optional.
{Array}
An array of [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab)
elements.
</api>
<api name="getActiveTab">
Given a browser window, get the active, or
[selected](https://developer.mozilla.org/en-US/docs/XUL/tabbrowser#p-selectedTab), tab.
window {window}
A browser window.
{tab}
The currently selected
[`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab).
</api>
<api name="getOwnerWindow">
Get the browser window that owns the specified `tab`.
tab {tab}
A browser [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab).
{window}
A browser window.
</api>
<api name="openTab">
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`.
{tab}
The new [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab).
</api>
<api name="isTabOpen">
Test whether the specified tab is open.
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
{boolean}
`true` if the tab is open, otherwise `false`.
</api>
<api name="closeTab">
Close the specified tab.
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
</api>
<api name="getURI">
Get the specified tab's URI.
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
{String}
The current URI.
</api>
<api name="getTabBrowserForTab">
Get the specified tab's [`tabbrowser`](https://developer.mozilla.org/en-US/docs/XUL/tabbrowser).
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
{tabbrowser}
</api>
<api name="getBrowserForTab">
Get the specified tab's [`browser`](https://developer.mozilla.org/en-US/docs/XUL/browser).
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
{browser}
</api>
<api name="getTabTitle">
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`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
{String}
</api>
<api name="setTabTitle">
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`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
title {String}
The new title.
</api>
<api name="getTabContentWindow">
Get the specified tab's content window.
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
{window}
</api>
<api name="getAllTabContentWindows">
Get all tabs' content windows across all the browsers' windows.
{Array}
Array of windows.
</api>
<api name="getTabForContentWindow">
Get the tab element that hosts the specified content window.
window {window}
{tab}
</api>
<api name="getTabURL">
Get the specified tab's URL.
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
{String}
The current URI.
</api>
<api name="setTabURL">
Set the specified tab's URL.
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
url {String}
</api>
<api name="getTabContentType">
Get the [`contentType`](https://developer.mozilla.org/en-US/docs/DOM/document.contentType)
of the document hosted by the specified tab.
tab {tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
{String}
</api>
<api name="getSelectedTab">
Get the selected tab for the specified browser window.
window {window}
{tab}
A XUL [`tab`](https://developer.mozilla.org/en-US/docs/XUL/tab) element.
</api>