Bug 1956458 - Unpin tabs when they are added to a group. r=dao,tabbrowser-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D247597
This commit is contained in:
@@ -8864,10 +8864,9 @@ var TabContextMenu = {
|
|||||||
let contextUngroupTab = document.getElementById("context_ungroupTab");
|
let contextUngroupTab = document.getElementById("context_ungroupTab");
|
||||||
|
|
||||||
if (gBrowser._tabGroupsEnabled) {
|
if (gBrowser._tabGroupsEnabled) {
|
||||||
let groupableTabs = this.contextTabs.filter(t => !t.pinned);
|
|
||||||
let selectedGroupCount = new Set(
|
let selectedGroupCount = new Set(
|
||||||
// The filter removes the "null" group for ungrouped tabs.
|
// The filter removes the "null" group for ungrouped tabs.
|
||||||
groupableTabs.map(t => t.group).filter(g => g)
|
this.contextTabs.map(t => t.group).filter(g => g)
|
||||||
).size;
|
).size;
|
||||||
|
|
||||||
let availableGroupsToMoveTo = gBrowser
|
let availableGroupsToMoveTo = gBrowser
|
||||||
@@ -8879,16 +8878,13 @@ var TabContextMenu = {
|
|||||||
// Determine whether or not the "current" tab group should appear in the
|
// Determine whether or not the "current" tab group should appear in the
|
||||||
// "move tab to group" context menu.
|
// "move tab to group" context menu.
|
||||||
if (selectedGroupCount == 1) {
|
if (selectedGroupCount == 1) {
|
||||||
let groupToFilter = groupableTabs[0].group;
|
let groupToFilter = this.contextTabs[0].group;
|
||||||
if (groupToFilter && groupableTabs.every(t => t.group)) {
|
if (groupToFilter && this.contextTabs.every(t => t.group)) {
|
||||||
availableGroupsToMoveTo = availableGroupsToMoveTo.filter(
|
availableGroupsToMoveTo = availableGroupsToMoveTo.filter(
|
||||||
group => group !== groupToFilter
|
group => group !== groupToFilter
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contextMoveTabToGroup.disabled = !groupableTabs.length;
|
|
||||||
contextMoveTabToNewGroup.disabled = !groupableTabs.length;
|
|
||||||
if (!availableGroupsToMoveTo.length) {
|
if (!availableGroupsToMoveTo.length) {
|
||||||
contextMoveTabToGroup.hidden = true;
|
contextMoveTabToGroup.hidden = true;
|
||||||
contextMoveTabToNewGroup.hidden = false;
|
contextMoveTabToNewGroup.hidden = false;
|
||||||
|
|||||||
@@ -305,6 +305,11 @@
|
|||||||
* Optional context to record for metrics purposes.
|
* Optional context to record for metrics purposes.
|
||||||
*/
|
*/
|
||||||
addTabs(tabs, metricsContext) {
|
addTabs(tabs, metricsContext) {
|
||||||
|
for (let tab of tabs) {
|
||||||
|
if (tab.pinned) {
|
||||||
|
tab.ownerGlobal.gBrowser.unpinTab(tab);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (let tab of tabs) {
|
for (let tab of tabs) {
|
||||||
let tabToMove =
|
let tabToMove =
|
||||||
this.ownerGlobal === tab.ownerGlobal
|
this.ownerGlobal === tab.ownerGlobal
|
||||||
|
|||||||
@@ -67,22 +67,31 @@ add_task(async function test_tabGroupCreateAndAddTabAtPosition() {
|
|||||||
|
|
||||||
add_task(async function test_pinned() {
|
add_task(async function test_pinned() {
|
||||||
let tab1 = BrowserTestUtils.addTab(gBrowser, "about:blank");
|
let tab1 = BrowserTestUtils.addTab(gBrowser, "about:blank");
|
||||||
gBrowser.pinTab(tab1);
|
|
||||||
let group = gBrowser.addTabGroup([tab1]);
|
|
||||||
Assert.ok(
|
|
||||||
!group,
|
|
||||||
"addTabGroup shouldn't create a group when only supplied with pinned tabs"
|
|
||||||
);
|
|
||||||
|
|
||||||
let tab2 = BrowserTestUtils.addTab(gBrowser, "about:blank");
|
let tab2 = BrowserTestUtils.addTab(gBrowser, "about:blank");
|
||||||
|
gBrowser.pinTab(tab1);
|
||||||
|
gBrowser.pinTab(tab2);
|
||||||
|
Assert.ok(tab1.pinned, "Tab1 is pinned");
|
||||||
|
Assert.ok(tab2.pinned, "Tab2 is pinned");
|
||||||
|
let group = gBrowser.addTabGroup([tab1, tab2]);
|
||||||
|
Assert.equal(
|
||||||
|
group.tabs.length,
|
||||||
|
2,
|
||||||
|
"addTabGroup creates a group when only supplied with pinned tabs"
|
||||||
|
);
|
||||||
|
Assert.ok(!tab1.pinned, "Tab1 is no longer pinned");
|
||||||
|
Assert.ok(!tab2.pinned, "Tab2 is no longer pinned");
|
||||||
|
group.ungroupTabs();
|
||||||
|
gBrowser.pinTab(tab1);
|
||||||
|
Assert.ok(tab1.pinned, "Tab1 is pinned again");
|
||||||
|
|
||||||
group = gBrowser.addTabGroup([tab1, tab2]);
|
group = gBrowser.addTabGroup([tab1, tab2]);
|
||||||
Assert.ok(
|
Assert.ok(
|
||||||
group,
|
group,
|
||||||
"addTabGroup should create a group when supplied with both pinned and non-pinned tabs"
|
"addTabGroup should create a group when supplied with both pinned and non-pinned tabs"
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.equal(group.tabs.length, 1, "group has only the non-pinned tab");
|
Assert.equal(group.tabs.length, 2, "group contains both tabs");
|
||||||
Assert.equal(group.tabs[0], tab2, "tab2 is in group");
|
Assert.ok(!tab1.pinned, "tab1 is no longer pinned");
|
||||||
|
|
||||||
BrowserTestUtils.removeTab(tab1);
|
BrowserTestUtils.removeTab(tab1);
|
||||||
await removeTabGroup(group);
|
await removeTabGroup(group);
|
||||||
|
|||||||
Reference in New Issue
Block a user