/* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ add_task(async function test_skip_invisible() { const URI = `
1234
`; await BrowserTestUtils.withNewTab( { gBrowser, url: "data:text/html;charset=utf-8," + encodeURIComponent(URI), }, async function (browser) { let finder = browser.finder; let listener = { onFindResult() { ok(false, "callback wasn't replaced"); }, }; finder.addResultListener(listener); function waitForFind() { return new Promise(resolve => { listener.onFindResult = resolve; }); } async function assertFindable(text, findable = true) { let promiseFind = waitForFind(); finder.fastFind(text, false, false); let findResult = await promiseFind; is( findResult.result, findable ? Ci.nsITypeAheadFind.FIND_FOUND : Ci.nsITypeAheadFind.FIND_NOTFOUND, `${text} should ${findable ? "" : "not "}be findable` ); } await assertFindable("before content"); await assertFindable("after content"); await assertFindable("fallback text"); await assertFindable("button text"); await assertFindable("password", false); // TODO(emilio): In an ideal world we could select the comma as well and // then you'd find it with "1,234" instead... await assertFindable("1234"); finder.removeResultListener(listener); } ); });