Bug 517819, inherit noinitialfocus into textbox inputs, so that uthe nknown content dialog can use it, prevents focus from appearing on the file type field, r=neil
authorNeil Deakin <neil@mozilla.com>
Fri, 16 Oct 2009 10:32:02 -0400
changeset 33916 d6a03e3e6e6f8e14263b378a6da916e889c0c07c
parent 33915 c19711e6eef2965966942611f55b2faa37a7a651
child 33917 8727bcd1871517720ec5db9d32cd8cc7bce2cd28
push idunknown
push userunknown
push dateunknown
reviewersneil
bugs517819
milestone1.9.3a1pre
Bug 517819, inherit noinitialfocus into textbox inputs, so that uthe nknown content dialog can use it, prevents focus from appearing on the file type field, r=neil
toolkit/content/tests/chrome/dialog_dialogfocus.xul
toolkit/content/tests/chrome/test_dialogfocus.xul
toolkit/content/widgets/textbox.xml
toolkit/mozapps/downloads/content/unknownContentType.xul
--- a/toolkit/content/tests/chrome/dialog_dialogfocus.xul
+++ b/toolkit/content/tests/chrome/dialog_dialogfocus.xul
@@ -10,16 +10,18 @@
   <tabpanels>
     <tabpanel>
       <button id="tabbutton" label="Tab Button"/>
       <button id="tabbutton2" label="Tab Button 2"/>
     </tabpanel>
   </tabpanels>
 </tabbox>
 
+<textbox id="textbox-yes" value="textbox-yes" hidden="true"/>
+<textbox id="textbox-no" value="textbox-no" noinitialfocus="true" hidden="true"/>
 <button id="one" label="One"/>
 <button id="two" label="Two" hidden="true"/>
 
 <script>
 function loaded()
 {
   if (window.arguments) {
     var step = window.arguments[0];
@@ -36,14 +38,20 @@ function loaded()
       case 6:
         document.getElementById("tabbox").hidden = false;
         break;
       case 7:
         var two = document.getElementById("two");
         two.hidden = false;
         two.focus();
         break;
+      case 8:
+        document.getElementById("textbox-yes").hidden = false;
+        break;
+      case 9:
+        document.getElementById("textbox-no").hidden = false;
+        break;
     }
   }
 }
 </script>
 
 </dialog>
--- a/toolkit/content/tests/chrome/test_dialogfocus.xul
+++ b/toolkit/content/tests/chrome/test_dialogfocus.xul
@@ -22,17 +22,17 @@
 </pre>
 </body>
 
 <script>
 <![CDATA[
 
 SimpleTest.waitForExplicitFinish();
 
-var expected = [ "one", "_extra2", "tab", "one", "tabbutton2", "tabbutton", "two" ];
+var expected = [ "one", "_extra2", "tab", "one", "tabbutton2", "tabbutton", "two", "textbox-yes", "one" ];
 // non-Mac will always focus the default button if any of the dialog buttons
 // would be focused
 if (navigator.platform.indexOf("Mac") == -1)
   expected[1] = "_accept";
 
 var step = 0;
 var fullKeyboardAccess = false;
 
@@ -59,17 +59,19 @@ function runTest()
   function checkDialogFocus(event)
   {
     // if full keyboard access is not on, just skip the tests
     var match = false;
     if (fullKeyboardAccess) {
       if (!(event.target instanceof Element))
         return;
 
-      if (expectedFocus[0] == "_")
+      if (expectedFocus == "textbox-yes")
+        match = (win.document.activeElement == win.document.getElementById(expectedFocus).inputField);
+      else if (expectedFocus[0] == "_")
         match = (win.document.activeElement.dlgType == expectedFocus.substring(1));
       else
         match = (win.document.activeElement.id == expectedFocus);
       if (!match)
         return;
     }
     else {
       match = (win.document.activeElement == win.document.documentElement);
--- a/toolkit/content/widgets/textbox.xml
+++ b/toolkit/content/widgets/textbox.xml
@@ -16,17 +16,17 @@
       <stylesheet src="chrome://global/content/textbox.css"/>
       <stylesheet src="chrome://global/skin/textbox.css"/>
     </resources>
 
     <content>
       <children/>
       <xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context,spellcheck">
         <html:input class="textbox-input" flex="1" anonid="input"
-                    xbl:inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly,tabindex,accesskey"/>
+                    xbl:inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly,tabindex,accesskey,noinitialfocus"/>
       </xul:hbox>
     </content>
 
     <implementation implements="nsIAccessibleProvider, nsIDOMXULTextBoxElement, nsIDOMXULLabeledControlElement">
       <property name="accessibleType" readonly="true">
         <getter>
           <![CDATA[
             return Components.interfaces.nsIAccessibleProvider.XULTextBox;
--- a/toolkit/mozapps/downloads/content/unknownContentType.xul
+++ b/toolkit/mozapps/downloads/content/unknownContentType.xul
@@ -73,17 +73,17 @@
     <separator class="thin"/>
     <hbox align="start" class="small-indent">
       <image id="contentTypeImage"/>
       <vbox flex="1">
         <description id="location" class="plain" crop="start" flex="1"/>
         <separator class="thin"/>
         <hbox align="center">
           <label value="&whichIsA.label;" id="whichIsA"/>
-          <textbox id="type" class="plain" readonly="true" flex="1"/>
+          <textbox id="type" class="plain" readonly="true" flex="1" noinitialfocus="true"/>
         </hbox>
         <hbox align="center">
           <label value="&from.label;" id="from"/>
           <description id="source" class="plain" crop="start" flex="1"/>
         </hbox>
       </vbox>
     </hbox>