2010-07-22 15:31:58 -07:00
|
|
|
var tabstrip = gBrowser.tabContainer.mTabstrip;
|
2009-04-13 23:53:12 -07:00
|
|
|
var scrollbox = tabstrip._scrollbox;
|
|
|
|
var originalSmoothScroll = tabstrip.smoothScroll;
|
2010-07-22 15:31:58 -07:00
|
|
|
var tabs = gBrowser.tabs;
|
2009-04-13 23:53:12 -07:00
|
|
|
|
|
|
|
function rect(ele) ele.getBoundingClientRect();
|
|
|
|
function width(ele) rect(ele).width;
|
2010-06-14 03:06:49 -07:00
|
|
|
function left(ele) rect(ele).left;
|
|
|
|
function right(ele) rect(ele).right;
|
2009-04-13 23:53:12 -07:00
|
|
|
function isLeft(ele, msg) is(left(ele), left(scrollbox), msg);
|
|
|
|
function isRight(ele, msg) is(right(ele), right(scrollbox), msg);
|
|
|
|
function elementFromPoint(x) tabstrip._elementFromPoint(x);
|
|
|
|
function nextLeftElement() elementFromPoint(left(scrollbox) - 1);
|
|
|
|
function nextRightElement() elementFromPoint(right(scrollbox) + 1);
|
2010-07-22 15:31:58 -07:00
|
|
|
function firstScrollable() tabs[gBrowser._numPinnedTabs];
|
2009-04-13 23:53:12 -07:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2009-12-11 21:17:40 -08:00
|
|
|
// If the previous (or more) test finished with cleaning up the tabs,
|
|
|
|
// there may be some pending animations. That can cause a failure of
|
|
|
|
// this tests, so, we should test this in another stack.
|
|
|
|
setTimeout(doTest, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function doTest() {
|
2009-04-13 23:53:12 -07:00
|
|
|
tabstrip.smoothScroll = false;
|
|
|
|
|
2010-07-05 02:40:54 -07:00
|
|
|
var tabMinWidth = parseInt(getComputedStyle(gBrowser.selectedTab, null).minWidth);
|
2009-04-13 23:53:12 -07:00
|
|
|
var tabCountForOverflow = Math.ceil(width(tabstrip) / tabMinWidth * 3);
|
2010-07-22 15:31:58 -07:00
|
|
|
while (tabs.length < tabCountForOverflow)
|
2010-06-14 03:06:49 -07:00
|
|
|
gBrowser.addTab("about:blank", {skipAnimation: true});
|
2010-07-22 15:31:58 -07:00
|
|
|
gBrowser.pinTab(tabs[0]);
|
2009-04-13 23:53:12 -07:00
|
|
|
|
|
|
|
tabstrip.addEventListener("overflow", runOverflowTests, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function runOverflowTests(aEvent) {
|
|
|
|
if (aEvent.detail != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tabstrip.removeEventListener("overflow", runOverflowTests, false);
|
|
|
|
|
|
|
|
var upButton = tabstrip._scrollButtonUp;
|
|
|
|
var downButton = tabstrip._scrollButtonDown;
|
|
|
|
var element;
|
|
|
|
|
2010-07-22 15:31:58 -07:00
|
|
|
gBrowser.selectedTab = firstScrollable();
|
|
|
|
isLeft(firstScrollable(), "Selecting the first tab scrolls it into view");
|
2009-04-13 23:53:12 -07:00
|
|
|
|
|
|
|
element = nextRightElement();
|
2010-07-20 12:05:02 -07:00
|
|
|
EventUtils.synthesizeMouse(downButton, 1, 1, {});
|
2009-04-13 23:53:12 -07:00
|
|
|
isRight(element, "Scrolled one tab to the right with a single click");
|
|
|
|
|
2010-07-22 15:31:58 -07:00
|
|
|
gBrowser.selectedTab = tabs[tabs.length - 1];
|
|
|
|
isRight(gBrowser.selectedTab, "Selecting the last tab scrolls it into view");
|
2009-04-13 23:53:12 -07:00
|
|
|
|
|
|
|
element = nextLeftElement();
|
2010-07-20 12:05:02 -07:00
|
|
|
EventUtils.synthesizeMouse(upButton, 1, 1, {});
|
2009-04-13 23:53:12 -07:00
|
|
|
isLeft(element, "Scrolled one tab to the left with a single click");
|
|
|
|
|
|
|
|
element = elementFromPoint(left(scrollbox) - width(scrollbox));
|
2010-07-20 12:05:02 -07:00
|
|
|
EventUtils.synthesizeMouse(upButton, 1, 1, {clickCount: 2});
|
2009-04-13 23:53:12 -07:00
|
|
|
isLeft(element, "Scrolled one page of tabs with a double click");
|
|
|
|
|
2010-07-20 12:05:02 -07:00
|
|
|
EventUtils.synthesizeMouse(upButton, 1, 1, {clickCount: 3});
|
2010-07-22 15:31:58 -07:00
|
|
|
isLeft(firstScrollable(), "Scrolled to the start with a triple click");
|
2009-04-13 23:53:12 -07:00
|
|
|
|
2010-06-23 10:28:12 -07:00
|
|
|
for (var i = 2; i; i--)
|
2010-07-20 12:05:02 -07:00
|
|
|
EventUtils.synthesizeMouseScroll(scrollbox, 1, 1, {axis: "horizontal", delta: -1});
|
2010-07-22 15:31:58 -07:00
|
|
|
isLeft(firstScrollable(), "Remained at the start with the mouse wheel");
|
2010-06-23 10:28:12 -07:00
|
|
|
|
2009-04-13 23:53:12 -07:00
|
|
|
element = nextRightElement();
|
2010-07-20 12:05:02 -07:00
|
|
|
EventUtils.synthesizeMouseScroll(scrollbox, 1, 1, {axis: "horizontal", delta: 1});
|
2009-04-13 23:53:12 -07:00
|
|
|
isRight(element, "Scrolled one tab to the right with the mouse wheel");
|
|
|
|
|
2010-07-22 15:31:58 -07:00
|
|
|
while (tabs.length > 1)
|
|
|
|
gBrowser.removeTab(tabs[0]);
|
2009-04-13 23:53:12 -07:00
|
|
|
|
|
|
|
tabstrip.smoothScroll = originalSmoothScroll;
|
|
|
|
finish();
|
|
|
|
}
|