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 | function test() { |
michael@0 | 5 | let cw, search, searchButton; |
michael@0 | 6 | |
michael@0 | 7 | let assertSearchIsEnabled = function () { |
michael@0 | 8 | isnot(search.style.display, "none", "search is enabled"); |
michael@0 | 9 | } |
michael@0 | 10 | |
michael@0 | 11 | let assertSearchIsDisabled = function () { |
michael@0 | 12 | is(search.style.display, "none", "search is disabled"); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | let testSearchInitiatedByKeyPress = function () { |
michael@0 | 16 | EventUtils.synthesizeKey("a", {}, cw); |
michael@0 | 17 | assertSearchIsEnabled(); |
michael@0 | 18 | |
michael@0 | 19 | EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); |
michael@0 | 20 | assertSearchIsDisabled(); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | let testSearchInitiatedByMouseClick = function () { |
michael@0 | 24 | EventUtils.sendMouseEvent({type: "mousedown"}, searchButton, cw); |
michael@0 | 25 | assertSearchIsEnabled(); |
michael@0 | 26 | |
michael@0 | 27 | EventUtils.synthesizeKey("a", {}, cw); |
michael@0 | 28 | EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); |
michael@0 | 29 | EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); |
michael@0 | 30 | assertSearchIsEnabled(); |
michael@0 | 31 | |
michael@0 | 32 | EventUtils.synthesizeKey("VK_ESCAPE", {}, cw); |
michael@0 | 33 | assertSearchIsDisabled(); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | waitForExplicitFinish(); |
michael@0 | 37 | |
michael@0 | 38 | newWindowWithTabView(function (win) { |
michael@0 | 39 | registerCleanupFunction(function () win.close()); |
michael@0 | 40 | |
michael@0 | 41 | cw = win.TabView.getContentWindow(); |
michael@0 | 42 | search = cw.document.getElementById("search"); |
michael@0 | 43 | searchButton = cw.document.getElementById("searchbutton"); |
michael@0 | 44 | |
michael@0 | 45 | SimpleTest.waitForFocus(function () { |
michael@0 | 46 | assertSearchIsDisabled(); |
michael@0 | 47 | |
michael@0 | 48 | testSearchInitiatedByKeyPress(); |
michael@0 | 49 | testSearchInitiatedByMouseClick(); |
michael@0 | 50 | |
michael@0 | 51 | finish(); |
michael@0 | 52 | }, cw); |
michael@0 | 53 | }); |
michael@0 | 54 | } |