michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let win; michael@0: let cw; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let onLoad = function (tvwin) { michael@0: win = tvwin; michael@0: registerCleanupFunction(function () win.close()); michael@0: win.gBrowser.loadOneTab("http://mochi.test:8888/", {inBackground: true}); michael@0: }; michael@0: michael@0: let onShow = function () { michael@0: cw = win.TabView.getContentWindow(); michael@0: ok(win.TabView.isVisible(), "Tab View is visible"); michael@0: afterAllTabItemsUpdated(testOne, win); michael@0: }; michael@0: michael@0: newWindowWithTabView(onShow, onLoad); michael@0: } michael@0: michael@0: function testOne() { michael@0: hideSearchWhenSearchEnabled(testTwo); michael@0: // press cmd/ctrl F michael@0: EventUtils.synthesizeKey("f", {accelKey: true}, cw); michael@0: } michael@0: michael@0: function testTwo() { michael@0: hideSearchWhenSearchEnabled(testThree); michael@0: // press / michael@0: EventUtils.synthesizeKey("VK_SLASH", {}, cw); michael@0: } michael@0: michael@0: function testThree() { michael@0: ok(win.TabView.isVisible(), "Tab View is visible"); michael@0: // create another group with a tab. michael@0: let groupItem = createGroupItemWithBlankTabs(win, 300, 300, 200, 1); michael@0: is(cw.UI.getActiveTab(), groupItem.getChild(0), michael@0: "The active tab is newly created tab item"); michael@0: michael@0: whenSearchIsEnabled(function () { michael@0: let doc = cw.document; michael@0: let searchBox = cw.iQ("#searchbox"); michael@0: let hasFocus = doc.hasFocus() && doc.activeElement == searchBox[0]; michael@0: ok(hasFocus, "The search box has focus"); michael@0: michael@0: let tab = win.gBrowser.tabs[1]; michael@0: searchBox.val(tab._tabViewTabItem.$tabTitle[0].innerHTML); michael@0: michael@0: cw.Search.perform(); michael@0: michael@0: whenTabViewIsHidden(function () { michael@0: is(tab, win.gBrowser.selectedTab, "The search result tab is shown"); michael@0: finish() michael@0: }, win); michael@0: michael@0: // use the tabview menu (the same as pressing cmd/ctrl + e) michael@0: win.document.getElementById("menu_tabview").doCommand(); michael@0: }, win); michael@0: EventUtils.synthesizeKey("VK_SLASH", {}, cw); michael@0: } michael@0: michael@0: function hideSearchWhenSearchEnabled(callback) { michael@0: whenSearchIsEnabled(function() { michael@0: hideSearch(callback, win); michael@0: }, win); michael@0: } michael@0: