From cba671875bd1bdbf34efd8b277eda4423f10c344 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Mon, 29 May 2017 10:52:37 -0700 Subject: [PATCH] Backed out changeset b89704b3bc19 (bug 1358500) for failures in browser_bug537013.js MozReview-Commit-ID: IO4dyagNqNB --HG-- extra : rebase_source : 5a5beba51e57ac28654eb7a4dcac7db1cd9bedb0 --- .../content/test/general/browser_bug537013.js | 13 ++++----- .../content/tests/chrome/findbar_window.xul | 28 +++++++++++++++++++ toolkit/content/widgets/findbar.xml | 16 ++++------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/browser/base/content/test/general/browser_bug537013.js b/browser/base/content/test/general/browser_bug537013.js index 7192ff24ded5..354441c3f42e 100644 --- a/browser/base/content/test/general/browser_bug537013.js +++ b/browser/base/content/test/general/browser_bug537013.js @@ -45,7 +45,7 @@ function test() { setFindString(texts[0]); // Turn on highlight for testing bug 891638 - gFindBar.getElement("highlight").checked = true; + gFindBar.toggleHighlight(true); // Make sure the second tab is correct, then set it up gBrowser.selectedTab = tabs[1]; @@ -72,20 +72,19 @@ function continueTests1() { ok(gFindBar.getElement("highlight").checked, "Highlight button state persists!"); - // While we're here, let's test bug 253793 + // While we're here, let's test the backout of bug 253793. gBrowser.reload(); gBrowser.addEventListener("DOMContentLoaded", continueTests2, true); } function continueTests2() { gBrowser.removeEventListener("DOMContentLoaded", continueTests2, true); - waitForCondition(() => !gFindBar.getElement("highlight").checked, - continueTests3, - "Highlight never reset!"); + ok(gFindBar.getElement("highlight").checked, "Highlight never reset!"); + continueTests3(); } 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]; @@ -129,7 +128,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 enabled buttons!"); + "New window findbar has disabled buttons!"); } newWindow.close(); finish(); diff --git a/toolkit/content/tests/chrome/findbar_window.xul b/toolkit/content/tests/chrome/findbar_window.xul index f2e4d32cb3aa..692692accf61 100644 --- a/toolkit/content/tests/chrome/findbar_window.xul +++ b/toolkit/content/tests/chrome/findbar_window.xul @@ -154,6 +154,17 @@ 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); @@ -164,6 +175,7 @@ "Incorrect selection in testFindbarSelection: " + aTestName + ". Selection: " + gFindBar._findField.value); } + testFindButtonsState(); // Clear the value, close the findbar. gFindBar._findField.value = ""; @@ -321,6 +333,7 @@ "testNormalFind: failed to find '" + args.searchStr + "'"); return sel; }); + testFindButtonsState(); testClipboardSearchString(sel); if (!matchCaseCheckbox.hidden) { @@ -335,6 +348,7 @@ promise = promiseFindResult(); matchCaseCheckbox.click(); await promise; + testFindButtonsState(); } } @@ -374,6 +388,7 @@ Assert.notEqual(content.getSelection().toString().toLowerCase(), args.searchStr, "testNormalFindWithComposition: text shouldn't be found during composition"); }); + testFindButtonsState(); synthesizeComposition({ type: "compositioncommitasis" }); @@ -384,6 +399,7 @@ return sel; }); testClipboardSearchString(sel); + testFindButtonsState(); if (clicked) { matchCaseCheckbox.click(); @@ -447,6 +463,7 @@ Assert.equal(content.getSelection().toString(), args.searchStr, "testQuickFindLink: failed to find sample link"); }); + testFindButtonsState(); testClipboardSearchString(searchStr); } @@ -565,6 +582,7 @@ Assert.equal(content.getSelection().toString(), args.SEARCH_TEXT, "testQuickFindText: failed to find '" + args.SEARCH_TEXT + "'"); }); + testFindButtonsState(); testClipboardSearchString(SEARCH_TEXT); } @@ -621,6 +639,7 @@ `${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) { @@ -670,11 +689,13 @@ 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: @@ -687,12 +708,14 @@ 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) { @@ -711,14 +734,17 @@ 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(); @@ -733,6 +759,7 @@ 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(); @@ -740,6 +767,7 @@ check.click(); result = await promise; is(result.result, Ci.nsITypeAheadFind.FIND_NOTFOUND, "Text should NOT be found"); + testFindButtonsState(false); check.click(); gFindBar.close(true); diff --git a/toolkit/content/widgets/findbar.xml b/toolkit/content/widgets/findbar.xml index 8dde209f85e4..c1710a7e46cc 100644 --- a/toolkit/content/widgets/findbar.xml +++ b/toolkit/content/widgets/findbar.xml @@ -366,8 +366,6 @@ this._findStatusIcon = this.getElement("find-status-icon"); this._findStatusDesc = this.getElement("find-status"); - this._foundURL = null; - let prefsvc = this._prefsvc; this._quickFindTimeoutLength = @@ -395,17 +393,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(function(aSelf) { aSelf.browser = aSelf.browser; }, 0, this); + setTimeout(() => this.browser = this.browser, 0); + + this._enableFindButtons(false); ]]> -