michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: let cw, search, searchButton; michael@0: michael@0: let assertSearchIsEnabled = function () { michael@0: isnot(search.style.display, "none", "search is enabled"); michael@0: } michael@0: michael@0: let assertSearchIsDisabled = function () { michael@0: is(search.style.display, "none", "search is disabled"); michael@0: } michael@0: michael@0: let testSearchInitiatedByKeyPress = function () { michael@0: EventUtils.synthesizeKey("a", {}, cw); michael@0: assertSearchIsEnabled(); michael@0: michael@0: EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); michael@0: assertSearchIsDisabled(); michael@0: } michael@0: michael@0: let testSearchInitiatedByMouseClick = function () { michael@0: EventUtils.sendMouseEvent({type: "mousedown"}, searchButton, cw); michael@0: assertSearchIsEnabled(); michael@0: michael@0: EventUtils.synthesizeKey("a", {}, cw); michael@0: EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); michael@0: EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); michael@0: assertSearchIsEnabled(); michael@0: michael@0: EventUtils.synthesizeKey("VK_ESCAPE", {}, cw); michael@0: assertSearchIsDisabled(); michael@0: } michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: newWindowWithTabView(function (win) { michael@0: registerCleanupFunction(function () win.close()); michael@0: michael@0: cw = win.TabView.getContentWindow(); michael@0: search = cw.document.getElementById("search"); michael@0: searchButton = cw.document.getElementById("searchbutton"); michael@0: michael@0: SimpleTest.waitForFocus(function () { michael@0: assertSearchIsDisabled(); michael@0: michael@0: testSearchInitiatedByKeyPress(); michael@0: testSearchInitiatedByMouseClick(); michael@0: michael@0: finish(); michael@0: }, cw); michael@0: }); michael@0: }