tabBrowser

This class simplifies the access to tab related elements and functions in the browser window.

Method overview

tabBrowser(in MozMillController controller);
closeAllTabs();
closeTab(in object event);
ElemBase getElement(in object spec);
ElemBase getTab(in number index);
ElemBase getTabPanelElement(in number tabIndex, in string elemString);
openTab(in object event);

Attributes

Attribute Type Description
controller MozMillController Controller of the browser window to work on.
length number Number of open tabs.
selectedIndex number Get or set the current tab index.

Methods

tabBrowser()

Constructor of the class.

tabBrowser(
  in MozMillController controller
);
Parameters
controller
Mozmill controller of the browser window to operate on.

closeAllTabs()

Closes all the window's tabs, leaving only a single tab containing a blank page.

closeAllTabs();
Parameters

None.

closeTab()

Closes an open tab.

closeTab(
  in object event
);
Parameters
event
The event to use to close the tab. The following values are supported:
event.type (string) Description
"closeButton" Use the close button of the tab.
"menu" Use the menu.
"middleClick"
Synthesize a middleClick on the tab itself.
"shortcut"
Use the keyboard shortcut.

getElement()

Retrieves a UI element based on the given spec object.

ElemBase getElement(
  in object spec
);
Parameters
spec
JSON object which specifies the element to retrieve. Use its attributes to specify the exact element. This example shows the correct usage.
spec.type  (string)
spec.subtype (string) spec.value (mixed) Description
"tabs" -
-
Get the tabs element.
"tabs_allTabsButton" -
-
Get the All Tabs button element.
"tabs_allTabsPopup" -
-
Get the All Tabs popup element.
"tabs_animateBox" -
-
Get the tabs animation box element.
"tabs_container" -
-
Get the tabs container element.
"tabs_newTabButton" -
-
Get the New Tab button element.
"tabs_scrollButton" "up"
-
Get the left tab scroll button element.
"tabs_scrollButton" "down" - Get the right tab scroll button element.
"tabs_strip" - - Get the tab strip element.
"tabs_tab" "index" index (number) Get the tab element with the specified index.
"tabs_tabCloseButton" - tab (ElemBase) Get the close button element of the specified tab.
"tabs_tabFavicon" - tab (ElemBase) Get the favicon element of the specified tab.
"tabs_tabPanel" - tab (ElemBase) Get the notification bar element of the specified tab.
Return value

ElemBase instance of the requested element which matches the specifications.

getTab()

Returns the tab at the specified index.

ElemBase getTab(
in number index
);
Parameters
index
Index of the tab.
Return value

ElemBase instance of the requested tab.

getTabPanelElement()

Gets the notification bar or a child specified by an element lookup string.

ElemBase getTabPanelElement(
in number tabIndex,
in string elemString
);
Parameters
tabIndex
Index of the tab.
elemString
Element lookup string of the notification bar's child node. This parameter is optional.

openTab()

Opens a new tab.

openTab(
  in object event
);
Parameters
event
Event which specifies how the tab will be closed. The following values are supported:
event.type (string) Description
"menu" Use the menu.
"shortcut" Use the keyboard shortcut.
"newTabButton"
Use the New Tab button at the end of the tab bar.
"tabStrip"
Synthesize a middleClick on the tab strip.

Examples

// Include necessary modules
var RELATIVE_ROOT = '../../shared-modules';
var MODULE_REQUIRES = ['TabbedBrowsingAPI'];
var setupModule = function(module)
{
  controller = mozmill.getBrowserController();
  tabBrowser = new TabbedBrowsingAPI.tabBrowser(controller);
}
var testOpenCloseTab = function()
{
  // Open a new tab by clicking on the new tab button
  tabBrowser.openTab({type: "newTabButton"});
  // Get the favicon of the first tab
  var firstTab = tabBrowser.getElement({type: "tabs_tab", subtype: "index", value: 0});
  var favicon = tabBrowser.getElement({type: "tabs_tabFavicon", value: firstTab});
  // Select the first tab and click the close button
  tabBrowser.selectedIndex = 0;
  tabBrowser.closeTab({type: "closeButton"});
}

 

Document Tags and Contributors

 Last updated by: Sheppy,