Bug 916383 - Adding test for fix r=mbrubeck

--HG--
extra : rebase_source : 1f0e9b7768e63d1e5dc8d402456cbeebbf5a6b05
This commit is contained in:
Rodrigo Silveira 2013-09-16 12:57:11 -07:00
parent 788b200dde
commit cfebc9e20f
2 changed files with 34 additions and 1 deletions

View File

@ -305,3 +305,35 @@ gTests.push({
}
});
gTests.push({
desc: "Bug 916383 - Invisible autocomplete items selectable by keyboard when 'your results' not shown",
setUp: setUp,
tearDown: tearDown,
run: function testBug916383() {
sendElementTap(window, gEdit);
let bookmarkItem = Browser.selectedBrowser.contentWindow.BookmarksStartView._grid.querySelector("richgriditem");
// Get the first bookmark item label to make sure it will show up in 'your results'
let label = bookmarkItem.getAttribute("label");
EventUtils.sendString(label, window);
let opened = yield waitForCondition(() => gEdit.popup.popupOpen);
yield waitForCondition(() => gEdit.popup._results.itemCount > 0);
ok(!gEdit.popup._resultsContainer.hidden, "'Your results' are visible");
ok(gEdit.popup._results.itemCount > 0, "'Your results' are populated");
// Append a string to make sure it doesn't match anything in 'your results'
EventUtils.sendString("zzzzzzzzzzzzzzzzzz", window);
yield waitForCondition(() => gEdit.popup._resultsContainer.hidden);
ok(gEdit.popup._resultsContainer.hidden, "'Your results' are hidden");
ok(gEdit.popup._results.itemCount === 0, "'Your results' are empty");
EventUtils.synthesizeKey("VK_DOWN", {}, window);
is(gEdit.popup._searches.selectedIndex, 0, "key select search: first search selected");
}
});

View File

@ -396,11 +396,12 @@ function waitForCondition(aCondition, aTimeoutMs, aIntervalMs) {
let timeoutMs = aTimeoutMs || kDefaultWait;
let intervalMs = aIntervalMs || kDefaultInterval;
let startTime = Date.now();
let stack = new Error().stack;
function testCondition() {
let now = Date.now();
if((now - startTime) > timeoutMs) {
deferred.reject( new Error("Timed out waiting for condition to be true") );
deferred.reject( new Error("Timed out waiting for condition to be true at " + stack) );
return;
}