browser/components/tabview/test/browser_tabview_bug618828.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function test() {
     5   waitForExplicitFinish();
     7   ok(!TabView.isVisible(), 'TabView is hidden');
     8   let tab = gBrowser.loadOneTab('about:blank#other', {inBackground: true});
    10   TabView._initFrame(function () {
    11     newWindowWithTabView(function (win) {
    12       onTabViewWindowLoaded(win, tab);
    13     });
    14   });
    15 }
    17 function onTabViewWindowLoaded(win, tab) {
    18   let contentWindow = win.TabView.getContentWindow();
    19   let search = contentWindow.document.getElementById('search');
    20   let searchbox = contentWindow.document.getElementById('searchbox');
    21   let searchButton = contentWindow.document.getElementById('searchbutton');
    22   let results = contentWindow.document.getElementById('results');
    24   let isSearchEnabled = function () {
    25     return 'none' != search.style.display;
    26   }
    28   let assertSearchIsEnabled = function () {
    29     ok(isSearchEnabled(), 'search is enabled');
    30   }
    32   let assertSearchIsDisabled = function () {
    33     ok(!isSearchEnabled(), 'search is disabled');
    34   }
    36   let enableSearch = function () {
    37     assertSearchIsDisabled();
    38     EventUtils.sendMouseEvent({type: 'mousedown'}, searchButton, contentWindow);
    39   }
    41   let finishTest = function () {
    42     win.close();
    43     gBrowser.removeTab(tab);
    44     finish();
    45   }
    47   let testClickOnSearchBox = function () {
    48     EventUtils.synthesizeMouseAtCenter(searchbox, {}, contentWindow);
    49     assertSearchIsEnabled();
    50   }
    52   let testClickOnOtherSearchResult = function () {
    53     // search for the tab from our main window
    54     searchbox.setAttribute('value', 'other');
    55     contentWindow.Search.perform();
    57     // prepare to finish when the main window gets focus back
    58     window.addEventListener('focus', function onFocus() {
    59       window.removeEventListener('focus', onFocus, true);
    60       assertSearchIsDisabled();
    62       // check that the right tab is active
    63       is(gBrowser.selectedTab, tab, 'search result is the active tab');
    65       finishTest();
    66     }, true);
    68     // click the first result
    69     ok(results.firstChild, 'search returns one result');
    70     EventUtils.synthesizeMouseAtCenter(results.firstChild, {}, contentWindow);
    71   }
    73   enableSearch();
    74   assertSearchIsEnabled();
    76   testClickOnSearchBox();
    77   testClickOnOtherSearchResult();
    78 }

mercurial