1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug599048.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +let cw; 1.8 + 1.9 +function test() { 1.10 + waitForExplicitFinish(); 1.11 + 1.12 + showTabView(function() { 1.13 + cw = TabView.getContentWindow(); 1.14 + 1.15 + whenSearchIsEnabled(function() { 1.16 + ok(cw.Search.isEnabled(), "The search is disabled"); 1.17 + 1.18 + // open a new window and it would have the focus 1.19 + newWindowWithTabView(function(win) { 1.20 + registerCleanupFunction(function() { 1.21 + win.close(); 1.22 + hideTabView(); 1.23 + }); 1.24 + testClickOnSearchShade(win); 1.25 + }); 1.26 + }); 1.27 + 1.28 + EventUtils.synthesizeKey("VK_SLASH", {}, cw); 1.29 + }); 1.30 +} 1.31 + 1.32 +function testClickOnSearchShade(win) { 1.33 + // click on the window with search enabled. 1.34 + let searchshade = cw.document.getElementById("searchshade"); 1.35 + EventUtils.sendMouseEvent({ type: "click" }, searchshade, cw); 1.36 + 1.37 + waitForFocus(function() { 1.38 + ok(cw.Search.isEnabled(), "The search is still enabled after the search shade is clicked"); 1.39 + testFocusInactiveWindow(win, cw); 1.40 + }); 1.41 +} 1.42 + 1.43 +function testFocusInactiveWindow(win) { 1.44 + win.focus(); 1.45 + // focus inactive window 1.46 + window.focus(); 1.47 + 1.48 + // need to use exeuteSoon as the _blockClick would be set to false after a setTimeout(,0) 1.49 + executeSoon(function() { 1.50 + ok(cw.Search.isEnabled(), "The search is still enabled when inactive window has focus"); 1.51 + 1.52 + whenSearchIsDisabled(function() { 1.53 + hideTabView(finish); 1.54 + }); 1.55 + 1.56 + let searchshade = cw.document.getElementById("searchshade"); 1.57 + EventUtils.synthesizeMouseAtCenter(searchshade, {}, cw); 1.58 +}); 1.59 +} 1.60 +