browser_overflowScroll.js
Go to the documentation of this file.
1 var tabContainer = gBrowser.tabContainer;
2 var tabstrip = tabContainer.mTabstrip;
3 var scrollbox = tabstrip._scrollbox;
4 var originalSmoothScroll = tabstrip.smoothScroll;
5 
6 function rect(ele) ele.getBoundingClientRect();
7 function width(ele) rect(ele).width;
8 function left(ele) rect(ele).left;
9 function right(ele) rect(ele).right;
10 function isLeft(ele, msg) is(left(ele), left(scrollbox), msg);
11 function isRight(ele, msg) is(right(ele), right(scrollbox), msg);
12 function elementFromPoint(x) tabstrip._elementFromPoint(x);
13 function nextLeftElement() elementFromPoint(left(scrollbox) - 1);
14 function nextRightElement() elementFromPoint(right(scrollbox) + 1);
15 
16 function test() {
18 
19  tabstrip.smoothScroll = false;
20 
21  var tabMinWidth = gPrefService.getIntPref("browser.tabs.tabMinWidth");
22  var tabCountForOverflow = Math.ceil(width(tabstrip) / tabMinWidth * 3);
23  while (tabContainer.childNodes.length < tabCountForOverflow)
24  gBrowser.addTab();
25 
26  tabstrip.addEventListener("overflow", runOverflowTests, false);
27 }
28 
29 function runOverflowTests(aEvent) {
30  if (aEvent.detail != 1)
31  return;
32 
33  tabstrip.removeEventListener("overflow", runOverflowTests, false);
34 
35  var upButton = tabstrip._scrollButtonUp;
36  var downButton = tabstrip._scrollButtonDown;
37  var element;
38 
39  gBrowser.selectedTab = tabContainer.firstChild;
40  isLeft(tabContainer.firstChild, "Selecting the first tab scrolls it into view");
41 
42  element = nextRightElement();
43  EventUtils.synthesizeMouse(downButton, 0, 0, {});
44  isRight(element, "Scrolled one tab to the right with a single click");
45 
46  gBrowser.selectedTab = tabContainer.lastChild;
47  isRight(tabContainer.lastChild, "Selecting the last tab scrolls it into view");
48 
49  element = nextLeftElement();
50  EventUtils.synthesizeMouse(upButton, 0, 0, {});
51  isLeft(element, "Scrolled one tab to the left with a single click");
52 
54  EventUtils.synthesizeMouse(upButton, 0, 0, {clickCount: 2});
55  isLeft(element, "Scrolled one page of tabs with a double click");
56 
57  EventUtils.synthesizeMouse(upButton, 0, 0, {clickCount: 3});
58  isLeft(tabContainer.firstChild, "Scrolled to the start with a triple click");
59 
60  element = nextRightElement();
61  EventUtils.synthesizeMouseScroll(scrollbox, 0, 0, {delta: 1});
62  isRight(element, "Scrolled one tab to the right with the mouse wheel");
63 
64  while (tabContainer.childNodes.length > 1)
65  gBrowser.removeTab(tabContainer.lastChild);
66 
67  tabstrip.smoothScroll = originalSmoothScroll;
68  finish();
69 }
function nextLeftElement() elementFromPoint(left(scrollbox)-1)
function isLeft(ele, msg) is(left(ele)
function isRight(ele, msg) is(right(ele)
function right(ele) rect(ele).right
function width(ele) rect(ele).width
function test()
waitForExplicitFinish()
function rect(ele) ele.getBoundingClientRect()
function nextRightElement() elementFromPoint(right(scrollbox)+1)
var originalSmoothScroll
function left(ele) rect(ele).left
var tabContainer
function elementFromPoint(x) tabstrip._elementFromPoint(x)
var tabstrip
var scrollbox
var gPrefService
Definition: overlay.js:34
function runOverflowTests(aEvent)
function msg