-
Notifications
You must be signed in to change notification settings - Fork 54
/
browser_Finder_skip_invisible_and_option.js
55 lines (49 loc) · 1.7 KB
/
browser_Finder_skip_invisible_and_option.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* 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);
}
);
});