зеркало из https://github.com/mozilla/gecko-dev.git
Bug 967982 - Show findbar after unsuccessful Find Again [r=mikedeboer]
This commit is contained in:
Родитель
5203e548cc
Коммит
575c52edc2
|
@ -29,6 +29,7 @@
|
|||
const SAMPLE_URL = "http://www.mozilla.org/";
|
||||
const SAMPLE_TEXT = "Some text in a text field.";
|
||||
const SEARCH_TEXT = "Text Test";
|
||||
const NOT_FOUND_TEXT = "This text is not on the page."
|
||||
|
||||
var gFindBar = null;
|
||||
var gBrowser;
|
||||
|
@ -122,6 +123,7 @@
|
|||
yield testFailedStringReset();
|
||||
gFindBar.close();
|
||||
yield testQuickFindClose();
|
||||
yield Task.spawn(testFindAgainNotFound);
|
||||
finish();
|
||||
});
|
||||
|
||||
|
@ -544,6 +546,38 @@
|
|||
"testClipboardSearchString: search string not set to '" + aExpected +
|
||||
"', instead found '" + searchStr + "'");
|
||||
}
|
||||
|
||||
// See bug 967982.
|
||||
function* testFindAgainNotFound() {
|
||||
yield openFindbar();
|
||||
yield findAndWaitForResult(NOT_FOUND_TEXT);
|
||||
gFindBar.close();
|
||||
ok(gFindBar.hidden, "The findbar is closed.");
|
||||
yield findAndWaitForResult();
|
||||
ok(!gFindBar.hidden, "Unsuccessful Find Again opens the find bar.");
|
||||
|
||||
yield findAndWaitForResult(SEARCH_TEXT);
|
||||
gFindBar.close();
|
||||
ok(gFindBar.hidden, "The findbar is closed.");
|
||||
yield findAndWaitForResult();
|
||||
ok(gFindBar.hidden, "Successful Find Again leaves the find bar closed.");
|
||||
}
|
||||
|
||||
function findAndWaitForResult(aText) {
|
||||
return new Promise(resolve => {
|
||||
gFindBar.browser.finder.addResultListener({
|
||||
onFindResult: function(aData) {
|
||||
gFindBar.browser.finder.removeResultListener(this);
|
||||
resolve(aData);
|
||||
}
|
||||
});
|
||||
if (aText) {
|
||||
enterStringIntoFindField(aText);
|
||||
} else {
|
||||
gFindBar.onFindAgainCommand();
|
||||
}
|
||||
});
|
||||
}
|
||||
]]></script>
|
||||
|
||||
<commandset>
|
||||
|
|
|
@ -1152,14 +1152,20 @@
|
|||
<method name="onFindResult">
|
||||
<parameter name="aData"/>
|
||||
<body><![CDATA[
|
||||
if (aData.result == this.nsITypeAheadFind.FIND_NOTFOUND) {
|
||||
// If an explicit Find Again command fails, re-open the toolbar.
|
||||
if (aData.storeResult && this.open()) {
|
||||
this._findField.select();
|
||||
this._findField.focus();
|
||||
}
|
||||
this._findFailedString = aData.searchString;
|
||||
} else {
|
||||
this._findFailedString = null;
|
||||
}
|
||||
|
||||
this._updateStatusUI(aData.result, aData.findBackwards);
|
||||
this._updateStatusUIBar(aData.linkURL);
|
||||
|
||||
if (aData.result == this.nsITypeAheadFind.FIND_NOTFOUND)
|
||||
this._findFailedString = aData.searchString;
|
||||
else
|
||||
this._findFailedString = null;
|
||||
|
||||
if (this._findMode != this.FIND_NORMAL)
|
||||
this._setFindCloseTimeout();
|
||||
]]></body>
|
||||
|
|
Загрузка…
Ссылка в новой задаче