Bug 717147 part.3 Findbar shouldn't do incremental search during composition r=gavin

This commit is contained in:
Masayuki Nakano 2012-01-13 15:19:22 +09:00
parent 7de3aa99c7
commit 4882293da4
2 changed files with 65 additions and 0 deletions

View File

@ -118,6 +118,9 @@
testNormalFind();
gFindBar.close();
ok(gFindBar.hidden, "Failed to close findbar after testNormalFind");
testNormalFindWithComposition();
gFindBar.close();
ok(gFindBar.hidden, "findbar should be hidden after testNormalFindWithComposition");
testAutoCaseSensitivityUI();
testQuickFindText();
gFindBar.close();
@ -226,6 +229,60 @@
}
}
function testNormalFindWithComposition() {
document.getElementById("cmd_find").doCommand();
ok(!gFindBar.hidden, "testNormalFindWithComposition: findbar should be open");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
"testNormalFindWithComposition: find field should be focused");
var matchCaseCheckbox = gFindBar.getElement("find-case-sensitive");
var clicked = false;
if (!matchCaseCheckbox.hidden & matchCaseCheckbox.checked) {
matchCaseCheckbox.click();
clicked = true;
}
gFindBar._findField.inputField.focus();
var searchStr = "text";
synthesizeComposition({ type: "compositionstart" });
synthesizeComposition({ type: "compositionupdate", data: searchStr });
synthesizeText(
{ "composition":
{ "string": searchStr,
"clauses":
[
{ "length": searchStr.length, "attr": COMPOSITION_ATTR_RAWINPUT }
]
},
"caret": { "start": searchStr.length, "length": 0 }
});
ok(gBrowser.contentWindow.getSelection().toString().toLowerCase() != searchStr,
"testNormalFindWithComposition: text shouldn't be found during composition");
synthesizeText(
{ "composition":
{ "string": searchStr,
"clauses":
[
{ "length": 0, "attr": 0 }
]
},
"caret": { "start": searchStr.length, "length": 0 }
});
synthesizeComposition({ type: "compositionend", data: searchStr });
ok(gBrowser.contentWindow.getSelection().toString().toLowerCase() == searchStr,
"testNormalFindWithComposition: text should be found after committing composition");
if (clicked) {
matchCaseCheckbox.click();
}
}
function testAutoCaseSensitivityUI() {
var matchCaseCheckbox = gFindBar.getElement("find-case-sensitive");
var matchCaseLabel = gFindBar.getElement("match-case-status");

View File

@ -113,6 +113,14 @@
<handlers>
<handler event="input"><![CDATA[
// We should do nothing during composition. E.g., composing string
// before converting may matches a forward word of expected word.
// After that, even if user converts the composition string to the
// expected word, it may find second or later searching word in the
// document.
if (this.findbar._isIMEComposing) {
return;
}
this.findbar._find(this.value);
]]></handler>