Bug 1358500 - fix find bar being disabled all the time, r=mikedeboer

MozReview-Commit-ID: BpnCdKgtYiG

--HG--
extra : rebase_source : 50ab38dd78941fe397a0acb8113f961f15d7f31d
This commit is contained in:
Gijs Kruitbosch 2017-05-29 16:17:56 +01:00
Родитель 096dd39d81
Коммит 80a2759099
3 изменённых файлов: 17 добавлений и 40 удалений

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

@ -45,7 +45,7 @@ function test() {
setFindString(texts[0]);
// Turn on highlight for testing bug 891638
gFindBar.toggleHighlight(true);
gFindBar.getElement("highlight").checked = true;
// Make sure the second tab is correct, then set it up
gBrowser.selectedTab = tabs[1];
@ -72,19 +72,20 @@ function continueTests1() {
ok(gFindBar.getElement("highlight").checked,
"Highlight button state persists!");
// While we're here, let's test the backout of bug 253793.
// While we're here, let's test bug 253793
gBrowser.reload();
gBrowser.addEventListener("DOMContentLoaded", continueTests2, true);
}
function continueTests2() {
gBrowser.removeEventListener("DOMContentLoaded", continueTests2, true);
ok(gFindBar.getElement("highlight").checked, "Highlight never reset!");
continueTests3();
waitForCondition(() => !gFindBar.getElement("highlight").checked,
continueTests3,
"Highlight never reset!");
}
function continueTests3() {
ok(gFindBar.getElement("highlight").checked, "Highlight button reset!");
ok(!gFindBar.getElement("highlight").checked, "Highlight button reset!");
gFindBar.close();
ok(gFindBar.hidden, "First tab doesn't show find bar!");
gBrowser.selectedTab = tabs[1];
@ -128,7 +129,7 @@ function checkNewWindow() {
is(newWindow.gFindBar._findField.value, texts[1],
"New window find bar has correct find value!");
ok(!newWindow.gFindBar.getElement("find-next").disabled,
"New window findbar has disabled buttons!");
"New window findbar has enabled buttons!");
}
newWindow.close();
finish();

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

@ -154,17 +154,6 @@
await testToggleEntireWord();
}
function testFindButtonsState(enabled = null) {
// If `enabled` is not explicitly passed in, we set it to its most logical
// value.
if (enabled === null)
enabled = !!gFindBar._findField.value;
is(gFindBar.getElement("find-next").disabled, !enabled,
`Expected the 'next' button to be ${enabled ? 'enabled' : 'disabled'}`);
is(gFindBar.getElement("find-previous").disabled, !enabled,
`Expected the 'previous' button to be ${enabled ? 'enabled' : 'disabled'}`);
}
async function testFindbarSelection() {
function checkFindbarState(aTestName, aExpSelection) {
ok(!gFindBar.hidden, "testFindbarSelection: failed to open findbar: " + aTestName);
@ -175,7 +164,6 @@
"Incorrect selection in testFindbarSelection: " + aTestName +
". Selection: " + gFindBar._findField.value);
}
testFindButtonsState();
// Clear the value, close the findbar.
gFindBar._findField.value = "";
@ -333,7 +321,6 @@
"testNormalFind: failed to find '" + args.searchStr + "'");
return sel;
});
testFindButtonsState();
testClipboardSearchString(sel);
if (!matchCaseCheckbox.hidden) {
@ -348,7 +335,6 @@
promise = promiseFindResult();
matchCaseCheckbox.click();
await promise;
testFindButtonsState();
}
}
@ -388,7 +374,6 @@
Assert.notEqual(content.getSelection().toString().toLowerCase(), args.searchStr,
"testNormalFindWithComposition: text shouldn't be found during composition");
});
testFindButtonsState();
synthesizeComposition({ type: "compositioncommitasis" });
@ -399,7 +384,6 @@
return sel;
});
testClipboardSearchString(sel);
testFindButtonsState();
if (clicked) {
matchCaseCheckbox.click();
@ -463,7 +447,6 @@
Assert.equal(content.getSelection().toString(), args.searchStr,
"testQuickFindLink: failed to find sample link");
});
testFindButtonsState();
testClipboardSearchString(searchStr);
}
@ -582,7 +565,6 @@
Assert.equal(content.getSelection().toString(), args.SEARCH_TEXT,
"testQuickFindText: failed to find '" + args.SEARCH_TEXT + "'");
});
testFindButtonsState();
testClipboardSearchString(SEARCH_TEXT);
}
@ -639,7 +621,6 @@
`${linksOnly ? "[Links-only] " : ""}Currently highlighted match should be at ${aTest.current} for '${aTest.text}'`);
is(aMatches[2], String(aTest.total),
`${linksOnly ? "[Links-only] " : ""}Total amount of matches should be ${aTest.total} for '${aTest.text}'`);
testFindButtonsState(aMatches.total !== 0);
}
for (let test of tests) {
@ -689,13 +670,11 @@
await ContentTask.spawn(gBrowser, null, async function() {
Assert.equal(content.getSelection().toString(), "T", "First T should be selected.");
});
testFindButtonsState();
gPrefsvc.setIntPref("accessibility.typeaheadfind.casesensitive", 1);
await ContentTask.spawn(gBrowser, null, async function() {
Assert.equal(content.getSelection().toString(), "t", "First t should be selected.");
});
testFindButtonsState();
}
// Make sure that _findFailedString is cleared:
@ -708,14 +687,12 @@
await ContentTask.spawn(gBrowser, null, async function() {
Assert.equal(content.getSelection().toString(), "", "Not found.");
});
testFindButtonsState(false);
gPrefsvc.setIntPref("accessibility.typeaheadfind.casesensitive", 0);
await ContentTask.spawn(gBrowser, { SEARCH_TEXT }, async function(args) {
Assert.equal(content.getSelection().toString(), args.SEARCH_TEXT,
"Search text should be selected.");
});
testFindButtonsState();
}
function testClipboardSearchString(aExpected) {
@ -734,17 +711,14 @@
async function testFindAgainNotFound() {
await openFindbar();
await enterStringIntoFindField(NOT_FOUND_TEXT, false);
testFindButtonsState(false);
gFindBar.close();
ok(gFindBar.hidden, "The findbar is closed.");
let promise = promiseFindResult();
gFindBar.onFindAgainCommand();
await promise;
ok(!gFindBar.hidden, "Unsuccessful Find Again opens the find bar.");
testFindButtonsState(false);
await enterStringIntoFindField(SEARCH_TEXT);
testFindButtonsState();
gFindBar.close();
ok(gFindBar.hidden, "The findbar is closed.");
promise = promiseFindResult();
@ -759,7 +733,6 @@
await enterStringIntoFindField("Tex", false);
let result = await promise;
is(result.result, Ci.nsITypeAheadFind.FIND_FOUND, "Text should be found");
testFindButtonsState();
await new Promise(resolve => setTimeout(resolve, ITERATOR_TIMEOUT + 20));
promise = promiseFindResult();
@ -767,7 +740,6 @@
check.click();
result = await promise;
is(result.result, Ci.nsITypeAheadFind.FIND_NOTFOUND, "Text should NOT be found");
testFindButtonsState(false);
check.click();
gFindBar.close(true);

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

@ -366,6 +366,8 @@
this._findStatusIcon = this.getElement("find-status-icon");
this._findStatusDesc = this.getElement("find-status");
this._foundURL = null;
let prefsvc = this._prefsvc;
this._quickFindTimeoutLength =
@ -393,17 +395,17 @@
this._entireWord = prefsvc.getBoolPref("findbar.entireword");
this._highlightAll = prefsvc.getBoolPref("findbar.highlightAll");
// Convenience.
// Convenience
this.nsITypeAheadFind = Components.interfaces.nsITypeAheadFind;
this.nsISelectionController = Components.interfaces.nsISelectionController;
this._findSelection = this.nsISelectionController.SELECTION_FIND;
this._findResetTimeout = -1;
// Make sure the FAYT keypress listener is attached by initializing the
// browser property.
// browser property
if (this.getAttribute("browserid"))
setTimeout(() => this.browser = this.browser, 0);
this._enableFindButtons(false);
setTimeout(function(aSelf) { aSelf.browser = aSelf.browser; }, 0, this);
]]></constructor>
<destructor><![CDATA[
@ -998,6 +1000,7 @@
this._startFindDeferred = null;
}
this._enableFindButtons(val);
this._updateCaseSensitivity(val);
this._setEntireWord();
@ -1105,6 +1108,7 @@
]]></body>
</method>
<!--
- Opens the findbar, focuses the findfield and selects its contents.
- Also flashes the findbar the first time it's used.
@ -1269,7 +1273,7 @@
this._findFailedString = null;
}
this.updateControlState(aData.result, aData.findBackwards);
this._updateStatusUI(aData.result, aData.findBackwards);
this._updateStatusUIBar(aData.linkURL);
if (this._findMode != this.FIND_NORMAL)