2009-03-09 10:52:22 -07:00
|
|
|
var tab1, tab2;
|
|
|
|
|
2011-12-13 06:17:57 -08:00
|
|
|
function focus_in_navbar()
|
|
|
|
{
|
2010-06-24 15:01:27 -07:00
|
|
|
var parent = document.activeElement.parentNode;
|
|
|
|
while (parent && parent.id != "nav-bar")
|
|
|
|
parent = parent.parentNode;
|
|
|
|
|
2011-12-13 06:17:57 -08:00
|
|
|
return parent != null;
|
2010-06-24 15:01:27 -07:00
|
|
|
}
|
|
|
|
|
2011-12-13 06:17:57 -08:00
|
|
|
function test()
|
|
|
|
{
|
2009-03-09 10:52:22 -07:00
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2010-06-14 01:10:54 -07:00
|
|
|
tab1 = gBrowser.addTab("about:blank", {skipAnimation: true});
|
|
|
|
tab2 = gBrowser.addTab("about:blank", {skipAnimation: true});
|
2009-03-09 10:52:22 -07:00
|
|
|
|
2010-10-11 11:03:12 -07:00
|
|
|
EventUtils.synthesizeMouseAtCenter(tab1, {});
|
2009-03-09 10:52:22 -07:00
|
|
|
setTimeout(step2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function step2()
|
|
|
|
{
|
2011-12-13 06:17:57 -08:00
|
|
|
is(gBrowser.selectedTab, tab1, "1st click on tab1 selects tab");
|
|
|
|
isnot(document.activeElement, tab1, "1st click on tab1 does not activate tab");
|
2009-03-09 10:52:22 -07:00
|
|
|
|
2010-10-11 11:03:12 -07:00
|
|
|
EventUtils.synthesizeMouseAtCenter(tab1, {});
|
2009-03-09 10:52:22 -07:00
|
|
|
setTimeout(step3, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function step3()
|
|
|
|
{
|
2011-12-13 06:17:57 -08:00
|
|
|
is(gBrowser.selectedTab, tab1, "2nd click on selected tab1 keeps tab selected");
|
|
|
|
isnot(document.activeElement, tab1, "2nd click on selected tab1 does not activate tab");
|
2009-03-09 10:52:22 -07:00
|
|
|
|
2013-06-04 15:08:55 -07:00
|
|
|
ok(true, "focusing URLBar then sending 1 Shift+Tab.");
|
|
|
|
gURLBar.focus();
|
|
|
|
EventUtils.synthesizeKey("VK_TAB", {shiftKey: true});
|
2011-12-13 06:17:57 -08:00
|
|
|
is(gBrowser.selectedTab, tab1, "tab key to selected tab1 keeps tab selected");
|
|
|
|
is(document.activeElement, tab1, "tab key to selected tab1 activates tab");
|
2009-03-09 10:52:22 -07:00
|
|
|
|
2010-10-11 11:03:12 -07:00
|
|
|
EventUtils.synthesizeMouseAtCenter(tab1, {});
|
2009-05-14 11:57:00 -07:00
|
|
|
setTimeout(step4, 0);
|
2009-03-09 10:52:22 -07:00
|
|
|
}
|
|
|
|
|
2009-05-14 11:57:00 -07:00
|
|
|
function step4()
|
2009-03-09 10:52:22 -07:00
|
|
|
{
|
2011-12-13 06:17:57 -08:00
|
|
|
is(gBrowser.selectedTab, tab1, "3rd click on activated tab1 keeps tab selected");
|
|
|
|
is(document.activeElement, tab1, "3rd click on activated tab1 keeps tab activated");
|
2009-03-09 10:52:22 -07:00
|
|
|
|
2010-10-11 11:03:12 -07:00
|
|
|
EventUtils.synthesizeMouseAtCenter(tab2, {});
|
2009-05-14 11:57:00 -07:00
|
|
|
setTimeout(step5, 0);
|
2009-03-09 10:52:22 -07:00
|
|
|
}
|
|
|
|
|
2009-05-14 11:57:00 -07:00
|
|
|
function step5()
|
2009-03-09 10:52:22 -07:00
|
|
|
{
|
|
|
|
// The tabbox selects a tab within a setTimeout in a bubbling mousedown event
|
2011-12-13 06:17:57 -08:00
|
|
|
// listener, and focuses the current tab if another tab previously had focus.
|
|
|
|
is(gBrowser.selectedTab, tab2, "click on tab2 while tab1 is activated selects tab");
|
|
|
|
is(document.activeElement, tab2, "click on tab2 while tab1 is activated activates tab");
|
2009-03-09 10:52:22 -07:00
|
|
|
|
2011-12-13 06:17:57 -08:00
|
|
|
ok(true, "focusing content then sending middle-button mousedown to tab2.");
|
2012-09-19 03:59:26 -07:00
|
|
|
gBrowser.selectedBrowser.focus();
|
2010-10-11 11:03:12 -07:00
|
|
|
EventUtils.synthesizeMouseAtCenter(tab2, {button: 1, type: "mousedown"});
|
2009-05-15 15:15:46 -07:00
|
|
|
setTimeout(step6, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function step6()
|
|
|
|
{
|
2011-12-13 06:17:57 -08:00
|
|
|
is(gBrowser.selectedTab, tab2, "middle-button mousedown on selected tab2 keeps tab selected");
|
|
|
|
isnot(document.activeElement, tab2, "middle-button mousedown on selected tab2 does not activate tab");
|
2009-05-15 15:15:46 -07:00
|
|
|
|
2009-03-09 10:52:22 -07:00
|
|
|
gBrowser.removeTab(tab2);
|
2011-12-13 06:17:57 -08:00
|
|
|
gBrowser.removeTab(tab1);
|
2009-03-09 10:52:22 -07:00
|
|
|
|
|
|
|
finish();
|
|
|
|
}
|