Bug 1490974 Part 3: Add a test that invisible text and text in option tags doesn't generate a find result. r=mikedeboer

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2019-03-05 20:19:51 +00:00
Родитель d4ceab331d
Коммит 36f13c24fe
2 изменённых файлов: 42 добавлений и 0 удалений

Просмотреть файл

@ -35,6 +35,7 @@ skip-if = verify && debug
[browser_Finder_overflowed_textarea.js]
skip-if = (verify && debug && (os == 'mac' || os == 'linux'))
[browser_Finder_pointer_events_none.js]
[browser_Finder_skip_invisible_and_option.js]
[browser_Finder_vertical_text.js]
[browser_FinderHighlighter.js]
skip-if = debug || os = "linux"

Просмотреть файл

@ -0,0 +1,41 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(async function test_vertical_text() {
const URI = '<body>a<div style="visibility:hidden;">a</div><select><option>a</option></select><select size=2><option>a</option><option>a</option></select></body>';
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;
});
}
// Find the target text. There should be three results.
let target = "a";
let promiseFind = waitForFind();
finder.fastFind(target, false, false);
let findResult = await promiseFind;
// Check the results and repeat three times. After the final repeat, make sure we've wrapped to the beginning.
let i = 0;
for (; i < 3; i++) {
isnot(findResult.result, Ci.nsITypeAheadFind.FIND_NOTFOUND, "Should find target text '" + target + "' instance " + (i + 1) + ".");
promiseFind = waitForFind();
finder.findAgain(false, false, false);
findResult = await promiseFind;
}
is(findResult.result, Ci.nsITypeAheadFind.FIND_WRAPPED, "After " + (i + 1) + " searches, we should wrap to first target text.");
finder.removeResultListener(listener);
});
});