2011-02-27 17:36:36 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2011-01-12 11:49:10 -08:00
|
|
|
|
|
|
|
function test() {
|
2011-04-13 21:04:13 -07:00
|
|
|
let cw, search, searchButton;
|
2011-01-12 11:49:10 -08:00
|
|
|
|
|
|
|
let assertSearchIsEnabled = function () {
|
2011-04-13 21:04:13 -07:00
|
|
|
isnot(search.style.display, "none", "search is enabled");
|
2011-01-12 11:49:10 -08:00
|
|
|
}
|
2011-04-13 21:04:13 -07:00
|
|
|
|
2011-01-12 11:49:10 -08:00
|
|
|
let assertSearchIsDisabled = function () {
|
2011-04-13 21:04:13 -07:00
|
|
|
is(search.style.display, "none", "search is disabled");
|
2011-01-12 11:49:10 -08:00
|
|
|
}
|
2011-04-13 21:04:13 -07:00
|
|
|
|
2011-01-12 11:49:10 -08:00
|
|
|
let testSearchInitiatedByKeyPress = function () {
|
2011-04-13 21:04:13 -07:00
|
|
|
EventUtils.synthesizeKey("a", {}, cw);
|
2011-01-12 11:49:10 -08:00
|
|
|
assertSearchIsEnabled();
|
2011-04-13 21:04:13 -07:00
|
|
|
|
|
|
|
EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
|
2011-01-12 11:49:10 -08:00
|
|
|
assertSearchIsDisabled();
|
|
|
|
}
|
2011-04-13 21:04:13 -07:00
|
|
|
|
2011-01-12 11:49:10 -08:00
|
|
|
let testSearchInitiatedByMouseClick = function () {
|
2011-04-13 21:04:13 -07:00
|
|
|
EventUtils.sendMouseEvent({type: "mousedown"}, searchButton, cw);
|
2011-01-12 11:49:10 -08:00
|
|
|
assertSearchIsEnabled();
|
2011-04-13 21:04:13 -07:00
|
|
|
|
|
|
|
EventUtils.synthesizeKey("a", {}, cw);
|
|
|
|
EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
|
|
|
|
EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
|
2011-01-12 11:49:10 -08:00
|
|
|
assertSearchIsEnabled();
|
2011-04-13 21:04:13 -07:00
|
|
|
|
|
|
|
EventUtils.synthesizeKey("VK_ESCAPE", {}, cw);
|
2011-01-12 11:49:10 -08:00
|
|
|
assertSearchIsDisabled();
|
|
|
|
}
|
2011-04-13 21:04:13 -07:00
|
|
|
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
newWindowWithTabView(function (win) {
|
|
|
|
registerCleanupFunction(function () win.close());
|
|
|
|
|
|
|
|
cw = win.TabView.getContentWindow();
|
|
|
|
search = cw.document.getElementById("search");
|
|
|
|
searchButton = cw.document.getElementById("searchbutton");
|
|
|
|
|
|
|
|
SimpleTest.waitForFocus(function () {
|
|
|
|
assertSearchIsDisabled();
|
|
|
|
|
|
|
|
testSearchInitiatedByKeyPress();
|
|
|
|
testSearchInitiatedByMouseClick();
|
|
|
|
|
2011-01-12 11:49:10 -08:00
|
|
|
finish();
|
2011-04-13 21:04:13 -07:00
|
|
|
}, cw);
|
|
|
|
});
|
2011-01-12 11:49:10 -08:00
|
|
|
}
|