diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js index 9fbb3d93746d..6104bdad5fb1 100644 --- a/browser/components/tabbrowser/content/tabbrowser.js +++ b/browser/components/tabbrowser/content/tabbrowser.js @@ -11377,6 +11377,9 @@ addTabGroup ( tabs { +id += +null color = null @@ -11433,7 +11436,12 @@ tabGroupMenu nextUnusedColor ; } -let +if +( +! +id +) +{ id = { @@ -11459,6 +11467,7 @@ random ) } ; +} let group = @@ -20667,6 +20676,154 @@ return win ; } +replaceGroupWithWindow +( +group +) +{ +let +selectedIndex += +group +. +tabs +. +indexOf +( +gBrowser +. +selectedTab +) +; +if +( +selectedIndex +< +0 +) +{ +selectedIndex += +0 +; +} +let +firstTab += +group +. +tabs +[ +selectedIndex +] +; +let +newWindow += +this +. +replaceTabWithWindow +( +firstTab +) +; +newWindow +. +addEventListener +( +" +before +- +initial +- +tab +- +adopted +" +( +) += +> +{ +let +tabsToGroup += +group +. +tabs +. +map +( +( +tab +i +) += +> +{ +if +( +i += += +selectedIndex +) +{ +return +newWindow +. +gBrowser +. +visibleTabs +[ +0 +] +; +} +return +tab +; +} +) +; +newWindow +. +gBrowser +. +addTabGroup +( +tabsToGroup +{ +color +: +group +. +color +label +: +group +. +label +id +: +group +. +id +} +) +; +} +{ +once +: +true +} +) +; +return +newWindow +; +} _updateTabsAfterInsert ( ) diff --git a/browser/components/tabbrowser/content/tabgroup-menu.js b/browser/components/tabbrowser/content/tabgroup-menu.js index 646a83993ee7..4099ef520f9f 100644 --- a/browser/components/tabbrowser/content/tabgroup-menu.js +++ b/browser/components/tabbrowser/content/tabgroup-menu.js @@ -501,6 +501,11 @@ only > < toolbarbutton +tabindex += +" +1 +" id = " @@ -537,10 +542,10 @@ toolbarbutton > < toolbarbutton -disabled +tabindex = " -true +1 " id = @@ -617,6 +622,11 @@ toolbarbutton > < toolbarbutton +tabindex += +" +1 +" id = " @@ -1057,6 +1067,37 @@ document getElementById ( " +tabGroupEditor_moveGroupToNewWindow +" +) +. +addEventListener +( +" +command +" +( +) += +> +{ +gBrowser +. +replaceGroupWithWindow +( +this +. +activeGroup +) +; +} +) +; +document +. +getElementById +( +" tabGroupEditor_ungroupTabs " ) @@ -1686,6 +1727,31 @@ topleft } ) ; +document +. +getElementById +( +" +tabGroupEditor_moveGroupToNewWindow +" +) +. +disabled += +gBrowser +. +openTabCount += += +this +. +activeGroup +? +. +tabs +. +length +; } on_popupshown ( diff --git a/browser/components/tabbrowser/content/tabgroup.js b/browser/components/tabbrowser/content/tabgroup.js index 2f43139a3d6d..e4b98b7ae388 100644 --- a/browser/components/tabbrowser/content/tabgroup.js +++ b/browser/components/tabbrowser/content/tabgroup.js @@ -741,7 +741,7 @@ gBrowser adoptTab ( tab -this +gBrowser . tabs . @@ -754,6 +754,9 @@ at _tPos + 1 +tab +. +selected ) ; gBrowser diff --git a/browser/components/tabbrowser/test/browser/tabs/browser_tab_groups.js b/browser/components/tabbrowser/test/browser/tabs/browser_tab_groups.js index d3aef168323b..671744416046 100644 --- a/browser/components/tabbrowser/test/browser/tabs/browser_tab_groups.js +++ b/browser/components/tabbrowser/test/browser/tabs/browser_tab_groups.js @@ -6790,6 +6790,10 @@ async function createTabGroupAndOpenEditPanel ( +tabs += +[ +] ) { let @@ -6815,6 +6819,14 @@ tabgroupEditor . panel ; +if +( +! +tabs +. +length +) +{ let tab = @@ -6835,6 +6847,13 @@ false } ) ; +tabs += +[ +tab +] +; +} let panelShown = @@ -6855,9 +6874,7 @@ gBrowser . addTabGroup ( -[ -tab -] +tabs { color : @@ -6976,8 +6993,6 @@ resolve ( { tabgroupEditor -tabgroupPanel -tab group } ) @@ -6999,7 +7014,7 @@ test_tabGroupPanelAddTab { let { -tabgroupPanel +tabgroupEditor group } = @@ -7009,6 +7024,13 @@ createTabGroupAndOpenEditPanel ) ; let +tabgroupPanel += +tabgroupEditor +. +panel +; +let addNewTabButton = tabgroupPanel @@ -7131,8 +7153,7 @@ test_tabGroupPanelUngroupTabs { let { -tabgroupPanel -tab +tabgroupEditor group } = @@ -7142,6 +7163,23 @@ createTabGroupAndOpenEditPanel ) ; let +tabgroupPanel += +tabgroupEditor +. +panel +; +let +tab += +group +. +tabs +[ +0 +] +; +let ungroupTabsButton = tabgroupPanel @@ -7225,3 +7263,479 @@ tab } ) ; +add_task +( +async +function +test_moveGroupToNewWindow +( +) +{ +let +tabs += +[ +BrowserTestUtils +. +addTab +( +gBrowser +" +about +: +cache +" +{ +skipAnimation +: +true +} +) +BrowserTestUtils +. +addTab +( +gBrowser +" +about +: +robots +" +{ +skipAnimation +: +true +} +) +BrowserTestUtils +. +addTab +( +gBrowser +" +about +: +mozilla +" +{ +skipAnimation +: +true +} +) +] +; +gBrowser +. +selectedTab += +tabs +[ +1 +] +; +let +assertTabsInCorrectOrder += +tabsToCheck += +> +{ +Assert +. +equal +( +tabsToCheck +[ +0 +] +. +linkedBrowser +. +currentURI +. +spec +" +about +: +cache +" +" +about +: +cache +is +first +" +) +; +Assert +. +equal +( +tabsToCheck +[ +1 +] +. +linkedBrowser +. +currentURI +. +spec +" +about +: +robots +" +" +about +: +robots +is +second +" +) +; +Assert +. +equal +( +tabsToCheck +[ +2 +] +. +linkedBrowser +. +currentURI +. +spec +" +about +: +mozilla +" +" +about +: +mozilla +is +third +" +) +; +} +; +let +{ +group +} += +await +createTabGroupAndOpenEditPanel +( +tabs +) +; +let +newWindowOpened += +BrowserTestUtils +. +waitForNewWindow +( +) +; +document +. +getElementById +( +" +tabGroupEditor_moveGroupToNewWindow +" +) +. +click +( +) +; +let +newWin += +await +newWindowOpened +; +Assert +. +ok +( +newWin +! += +window +" +Group +is +moved +to +new +window +" +) +; +let +movedTabs += +newWin +. +gBrowser +. +tabs +; +let +movedGroup += +movedTabs +[ +0 +] +. +group +; +Assert +. +equal +( +movedGroup +. +id +group +. +id +" +Tab +is +in +original +group +" +) +; +Assert +. +equal +( +newWin +. +gBrowser +. +selectedTab +newWin +. +gBrowser +. +tabs +[ +1 +] +" +Second +tab +remains +selected +" +) +; +assertTabsInCorrectOrder +( +newWin +. +gBrowser +. +tabs +) +; +let +tabgroupEditor += +newWin +. +document +. +getElementById +( +" +tab +- +group +- +editor +" +) +; +let +panelOpen += +BrowserTestUtils +. +waitForPopupEvent +( +tabgroupEditor +. +panel +" +shown +" +) +; +tabgroupEditor +. +openEditModal +( +movedGroup +) +; +await +panelOpen +; +let +moveGroupButton += +newWin +. +document +. +getElementById +( +" +tabGroupEditor_moveGroupToNewWindow +" +) +; +Assert +. +ok +( +moveGroupButton +. +disabled +" +Button +is +disabled +when +group +is +only +thing +in +window +" +) +; +let +panelHidden += +BrowserTestUtils +. +waitForPopupEvent +( +tabgroupEditor +. +panel +" +hidden +" +) +; +tabgroupEditor +. +panel +. +hidePopup +( +) +; +await +panelHidden +; +BrowserTestUtils +. +addTab +( +newWin +. +gBrowser +" +about +: +blank +" +{ +skipAnimation +: +true +} +) +; +panelOpen += +BrowserTestUtils +. +waitForPopupEvent +( +tabgroupEditor +. +panel +" +shown +" +) +; +tabgroupEditor +. +openEditModal +( +movedGroup +) +; +await +panelOpen +; +Assert +. +ok +( +! +moveGroupButton +. +disabled +" +Button +is +enabled +again +when +additional +tab +present +" +) +; +await +BrowserTestUtils +. +closeWindow +( +newWin +{ +animate +: +false +} +) +; +} +) +;