Bug 1012398 - Completion doesn't take capitalization from address book entry. Also fixes bug 1009469. r=Enn
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 27 Jun 2014 21:17:43 +0300
changeset 215672 064025abab4d91d69c7980dbbb337a403880d676
parent 215671 58d9f861d2b40e1dc287106f02dc35bfb9276e66
child 215673 2c95fdd24a270f20c9dd892b12552f834c4ff444
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn
bugs1012398, 1009469
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1012398 - Completion doesn't take capitalization from address book entry. Also fixes bug 1009469. r=Enn
toolkit/content/tests/chrome/test_autocomplete4.xul
toolkit/content/widgets/autocomplete.xml
--- a/toolkit/content/tests/chrome/test_autocomplete4.xul
+++ b/toolkit/content/tests/chrome/test_autocomplete4.xul
@@ -8,16 +8,17 @@
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
 
 <textbox id="autocomplete"
          type="autocomplete"
          completedefaultindex="true"
+
          onsearchcomplete="searchComplete();"
          autocompletesearch="simple"/>
 
 <script class="testbody" type="application/javascript">
 <![CDATA[
 
 // Set to indicate whether or not we want autoCompleteSimple to return a result
 var returnResult = true;
@@ -138,16 +139,23 @@ const tests = [
     start: 6, end: 6
   },
   { desc: "RETURN key",
     key: "VK_RETURN",
     removeSelection: false,
     result: "Result",
     start: 6, end: 6
   },
+  { desc: "TAB key should confirm suggestion when forcecomplete is set",
+    key: "VK_TAB",
+    removeSelection: false,
+    forceComplete: true,
+    result: "Result",
+    start: 6, end: 6
+  },
 ];
 
 function nextTest() {
   if (!tests.length) {
     // No more tests to run, finish.
     setTimeout(function() {
       // Unregister the factory so that we don't get in the way of other tests
       componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple);
@@ -176,16 +184,18 @@ function runCurrentTest() {
   synthesizeKey("e", {});
 }
 
 function searchComplete() {
   var autocomplete = $("autocomplete");
   is(autocomplete.value, "result",
      "Test '" + currentTest.desc + "': autocomplete.value should equal 'result'");
 
+  autocomplete.setAttribute("forcecomplete", currentTest.forceComplete ? true : false);
+
   if (autocomplete.selectionStart == 2) {  // Finished inserting "re" string.
     if (currentTest.removeSelection) {
       // remove current selection
       synthesizeKey("VK_DELETE", {});
     }
 
     synthesizeKey(currentTest.key, {});
 
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -459,16 +459,18 @@
           // Handle keys that are not part of a keyboard shortcut (no Ctrl or Alt)
           if (!this.disableKeyNavigation && !aEvent.ctrlKey && !aEvent.altKey) {
             switch (aEvent.keyCode) {
               case KeyEvent.DOM_VK_TAB:
                 if (this.tabScrolling && this.popup.popupOpen)
                   cancel = this.mController.handleKeyNavigation(aEvent.shiftKey ?
                                                                 KeyEvent.DOM_VK_UP :
                                                                 KeyEvent.DOM_VK_DOWN);
+                else if (this.forceComplete && this.mController.matchCount >= 1)
+                  this.mController.handleTab();
                 break;
               case KeyEvent.DOM_VK_UP:
               case KeyEvent.DOM_VK_DOWN:
               case KeyEvent.DOM_VK_PAGE_UP:
               case KeyEvent.DOM_VK_PAGE_DOWN:
                 cancel = this.mController.handleKeyNavigation(aEvent.keyCode);
                 break;
             }