|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 let win; |
|
5 let cw; |
|
6 |
|
7 function test() { |
|
8 waitForExplicitFinish(); |
|
9 |
|
10 let onLoad = function (tvwin) { |
|
11 win = tvwin; |
|
12 registerCleanupFunction(function () win.close()); |
|
13 win.gBrowser.loadOneTab("http://mochi.test:8888/", {inBackground: true}); |
|
14 }; |
|
15 |
|
16 let onShow = function () { |
|
17 cw = win.TabView.getContentWindow(); |
|
18 ok(win.TabView.isVisible(), "Tab View is visible"); |
|
19 afterAllTabItemsUpdated(testOne, win); |
|
20 }; |
|
21 |
|
22 newWindowWithTabView(onShow, onLoad); |
|
23 } |
|
24 |
|
25 function testOne() { |
|
26 hideSearchWhenSearchEnabled(testTwo); |
|
27 // press cmd/ctrl F |
|
28 EventUtils.synthesizeKey("f", {accelKey: true}, cw); |
|
29 } |
|
30 |
|
31 function testTwo() { |
|
32 hideSearchWhenSearchEnabled(testThree); |
|
33 // press / |
|
34 EventUtils.synthesizeKey("VK_SLASH", {}, cw); |
|
35 } |
|
36 |
|
37 function testThree() { |
|
38 ok(win.TabView.isVisible(), "Tab View is visible"); |
|
39 // create another group with a tab. |
|
40 let groupItem = createGroupItemWithBlankTabs(win, 300, 300, 200, 1); |
|
41 is(cw.UI.getActiveTab(), groupItem.getChild(0), |
|
42 "The active tab is newly created tab item"); |
|
43 |
|
44 whenSearchIsEnabled(function () { |
|
45 let doc = cw.document; |
|
46 let searchBox = cw.iQ("#searchbox"); |
|
47 let hasFocus = doc.hasFocus() && doc.activeElement == searchBox[0]; |
|
48 ok(hasFocus, "The search box has focus"); |
|
49 |
|
50 let tab = win.gBrowser.tabs[1]; |
|
51 searchBox.val(tab._tabViewTabItem.$tabTitle[0].innerHTML); |
|
52 |
|
53 cw.Search.perform(); |
|
54 |
|
55 whenTabViewIsHidden(function () { |
|
56 is(tab, win.gBrowser.selectedTab, "The search result tab is shown"); |
|
57 finish() |
|
58 }, win); |
|
59 |
|
60 // use the tabview menu (the same as pressing cmd/ctrl + e) |
|
61 win.document.getElementById("menu_tabview").doCommand(); |
|
62 }, win); |
|
63 EventUtils.synthesizeKey("VK_SLASH", {}, cw); |
|
64 } |
|
65 |
|
66 function hideSearchWhenSearchEnabled(callback) { |
|
67 whenSearchIsEnabled(function() { |
|
68 hideSearch(callback, win); |
|
69 }, win); |
|
70 } |
|
71 |