Bug 1012398 - Completion doesn't take capitalization from address book entry. Also fixes bug 1009469. r=Enn, a=sledru
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 27 Jun 2014 21:17:43 +0300
changeset 207983 bccc4c5da5ed7b73032c39775d56d87b830925c9
parent 207982 14b9fde050ba4def2b4ce77bb66c520387a6e9ba
child 207984 244a3dc5bf491b3d18cdbbd290cf7a92038b864e
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn, sledru
bugs1012398, 1009469
milestone32.0a2
Bug 1012398 - Completion doesn't take capitalization from address book entry. Also fixes bug 1009469. r=Enn, a=sledru
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;
             }