browser/components/tabview/test/browser_tabview_bug595560.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial