Bug 1309207 - the finder iterator doesn't find occurrences properly in links-only mode. r=jaws

MozReview-Commit-ID: 4kdxyX9zrKl

--HG--
extra : rebase_source : c3bfa0bb06d6c37615ac5e382de227788000dbe6
This commit is contained in:
Mike de Boer 2016-11-02 13:38:59 +01:00
Родитель aae0af521c
Коммит fa5057ff91
2 изменённых файлов: 28 добавлений и 15 удалений

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

@ -136,11 +136,14 @@
if (gHasFindClipboard) {
yield testStatusText();
}
if (!gBrowser.hasAttribute("remote")) {
yield testFindCountUI();
gFindBar.close();
ok(gFindBar.hidden, "Failed to close findbar after testFindCountUI");
}
yield testFindCountUI();
gFindBar.close();
ok(gFindBar.hidden, "Failed to close findbar after testFindCountUI");
yield testFindCountUI(true);
gFindBar.close();
ok(gFindBar.hidden, "Failed to close findbar after testFindCountUI - linksOnly");
yield openFindbar();
yield testFindAfterCaseChanged();
gFindBar.close();
@ -509,10 +512,20 @@
testClipboardSearchString(SEARCH_TEXT);
}
function* testFindCountUI(callback) {
function* testFindCountUI(linksOnly = false) {
yield clearFocus();
document.getElementById("cmd_find").doCommand();
if (linksOnly) {
yield ContentTask.spawn(gBrowser, null, function* () {
let document = content.document;
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, "'".charCodeAt(0));
document.documentElement.dispatchEvent(event);
});
} else {
document.getElementById("cmd_find").doCommand();
}
ok(!gFindBar.hidden, "testFindCountUI: failed to open findbar");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
@ -530,16 +543,16 @@
let foundMatches = gFindBar._foundMatches;
let tests = [{
text: "t",
current: 5,
total: 10,
current: linksOnly ? 1 : 5,
total: linksOnly ? 2 : 10,
}, {
text: "te",
current: 3,
total: 5,
current: linksOnly ? 1 : 3,
total: linksOnly ? 1 : 5,
}, {
text: "tes",
current: 1,
total: 2,
total: linksOnly ? 1 : 2,
}, {
text: "texxx",
current: 0,
@ -549,9 +562,9 @@
function assertMatches(aTest, aMatches) {
is(aMatches[1], String(aTest.current),
`Currently highlighted match should be at ${aTest.current} for '${aTest.text}'`);
`${linksOnly ? "[Links-only] " : ""}Currently highlighted match should be at ${aTest.current} for '${aTest.text}'`);
is(aMatches[2], String(aTest.total),
`Total amount of matches should be ${aTest.total} for '${aTest.text}'`);
`${linksOnly ? "[Links-only] " : ""}Total amount of matches should be ${aTest.total} for '${aTest.text}'`);
}
for (let test of tests) {

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

@ -466,7 +466,7 @@ this.FinderIterator = {
return;
// Deal with links-only mode here.
if (linksOnly && this._rangeStartsInLink(range))
if (linksOnly && !this._rangeStartsInLink(range))
continue;
this.ranges.push(range);