Bug 1582833, update findbar state correctly when findbar is closed to allow keyboard to work properly, r=mikedeboer

Differential Revision: https://phabricator.services.mozilla.com/D46906

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Neil Deakin 2019-09-30 15:12:28 +00:00
parent 204f15a778
commit 4348582007
3 changed files with 54 additions and 5 deletions

View File

@ -37,11 +37,8 @@ class FindBarChild extends JSWindowActorChild {
receiveMessage(msg) {
if (msg.name == "Findbar:UpdateState") {
this.findMode = msg.data.findMode;
this.inQuickFind = msg.data.hasQuickFindTimeout;
if (msg.data.isOpenAndFocused) {
this.inPassThrough = false;
}
let { FindBarContent } = this;
FindBarContent.updateState(msg.data);
}
}

View File

@ -254,6 +254,50 @@ add_task(async function e10sLostKeys() {
BrowserTestUtils.removeTab(tab);
});
/**
* This test makes sure that keyboard operations still occur
* after the findbar is opened and closed.
*/
add_task(async function test_open_and_close_keys() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"data:text/html,<body style='height: 5000px;'>Hello There</body>"
);
await gFindBarPromise;
let findBar = gFindBar;
is(findBar.hidden, true, "Findbar is hidden now.");
let openedPromise = BrowserTestUtils.waitForEvent(findBar, "findbaropen");
await EventUtils.synthesizeKey("f", { accelKey: true });
await openedPromise;
is(findBar.hidden, false, "Findbar should not be hidden.");
let closedPromise = BrowserTestUtils.waitForEvent(findBar, "findbarclose");
await EventUtils.synthesizeKey("KEY_Escape");
await closedPromise;
let scrollPromise = BrowserTestUtils.waitForContentEvent(
tab.linkedBrowser,
"scroll"
);
await EventUtils.synthesizeKey("KEY_ArrowDown");
await scrollPromise;
let scrollPosition = await SpecialPowers.spawn(
tab.linkedBrowser,
[],
async function() {
return content.document.body.scrollTop;
}
);
ok(scrollPosition > 0, "Scrolled ok to " + scrollPosition);
BrowserTestUtils.removeTab(tab);
});
async function promiseFindFinished(searchText, highlightOn) {
let findbar = await gBrowser.getFindBar();
findbar.startFind(findbar.FIND_NORMAL);

View File

@ -60,6 +60,14 @@ class FindBarContent {
this.passKeyToParent(event);
}
updateState(data) {
this.findMode = data.findMode;
this.inQuickFind = data.hasQuickFindTimeout;
if (data.isOpenAndFocused) {
this.inPassThrough = false;
}
}
handleEvent(event) {
switch (event.type) {
case "keypress":