Skip to content

Commit

Permalink
Merge autoland to mozilla-central. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ncsoregi committed Aug 31, 2022
2 parents fa81b64 + 088c86b commit 96187d1
Show file tree
Hide file tree
Showing 205 changed files with 6,737 additions and 2,458 deletions.
3 changes: 3 additions & 0 deletions browser/base/content/browser-allTabsMenu.inc.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
oncommand="PanelUI.showSubView('allTabsMenu-hiddenTabsView', this);"
data-l10n-id="all-tabs-menu-hidden-tabs"/>
<toolbarseparator id="allTabsMenu-tabsSeparator"/>
<vbox id="allTabsMenu-dropIndicatorHolder">
<vbox id="allTabsMenu-dropIndicator" collapsed="true"/>
</vbox>
<vbox id="allTabsMenu-allTabsViewTabs" class="panel-subview-body"/>
</vbox>
</panelview>
Expand Down
2 changes: 2 additions & 0 deletions browser/base/content/browser-allTabsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var gTabsPanel = {
allTabsButton: "alltabs-button",
allTabsView: "allTabsMenu-allTabsView",
allTabsViewTabs: "allTabsMenu-allTabsViewTabs",
dropIndicator: "allTabsMenu-dropIndicator",
containerTabsView: "allTabsMenu-containerTabsView",
hiddenTabsButton: "allTabsMenu-hiddenTabsButton",
hiddenTabsView: "allTabsMenu-hiddenTabsView",
Expand Down Expand Up @@ -56,6 +57,7 @@ var gTabsPanel = {
containerNode: this.allTabsViewTabs,
filterFn: tab =>
!tab.hidden && (!tab.pinned || (showPinnedTabs && tab.pinned)),
dropIndicator: this.dropIndicator,
});

this.allTabsView.addEventListener("ViewShowing", e => {
Expand Down
16 changes: 16 additions & 0 deletions browser/base/content/browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,22 @@ toolbarpaletteitem[place="palette"] > #personal-bookmarks > #bookmarks-toolbar-b
position: absolute;
}

#allTabsMenu-dropIndicatorHolder {
display: block;
position: relative;
}

#allTabsMenu-dropIndicator {
background: url(chrome://browser/skin/tabbrowser/tab-drag-indicator.svg) no-repeat center;
display: block;
position: absolute;
transform: rotate(-90deg);
width: 12px;
height: 29px;
left: 8px;
top: 0;
}

#nav-bar-customization-target > #personal-bookmarks,
toolbar:not(#TabsToolbar) > #wrapper-personal-bookmarks,
toolbar:not(#TabsToolbar) > #personal-bookmarks {
Expand Down
23 changes: 17 additions & 6 deletions browser/base/content/tabbrowser-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@
return;
}

this.startTabDrag(event, tab);
}

startTabDrag(event, tab, { fromTabList = false } = {}) {
let selectedTabs = gBrowser.selectedTabs;
let otherSelectedTabs = selectedTabs.filter(
selectedTab => selectedTab != tab
Expand Down Expand Up @@ -529,13 +533,14 @@
movingTabs: (tab.multiselected ? gBrowser.selectedTabs : [tab]).filter(
t => t.pinned == tab.pinned
),
fromTabList,
};

event.stopPropagation();
}

on_dragover(event) {
var effects = this._getDropEffectForTabDrag(event);
var effects = this.getDropEffectForTabDrag(event);

var ind = this._tabDropIndicator;
if (effects == "" || effects == "none") {
Expand Down Expand Up @@ -571,7 +576,8 @@
let draggedTab = event.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0);
if (
(effects == "move" || effects == "copy") &&
this == draggedTab.container
this == draggedTab.container &&
!draggedTab._dragData.fromTabList
) {
ind.hidden = true;

Expand Down Expand Up @@ -692,9 +698,14 @@
newTranslateX -= tabWidth;
}

let dropIndex =
"animDropIndex" in draggedTab._dragData &&
draggedTab._dragData.animDropIndex;
let dropIndex;
if (draggedTab._dragData.fromTabList) {
dropIndex = this._getDropIndex(event, false);
} else {
dropIndex =
"animDropIndex" in draggedTab._dragData &&
draggedTab._dragData.animDropIndex;
}
let incrementDropIndex = true;
if (dropIndex && dropIndex > movingTabs[0]._tPos) {
dropIndex--;
Expand Down Expand Up @@ -1982,7 +1993,7 @@
return tabs.length;
}

_getDropEffectForTabDrag(event) {
getDropEffectForTabDrag(event) {
var dt = event.dataTransfer;

let isMovingTabs = dt.mozItemCount > 0;
Expand Down
2 changes: 2 additions & 0 deletions browser/base/content/test/performance/browser_tabdetach.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const EXPECTED_REFLOWS = [
{
stack: [
"clientX@chrome://browser/content/tabbrowser-tabs.js",
"startTabDrag@chrome://browser/content/tabbrowser-tabs.js",
"on_dragstart@chrome://browser/content/tabbrowser-tabs.js",
"handleEvent@chrome://browser/content/tabbrowser-tabs.js",
"synthesizeMouseAtPoint@chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
Expand All @@ -24,6 +25,7 @@ const EXPECTED_REFLOWS = [

{
stack: [
"startTabDrag@chrome://browser/content/tabbrowser-tabs.js",
"on_dragstart@chrome://browser/content/tabbrowser-tabs.js",
"handleEvent@chrome://browser/content/tabbrowser-tabs.js",
"synthesizeMouseAtPoint@chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
Expand Down
1 change: 1 addition & 0 deletions browser/base/content/test/tabs/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,4 @@ skip-if = (verify && os == 'mac')
[browser_bfcache_exemption_about_pages.js]
skip-if = !fission
[browser_tab_tooltips.js]
[browser_tab_manager_drag.js]
226 changes: 226 additions & 0 deletions browser/base/content/test/tabs/browser_tab_manager_drag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
/**
* Test reordering the tabs in the Tab Manager, moving the tab between the
* Tab Manager and tab bar.
*/

"use strict";

const URL1 = "data:text/plain,tab1";
const URL2 = "data:text/plain,tab2";
const URL3 = "data:text/plain,tab3";
const URL4 = "data:text/plain,tab4";
const URL5 = "data:text/plain,tab5";

function assertOrder(order, expected, message) {
is(
JSON.stringify(order),
JSON.stringify(expected),
`The order of the tabs ${message}`
);
}

function toIndex(url) {
const m = url.match(/^data:text\/plain,tab(\d)/);
if (m) {
return parseInt(m[1]);
}
return 0;
}

function getOrderOfList(list) {
return [...list.querySelectorAll("toolbaritem")].map(row => {
const url = row.firstElementChild.tab.linkedBrowser.currentURI.spec;
return toIndex(url);
});
}

function getOrderOfTabs(tabs) {
return tabs.map(tab => {
const url = tab.linkedBrowser.currentURI.spec;
return toIndex(url);
});
}

async function testWithNewWindow(func) {
Services.prefs.setBoolPref("browser.tabs.tabmanager.enabled", true);

const newWindow = await BrowserTestUtils.openNewWindowWithFlushedCacheForMozSupports();

await Promise.all([
addTabTo(newWindow.gBrowser, URL1),
addTabTo(newWindow.gBrowser, URL2),
addTabTo(newWindow.gBrowser, URL3),
addTabTo(newWindow.gBrowser, URL4),
addTabTo(newWindow.gBrowser, URL5),
]);

newWindow.gTabsPanel.init();

const button = newWindow.document.getElementById("alltabs-button");

const allTabsView = newWindow.document.getElementById(
"allTabsMenu-allTabsView"
);
const allTabsPopupShownPromise = BrowserTestUtils.waitForEvent(
allTabsView,
"ViewShown"
);
button.click();
await allTabsPopupShownPromise;

await func(newWindow);

await BrowserTestUtils.closeWindow(newWindow);

Services.prefs.clearUserPref("browser.tabs.tabmanager.enabled");
}

add_task(async function test_reorder() {
await testWithNewWindow(async function(newWindow) {
const list = newWindow.document.getElementById(
"allTabsMenu-allTabsViewTabs"
);

assertOrder(getOrderOfList(list), [0, 1, 2, 3, 4, 5], "before reorder");

let rows;
rows = list.querySelectorAll("toolbaritem");
EventUtils.synthesizeDrop(
rows[3],
rows[1],
null,
"move",
newWindow,
newWindow,
{ clientX: 0, clientY: 0 }
);

assertOrder(getOrderOfList(list), [0, 3, 1, 2, 4, 5], "after moving up");

rows = list.querySelectorAll("toolbaritem");
EventUtils.synthesizeDrop(
rows[1],
rows[5],
null,
"move",
newWindow,
newWindow,
{ clientX: 0, clientY: 0 }
);

assertOrder(getOrderOfList(list), [0, 1, 2, 4, 3, 5], "after moving down");

rows = list.querySelectorAll("toolbaritem");
EventUtils.synthesizeDrop(
rows[4],
rows[3],
null,
"move",
newWindow,
newWindow,
{ clientX: 0, clientY: 0 }
);

assertOrder(
getOrderOfList(list),
[0, 1, 2, 3, 4, 5],
"after moving up again"
);
});
});

function tabOf(row) {
return row.firstElementChild.tab;
}

add_task(async function test_move_to_tab_bar() {
await testWithNewWindow(async function(newWindow) {
const list = newWindow.document.getElementById(
"allTabsMenu-allTabsViewTabs"
);

assertOrder(getOrderOfList(list), [0, 1, 2, 3, 4, 5], "before reorder");

let rows;
rows = list.querySelectorAll("toolbaritem");
EventUtils.synthesizeDrop(
rows[3],
tabOf(rows[1]),
null,
"move",
newWindow,
newWindow,
{ clientX: 0, clientY: 0 }
);

assertOrder(
getOrderOfList(list),
[0, 3, 1, 2, 4, 5],
"after moving up with tab bar"
);

rows = list.querySelectorAll("toolbaritem");
EventUtils.synthesizeDrop(
rows[1],
tabOf(rows[4]),
null,
"move",
newWindow,
newWindow,
{ clientX: 0, clientY: 0 }
);

assertOrder(
getOrderOfList(list),
[0, 1, 2, 3, 4, 5],
"after moving down with tab bar"
);
});
});

add_task(async function test_move_to_different_tab_bar() {
const newWindow2 = await BrowserTestUtils.openNewWindowWithFlushedCacheForMozSupports();

await testWithNewWindow(async function(newWindow) {
const list = newWindow.document.getElementById(
"allTabsMenu-allTabsViewTabs"
);

assertOrder(
getOrderOfList(list),
[0, 1, 2, 3, 4, 5],
"before reorder in newWindow"
);
assertOrder(
getOrderOfTabs(newWindow2.gBrowser.tabs),
[0],
"before reorder in newWindow2"
);

let rows;
rows = list.querySelectorAll("toolbaritem");
EventUtils.synthesizeDrop(
rows[3],
newWindow2.gBrowser.tabs[0],
null,
"move",
newWindow,
newWindow2,
{ clientX: 0, clientY: 0 }
);

assertOrder(
getOrderOfList(list),
[0, 1, 2, 4, 5],
"after moving to other window in newWindow"
);

assertOrder(
getOrderOfTabs(newWindow2.gBrowser.tabs),
[3, 0],
"after moving to other window in newWindow2"
);
});

await BrowserTestUtils.closeWindow(newWindow2);
});
14 changes: 11 additions & 3 deletions browser/base/content/test/tabs/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@ function triggerClickOn(target, options) {
return promise;
}

async function addTab(url = "http://mochi.test:8888/", params = {}) {
async function addTab(url = "http://mochi.test:8888/", params) {
return addTabTo(gBrowser, url, params);
}

async function addTabTo(
targetBrowser,
url = "http://mochi.test:8888/",
params = {}
) {
params.skipAnimation = true;
const tab = BrowserTestUtils.addTab(gBrowser, url, params);
const browser = gBrowser.getBrowserForTab(tab);
const tab = BrowserTestUtils.addTab(targetBrowser, url, params);
const browser = targetBrowser.getBrowserForTab(tab);
await BrowserTestUtils.browserLoaded(browser);
return tab;
}
Expand Down
Loading

0 comments on commit 96187d1

Please sign in to comment.