Wed, 31 Dec 2014 06:09:35 +0100
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 cw; |
michael@0 | 5 | |
michael@0 | 6 | function test() { |
michael@0 | 7 | waitForExplicitFinish(); |
michael@0 | 8 | |
michael@0 | 9 | showTabView(function() { |
michael@0 | 10 | cw = TabView.getContentWindow(); |
michael@0 | 11 | |
michael@0 | 12 | whenSearchIsEnabled(function() { |
michael@0 | 13 | ok(cw.Search.isEnabled(), "The search is disabled"); |
michael@0 | 14 | |
michael@0 | 15 | // open a new window and it would have the focus |
michael@0 | 16 | newWindowWithTabView(function(win) { |
michael@0 | 17 | registerCleanupFunction(function() { |
michael@0 | 18 | win.close(); |
michael@0 | 19 | hideTabView(); |
michael@0 | 20 | }); |
michael@0 | 21 | testClickOnSearchShade(win); |
michael@0 | 22 | }); |
michael@0 | 23 | }); |
michael@0 | 24 | |
michael@0 | 25 | EventUtils.synthesizeKey("VK_SLASH", {}, cw); |
michael@0 | 26 | }); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function testClickOnSearchShade(win) { |
michael@0 | 30 | // click on the window with search enabled. |
michael@0 | 31 | let searchshade = cw.document.getElementById("searchshade"); |
michael@0 | 32 | EventUtils.sendMouseEvent({ type: "click" }, searchshade, cw); |
michael@0 | 33 | |
michael@0 | 34 | waitForFocus(function() { |
michael@0 | 35 | ok(cw.Search.isEnabled(), "The search is still enabled after the search shade is clicked"); |
michael@0 | 36 | testFocusInactiveWindow(win, cw); |
michael@0 | 37 | }); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function testFocusInactiveWindow(win) { |
michael@0 | 41 | win.focus(); |
michael@0 | 42 | // focus inactive window |
michael@0 | 43 | window.focus(); |
michael@0 | 44 | |
michael@0 | 45 | // need to use exeuteSoon as the _blockClick would be set to false after a setTimeout(,0) |
michael@0 | 46 | executeSoon(function() { |
michael@0 | 47 | ok(cw.Search.isEnabled(), "The search is still enabled when inactive window has focus"); |
michael@0 | 48 | |
michael@0 | 49 | whenSearchIsDisabled(function() { |
michael@0 | 50 | hideTabView(finish); |
michael@0 | 51 | }); |
michael@0 | 52 | |
michael@0 | 53 | let searchshade = cw.document.getElementById("searchshade"); |
michael@0 | 54 | EventUtils.synthesizeMouseAtCenter(searchshade, {}, cw); |
michael@0 | 55 | }); |
michael@0 | 56 | } |
michael@0 | 57 |