Decision
@paa is nice, but it doesn't move the tab. It is duplicated by a tab. Thus, flash movies do not retain their position, etc. And this is not the movement of his duplication, as he explained.
I did a lot of research, it was fun. The way tabs are moved in Firefox is through the exchange of docShell. This will accomplish what you want. This is written for bootstrap, although so you need to tweak it for addon sdk.
Pass the second argument as a tabbed or non-tabbed string if you want to move it to a new window. Else passes the second argument to the existing window, and it will be moved there. can copy paste and run this code from the satch panel.
function gBrowser.swapBrowsersAndCloseOther is gBrowser.swapBrowsersAndCloseOther
function moveTabToWin(aTab, tDOMWin) { //tDOMWin means target DOMWindow means the window you want the tab in //if tDOMWin == 'tabbed' or == 'non-tabbed' it opens in a new window //if aTopContWin is the last in its window, then its window is closed if (tDOMWin == 'tabbed' || tDOMWin == 'non-tabbed') { var sa = Cc["@mozilla.org/supports-array;1"].createInstance(Ci.nsISupportsArray); var wuri = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString); wuri.data = 'about:blank'; sa.AppendElement(wuri); let features = "chrome,dialog=no"; if (tDOMWin == 'tabbed') { features += ',all'; } var sDOMWin = aTab.ownerGlobal; //source DOMWindow if (PrivateBrowsingUtils.permanentPrivateBrowsing || PrivateBrowsingUtils.isWindowPrivate(sDOMWin)) { features += ",private"; } else { features += ",non-private"; } var XULWindow = Services.ww.openWindow(null, 'chrome://browser/content/browser.xul', null, features, sa); XULWindow.addEventListener('load', function() { var DOMWindow = XULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow); DOMWindow.gBrowser.selectedTab.linkedBrowser.webNavigation.stop(Ci.nsIWebNavigation.STOP_ALL); DOMWindow.gBrowser.swapBrowsersAndCloseOther(DOMWindow.gBrowser.selectedTab, aTab); //DOMWindow.gBrowser.selectedTab = newTab; }, false); } else if (tDOMWin) { //existing dom window var newTab = tDOMWin.gBrowser.addTab('about:blank'); newTab.linkedBrowser.webNavigation.stop(Ci.nsIWebNavigation.STOP_ALL); tDOMWin.gBrowser.swapBrowsersAndCloseOther(newTab, aTab); tDOMWin.gBrowser.selectedTab = newTab; } } moveTabToWin(gBrowser.selectedTab, 'tabbed');
source share