forked from mirrors/gecko-dev
Bug 1791439 - Reuse overflowTabs test function. r=tgiles
Differential Revision: https://phabricator.services.mozilla.com/D158090
This commit is contained in:
parent
f3295cc62d
commit
eb54efca2b
2 changed files with 10 additions and 11 deletions
|
|
@ -15,7 +15,9 @@ add_task(async function() {
|
||||||
|
|
||||||
let width = ele => ele.getBoundingClientRect().width;
|
let width = ele => ele.getBoundingClientRect().width;
|
||||||
|
|
||||||
let tabCountForOverflow = Math.ceil(width(arrowScrollbox) / tabMinWidth);
|
let tabCountForOverflow = Math.ceil(
|
||||||
|
(width(arrowScrollbox) / tabMinWidth) * 1.1
|
||||||
|
);
|
||||||
|
|
||||||
let newTab1 = (gBrowser.selectedTab = BrowserTestUtils.addTab(
|
let newTab1 = (gBrowser.selectedTab = BrowserTestUtils.addTab(
|
||||||
gBrowser,
|
gBrowser,
|
||||||
|
|
@ -33,9 +35,7 @@ add_task(async function() {
|
||||||
{ skipAnimation: true }
|
{ skipAnimation: true }
|
||||||
));
|
));
|
||||||
|
|
||||||
while (gBrowser.tabs.length < tabCountForOverflow) {
|
await BrowserTestUtils.overflowTabs(registerCleanupFunction, window, false);
|
||||||
BrowserTestUtils.addTab(gBrowser, "about:blank", { skipAnimation: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
registerCleanupFunction(function() {
|
registerCleanupFunction(function() {
|
||||||
while (gBrowser.tabs.length > initialTabsLength) {
|
while (gBrowser.tabs.length > initialTabsLength) {
|
||||||
|
|
|
||||||
|
|
@ -1836,8 +1836,12 @@ var BrowserTestUtils = {
|
||||||
* function, allowing us to clean up after you if necessary.
|
* function, allowing us to clean up after you if necessary.
|
||||||
* @param win {Window}
|
* @param win {Window}
|
||||||
* The window where the tabs need to be overflowed.
|
* The window where the tabs need to be overflowed.
|
||||||
|
* @param overflowAtStart {boolean}
|
||||||
|
* Determines whether the new tabs are added at the beginning of the
|
||||||
|
* URL bar or at the end of it.
|
||||||
*/
|
*/
|
||||||
async overflowTabs(registerCleanupFunction, win) {
|
async overflowTabs(registerCleanupFunction, win, overflowAtStart = true) {
|
||||||
|
let index = overflowAtStart ? 0 : undefined;
|
||||||
let { gBrowser } = win;
|
let { gBrowser } = win;
|
||||||
let arrowScrollbox = gBrowser.tabContainer.arrowScrollbox;
|
let arrowScrollbox = gBrowser.tabContainer.arrowScrollbox;
|
||||||
const originalSmoothScroll = arrowScrollbox.smoothScroll;
|
const originalSmoothScroll = arrowScrollbox.smoothScroll;
|
||||||
|
|
@ -1856,14 +1860,9 @@ var BrowserTestUtils = {
|
||||||
while (gBrowser.tabs.length < tabCountForOverflow) {
|
while (gBrowser.tabs.length < tabCountForOverflow) {
|
||||||
BrowserTestUtils.addTab(gBrowser, "about:blank", {
|
BrowserTestUtils.addTab(gBrowser, "about:blank", {
|
||||||
skipAnimation: true,
|
skipAnimation: true,
|
||||||
index: 0,
|
index,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure scrolling finished.
|
|
||||||
await new Promise(resolve => {
|
|
||||||
arrowScrollbox.addEventListener("scrollend", resolve, { once: true });
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue