From c2ca145a4ddbd8b0709fd801771772755a2b5536 Mon Sep 17 00:00:00 2001 From: "mozilla.mano@sent.com" Date: Sat, 12 May 2007 23:27:11 -0700 Subject: [PATCH] Bug 365551 - Auto-case mode erroneously shows Match Case box sometimes. r=gavin. --- .../content/tests/chrome/bug288254_window.xul | 32 +++++++++++++++++++ toolkit/content/widgets/findbar.xml | 3 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/toolkit/content/tests/chrome/bug288254_window.xul b/toolkit/content/tests/chrome/bug288254_window.xul index 69fe64856b66..f9a1368bccc9 100644 --- a/toolkit/content/tests/chrome/bug288254_window.xul +++ b/toolkit/content/tests/chrome/bug288254_window.xul @@ -104,6 +104,7 @@ testNormalFind(); gFindBar.close(); ok(gFindBar.hidden, "Failed to close findbar after testNormalFind"); + testAutoCaseSensitivityUI(); testQuickFindText(); gFindBar.close(); ok(gFindBar.hidden, "Failed to close findbar after testQuickFindText"); @@ -164,6 +165,37 @@ } } + function testAutoCaseSensitivityUI() { + var matchCaseCheckbox = gFindBar.getElement("find-case-sensitive"); + var matchCaseLabel = gFindBar.getElement("match-case-status"); + document.getElementById("cmd_find").doCommand(); + ok(!matchCaseCheckbox.hidden, "match case box is hidden in manual mode"); + ok(matchCaseLabel.hidden, "match case label is visible in manual mode"); + + var prefsvc = Cc["@mozilla.org/preferences-service;1"]. + getService(Components.interfaces.nsIPrefBranch2); + prefsvc.setIntPref("accessibility.typeaheadfind.casesensitive", 2); + + ok(matchCaseCheckbox.hidden, + "match case box is visible in automatic mode"); + ok(!matchCaseLabel.hidden, + "match case label is hidden in automatic mode"); + + enterStringIntoFindField("a"); + var insensitiveLabel = matchCaseLabel.value; + enterStringIntoFindField("A"); + var sensitiveLabel = matchCaseLabel.value; + ok(insensitiveLabel != sensitiveLabel, + "Case Sensitive label was not correctly updated"); + + // bug 365551 + gFindBar.onFindAgainCommand(); + ok(matchCaseCheckbox.hidden && !matchCaseLabel.hidden, + "bug 365551: case sensitivity UI is broken after find-again"); + prefsvc.setIntPref("accessibility.typeaheadfind.casesensitive", 0); + gFindBar.close(); + } + function clearFocus() { document.commandDispatcher.focusedElement = null; document.commandDispatcher.focusedWindow = null; diff --git a/toolkit/content/widgets/findbar.xml b/toolkit/content/widgets/findbar.xml index 2ebdb3754222..44967388df66 100644 --- a/toolkit/content/widgets/findbar.xml +++ b/toolkit/content/widgets/findbar.xml @@ -708,9 +708,7 @@ if (this.hidden) { this.hidden = false; - this._updateCaseSensitivity(this._findField.value); this._updateStatusUI(this.nsITypeAheadFind.FIND_FOUND); - return true; } return false; @@ -1052,6 +1050,7 @@ nodes[i].hidden = showMinimalUI; } + this._updateCaseSensitivity(); if (this._findMode == this.FIND_TYPEAHEAD) this.getElement("find-label").value = this._fastFindStr;