browser/components/tabview/test/browser_tabview_bug595560.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/tabview/test/browser_tabview_bug595560.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +let win;
     1.8 +let cw;
     1.9 +
    1.10 +function test() {
    1.11 +  waitForExplicitFinish();
    1.12 +
    1.13 +  let onLoad = function (tvwin) {
    1.14 +    win = tvwin;
    1.15 +    registerCleanupFunction(function () win.close());
    1.16 +    win.gBrowser.loadOneTab("http://mochi.test:8888/", {inBackground: true});
    1.17 +  };
    1.18 +
    1.19 +  let onShow = function () {
    1.20 +    cw = win.TabView.getContentWindow();
    1.21 +    ok(win.TabView.isVisible(), "Tab View is visible");
    1.22 +    afterAllTabItemsUpdated(testOne, win);
    1.23 +  };
    1.24 +
    1.25 +  newWindowWithTabView(onShow, onLoad);
    1.26 +}
    1.27 +
    1.28 +function testOne() {
    1.29 +  hideSearchWhenSearchEnabled(testTwo);
    1.30 +  // press cmd/ctrl F
    1.31 +  EventUtils.synthesizeKey("f", {accelKey: true}, cw);
    1.32 +}
    1.33 +
    1.34 +function testTwo() {
    1.35 +  hideSearchWhenSearchEnabled(testThree);
    1.36 +  // press /
    1.37 +  EventUtils.synthesizeKey("VK_SLASH", {}, cw);
    1.38 +}
    1.39 +
    1.40 +function testThree() {
    1.41 +  ok(win.TabView.isVisible(), "Tab View is visible");
    1.42 +  // create another group with a tab.
    1.43 +  let groupItem = createGroupItemWithBlankTabs(win, 300, 300, 200, 1);
    1.44 +  is(cw.UI.getActiveTab(), groupItem.getChild(0), 
    1.45 +     "The active tab is newly created tab item");
    1.46 +
    1.47 +  whenSearchIsEnabled(function () {
    1.48 +    let doc = cw.document;
    1.49 +    let searchBox = cw.iQ("#searchbox");
    1.50 +    let hasFocus = doc.hasFocus() && doc.activeElement == searchBox[0];
    1.51 +    ok(hasFocus, "The search box has focus");
    1.52 +
    1.53 +    let tab = win.gBrowser.tabs[1];
    1.54 +    searchBox.val(tab._tabViewTabItem.$tabTitle[0].innerHTML);
    1.55 +
    1.56 +    cw.Search.perform();
    1.57 +
    1.58 +    whenTabViewIsHidden(function () {
    1.59 +      is(tab, win.gBrowser.selectedTab, "The search result tab is shown");
    1.60 +      finish()
    1.61 +    }, win);
    1.62 +
    1.63 +    // use the tabview menu (the same as pressing cmd/ctrl + e)
    1.64 +    win.document.getElementById("menu_tabview").doCommand();
    1.65 +  }, win);
    1.66 +  EventUtils.synthesizeKey("VK_SLASH", {}, cw);
    1.67 +}
    1.68 +
    1.69 +function hideSearchWhenSearchEnabled(callback) {
    1.70 +  whenSearchIsEnabled(function() {
    1.71 +    hideSearch(callback, win);
    1.72 +  }, win);
    1.73 +}
    1.74 +

mercurial