third_party/js/mozmill/shared-modules/tabs.js
function tabBrowser_openTab(aEvent) {
    var event = aEvent || { };
    var type = (event.type == undefined) ? "menu" : event.type;

    // Disable tab closing animation for default behavior
    prefs.preferences.setPref(PREF_TABS_ANIMATE, false);

    // Add event listener to wait until the tab has been opened
    var self = { opened: false };
    function checkTabOpened() { self.opened = true; }
    this._controller.window.addEventListener("TabOpen", checkTabOpened, false);

    switch (type) {
      case "menu":
        var menuitem = new elementslib.Elem(this._controller.menus['file-menu'].menu_newNavigatorTab);
        this._controller.click(menuitem);
        break;
      case "shortcut":
        var cmdKey = utils.getEntity(this.getDtds(), "tabCmd.commandkey");
        this._controller.keypress(null, cmdKey, {accelKey: true});
        break;
      case "newTabButton":
        var newTabButton = this.getElement({type: "tabs_newTabButton"});
        this._controller.click(newTabButton);
        break;
      case "tabStrip":
        var tabStrip = this.getElement({type: "tabs_strip"});
        
        // RTL-locales need to be treated separately
        if (utils.getEntity(this.getDtds(), "locale.dir") == "rtl") {
          // XXX: Workaround until bug 537968 has been fixed
          this._controller.click(tabStrip, 100, 3);
          // Todo: Calculate the correct x position
          this._controller.doubleClick(tabStrip, 100, 3);
        } else {
          // XXX: Workaround until bug 537968 has been fixed
          this._controller.click(tabStrip, tabStrip.getNode().clientWidth - 100, 3);
          // Todo: Calculate the correct x position
          this._controller.doubleClick(tabStrip, tabStrip.getNode().clientWidth - 100, 3);
        }
        break;
      default:
        throw new Error(arguments.callee.name + ": Unknown event type - " + type);
    }

    try {
      this._controller.waitForEval("subject.tab.opened == true", TIMEOUT, 100,
                                   {tab: self});
    } finally {
      this._controller.window.removeEventListener("TabOpen", checkTabOpened, false);
      prefs.preferences.clearUserPref(PREF_TABS_ANIMATE);
    }
  }
function tabBrowser_openTab(aEvent) {
    var event = aEvent || { };
    var type = (event.type == undefined) ? "menu" : event.type;

    // Disable tab closing animation for default behavior
    prefs.preferences.setPref(PREF_TABS_ANIMATE, false);

    // Add event listener to wait until the tab has been opened
    var self = { opened: false };
    function checkTabOpened() { self.opened = true; }
    this._controller.window.addEventListener("TabOpen", checkTabOpened, false);

    switch (type) {
      case "menu":
        var menuitem = new elementslib.Elem(this._controller.menus['file-menu'].menu_newNavigatorTab);
        this._controller.click(menuitem);
        break;
      case "shortcut":
        var cmdKey = utils.getEntity(this.getDtds(), "tabCmd.commandkey");
        this._controller.keypress(null, cmdKey, {accelKey: true});
        break;
      case "newTabButton":
        var newTabButton = this.getElement({type: "tabs_newTabButton"});
        this._controller.click(newTabButton);
        break;
      case "tabStrip":
        var tabStrip = this.getElement({type: "tabs_strip"});
        
        // RTL-locales need to be treated separately
        if (utils.getEntity(this.getDtds(), "locale.dir") == "rtl") {
          // XXX: Workaround until bug 537968 has been fixed
          this._controller.click(tabStrip, 100, 3);
          // Todo: Calculate the correct x position
          this._controller.doubleClick(tabStrip, 100, 3);
        } else {
          // XXX: Workaround until bug 537968 has been fixed
          this._controller.click(tabStrip, tabStrip.getNode().clientWidth - 100, 3);
          // Todo: Calculate the correct x position
          this._controller.doubleClick(tabStrip, tabStrip.getNode().clientWidth - 100, 3);
        }
        break;
      default:
        throw new Error(arguments.callee.name + ": Unknown event type - " + type);
    }

    try {
      this._controller.waitForEval("subject.tab.opened == true", TIMEOUT, 100,
                                   {tab: self});
    } finally {
      this._controller.window.removeEventListener("TabOpen", checkTabOpened, false);
      prefs.preferences.clearUserPref(PREF_TABS_ANIMATE);
    }
  }
function tabBrowser_openTab ( aEvent ) { var event = aEvent || { } ; var type = ( event . type == undefined ) ? "menu" : event . type ; // Disable tab closing animation for default behavior prefs . preferences . setPref ( PREF_TABS_ANIMATE , false ) ; // Add event listener to wait until the tab has been opened var self = { opened : false } ; function checkTabOpened ( ) { self . opened = true ; } this . _controller . window . addEventListener ( "TabOpen" , checkTabOpened , false ) ; switch ( type ) { case "menu" : var menuitem = new elementslib . Elem ( this . _controller . menus [ 'file-menu' ] . menu_newNavigatorTab ) ; this . _controller . click ( menuitem ) ; break ; case "shortcut" : var cmdKey = utils . getEntity ( this . getDtds ( ) , "tabCmd.commandkey" ) ; this . _controller . keypress ( null , cmdKey , { accelKey : true } ) ; break ; case "newTabButton" : var newTabButton = this . getElement ( { type : "tabs_newTabButton" } ) ; this . _controller . click ( newTabButton ) ; break ; case "tabStrip" : var tabStrip = this . getElement ( { type : "tabs_strip" } ) ; // RTL-locales need to be treated separately if ( utils . getEntity ( this . getDtds ( ) , "locale.dir" ) == "rtl" ) { // XXX: Workaround until bug 537968 has been fixed this . _controller . click ( tabStrip , 100 , 3 ) ; // Todo: Calculate the correct x position this . _controller . doubleClick ( tabStrip , 100 , 3 ) ; } else { // XXX: Workaround until bug 537968 has been fixed this . _controller . click ( tabStrip , tabStrip . getNode ( ) . clientWidth - 100 , 3 ) ; // Todo: Calculate the correct x position this . _controller . doubleClick ( tabStrip , tabStrip . getNode ( ) . clientWidth - 100 , 3 ) ; } break ; default : throw new Error ( arguments . callee . name + ": Unknown event type - " + type ) ; } try { this . _controller . waitForEval ( "subject.tab.opened == true" , TIMEOUT , 100 , { tab : self } ) ; } finally { this . _controller . window . removeEventListener ( "TabOpen" , checkTabOpened , false ) ; prefs . preferences . clearUserPref ( PREF_TABS_ANIMATE ) ; } }
Open a new tab

@param {object} aEvent
The event specifies how to open a new tab (menu, shortcut,
Elements: type - Type of event (menu, newTabButton, shortcut, tabStrip)
[optional - default: menu]
Open a new tab