1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/tabview/test/browser_tabview_bug595436.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + let cw, search, searchButton; 1.9 + 1.10 + let assertSearchIsEnabled = function () { 1.11 + isnot(search.style.display, "none", "search is enabled"); 1.12 + } 1.13 + 1.14 + let assertSearchIsDisabled = function () { 1.15 + is(search.style.display, "none", "search is disabled"); 1.16 + } 1.17 + 1.18 + let testSearchInitiatedByKeyPress = function () { 1.19 + EventUtils.synthesizeKey("a", {}, cw); 1.20 + assertSearchIsEnabled(); 1.21 + 1.22 + EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); 1.23 + assertSearchIsDisabled(); 1.24 + } 1.25 + 1.26 + let testSearchInitiatedByMouseClick = function () { 1.27 + EventUtils.sendMouseEvent({type: "mousedown"}, searchButton, cw); 1.28 + assertSearchIsEnabled(); 1.29 + 1.30 + EventUtils.synthesizeKey("a", {}, cw); 1.31 + EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); 1.32 + EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw); 1.33 + assertSearchIsEnabled(); 1.34 + 1.35 + EventUtils.synthesizeKey("VK_ESCAPE", {}, cw); 1.36 + assertSearchIsDisabled(); 1.37 + } 1.38 + 1.39 + waitForExplicitFinish(); 1.40 + 1.41 + newWindowWithTabView(function (win) { 1.42 + registerCleanupFunction(function () win.close()); 1.43 + 1.44 + cw = win.TabView.getContentWindow(); 1.45 + search = cw.document.getElementById("search"); 1.46 + searchButton = cw.document.getElementById("searchbutton"); 1.47 + 1.48 + SimpleTest.waitForFocus(function () { 1.49 + assertSearchIsDisabled(); 1.50 + 1.51 + testSearchInitiatedByKeyPress(); 1.52 + testSearchInitiatedByMouseClick(); 1.53 + 1.54 + finish(); 1.55 + }, cw); 1.56 + }); 1.57 +}