|
1 var tab1, tab2; |
|
2 |
|
3 function focus_in_navbar() |
|
4 { |
|
5 var parent = document.activeElement.parentNode; |
|
6 while (parent && parent.id != "nav-bar") |
|
7 parent = parent.parentNode; |
|
8 |
|
9 return parent != null; |
|
10 } |
|
11 |
|
12 function test() |
|
13 { |
|
14 waitForExplicitFinish(); |
|
15 |
|
16 tab1 = gBrowser.addTab("about:blank", {skipAnimation: true}); |
|
17 tab2 = gBrowser.addTab("about:blank", {skipAnimation: true}); |
|
18 |
|
19 EventUtils.synthesizeMouseAtCenter(tab1, {}); |
|
20 setTimeout(step2, 0); |
|
21 } |
|
22 |
|
23 function step2() |
|
24 { |
|
25 is(gBrowser.selectedTab, tab1, "1st click on tab1 selects tab"); |
|
26 isnot(document.activeElement, tab1, "1st click on tab1 does not activate tab"); |
|
27 |
|
28 EventUtils.synthesizeMouseAtCenter(tab1, {}); |
|
29 setTimeout(step3, 0); |
|
30 } |
|
31 |
|
32 function step3() |
|
33 { |
|
34 is(gBrowser.selectedTab, tab1, "2nd click on selected tab1 keeps tab selected"); |
|
35 isnot(document.activeElement, tab1, "2nd click on selected tab1 does not activate tab"); |
|
36 |
|
37 ok(true, "focusing URLBar then sending 1 Shift+Tab."); |
|
38 gURLBar.focus(); |
|
39 EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); |
|
40 is(gBrowser.selectedTab, tab1, "tab key to selected tab1 keeps tab selected"); |
|
41 is(document.activeElement, tab1, "tab key to selected tab1 activates tab"); |
|
42 |
|
43 EventUtils.synthesizeMouseAtCenter(tab1, {}); |
|
44 setTimeout(step4, 0); |
|
45 } |
|
46 |
|
47 function step4() |
|
48 { |
|
49 is(gBrowser.selectedTab, tab1, "3rd click on activated tab1 keeps tab selected"); |
|
50 is(document.activeElement, tab1, "3rd click on activated tab1 keeps tab activated"); |
|
51 |
|
52 EventUtils.synthesizeMouseAtCenter(tab2, {}); |
|
53 setTimeout(step5, 0); |
|
54 } |
|
55 |
|
56 function step5() |
|
57 { |
|
58 // The tabbox selects a tab within a setTimeout in a bubbling mousedown event |
|
59 // listener, and focuses the current tab if another tab previously had focus. |
|
60 is(gBrowser.selectedTab, tab2, "click on tab2 while tab1 is activated selects tab"); |
|
61 is(document.activeElement, tab2, "click on tab2 while tab1 is activated activates tab"); |
|
62 |
|
63 ok(true, "focusing content then sending middle-button mousedown to tab2."); |
|
64 gBrowser.selectedBrowser.focus(); |
|
65 EventUtils.synthesizeMouseAtCenter(tab2, {button: 1, type: "mousedown"}); |
|
66 setTimeout(step6, 0); |
|
67 } |
|
68 |
|
69 function step6() |
|
70 { |
|
71 is(gBrowser.selectedTab, tab2, "middle-button mousedown on selected tab2 keeps tab selected"); |
|
72 isnot(document.activeElement, tab2, "middle-button mousedown on selected tab2 does not activate tab"); |
|
73 |
|
74 gBrowser.removeTab(tab2); |
|
75 gBrowser.removeTab(tab1); |
|
76 |
|
77 finish(); |
|
78 } |