Bug 594751 - Error: nameField is null [about:config] [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Fri, 10 Sep 2010 14:44:56 +0200
changeset 66558 e155bf5b33e2704f0a1ccb98663ca8f1a0f70a1c
parent 66557 655393ca5bf0ffc7c3f3da1025e732fa7c352383
child 66559 11d099ed1e4c37efe583dbf4ead647d6626aa732
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs594751
Bug 594751 - Error: nameField is null [about:config] [r=mfinkle]
mobile/chrome/content/config.js
mobile/chrome/content/config.xul
--- a/mobile/chrome/content/config.js
+++ b/mobile/chrome/content/config.js
@@ -10,17 +10,17 @@
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is Mozilla Mobile Browser.
  *
  * The Initial Developer of the Original Code is
  * Mozilla Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2008
+ * Portions created by the Initial Developer are Copyright (C) 2010
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
@@ -80,18 +80,16 @@ var ViewConfig = {
 
     let result = Utils.getPrefs(aValue);
     this._container.setItems(result.map(this._createItem, this));
   },
 
   open: function open(aType) {
     let buttons = document.getElementById("editor-buttons-add");
     buttons.setAttribute("hidden", "true");
-    let nameField = document.getElementById("editor-name");
-    nameField.value = "";
 
     let shouldFocus = false;
     let setting = document.getElementById("editor-setting");
     switch (aType) {
       case Ci.nsIPrefBranch.PREF_INT:
         setting.setAttribute("type", "integer");
         break;
       case Ci.nsIPrefBranch.PREF_BOOL:
@@ -103,34 +101,38 @@ var ViewConfig = {
     }
 
     setting.removeAttribute("title");
     setting.removeAttribute("pref");
     if (setting.input)
       setting.input.value = "";
 
     document.getElementById("editor-container").appendChild(this._editor);
+    let nameField = document.getElementById("editor-name");
+    nameField.value = "";
+
     this._editor.setAttribute("hidden", "false");
     this._currentItem = null;
     nameField.focus();
   },
 
   close: function close(aValid) {
     this._editor.setAttribute("hidden", "true");
     let buttons = document.getElementById("editor-buttons-add");
     buttons.setAttribute("hidden", "false");
 
     if (aValid) {
-      let name = document.getElementById("editor-name").value;
+      let name = document.getElementById("editor-name").inputField.value;
       if (name != "") {
         let setting = document.getElementById("editor-setting");
         setting.setAttribute("pref", name);
         setting.valueToPreference();
       }
     }
+
     document.getElementById("editor-container").appendChild(this._editor);
   },
 
   _currentItem: null,
   edit: function(aItem) {
     if (!aItem)
       return;
 
@@ -392,17 +394,17 @@ var Utils = {
     }
 
     let evt = document.createEvent("UIEvents");
     evt.initUIEvent(type, true, true, window, index);
     window.dispatchEvent(evt);
   },
 
   _generateRegexp: function _generateRegexp(aValue) {
-    if (aValue.charAt(0) == '/') {
+    if (aValue.charAt(0) == "/") {
       try {
         let rv = aValue.match(/^\/(.*)\/(i?)$/);
         return RegExp(rv[1], rv[2]);
       }
       catch (e) {
         return null; // Do nothing on incomplete or bad RegExp
       }
     }
--- a/mobile/chrome/content/config.xul
+++ b/mobile/chrome/content/config.xul
@@ -12,17 +12,17 @@
    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
    - for the specific language governing rights and limitations under the
    - License.
    -
    - The Original Code is Mozilla Mobile Browser.
    -
    - The Initial Developer of the Original Code is
    - Mozilla Corporation.
-   - Portions created by the Initial Developer are Copyright (C) 2008
+   - Portions created by the Initial Developer are Copyright (C) 2010
    - the Initial Developer. All Rights Reserved.
    -
    - Contributor(s):
    -
    - Alternatively, the contents of this file may be used under the terms of
    - either the GNU General Public License Version 2 or later (the "GPL"), or
    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    - in which case the provisions of the GPL or the LGPL are applicable instead
@@ -64,19 +64,19 @@
       <richlistbox id="prefs-container" flex="1" onselect="ViewConfig.edit(this.selectedItem)" batch="25">
         <richlistitem id="editor-row">
           <vbox id="editor-container" flex="1">
 
             <hbox align="center" flex="1">
               <label value="&newpref.label;" flex="1"/>
               <spacer flex="1" />
               <hbox id="editor-buttons-add">
-                <button label="&integer.label;" oncommand="ViewConfig.open(Components.interfaces.nsIPrefBranch.PREF_INT)"/>
-                <button label="&boolean.label;" oncommand="ViewConfig.open(Components.interfaces.nsIPrefBranch.PREF_BOOL)"/>
-                <button label="&string.label;" oncommand="ViewConfig.open(Components.interfaces.nsIPrefBranch.PREF_STRING)"/>
+                <button label="&integer.label;" oncommand="ViewConfig.open(Ci.nsIPrefBranch.PREF_INT)"/>
+                <button label="&boolean.label;" oncommand="ViewConfig.open(Ci.nsIPrefBranch.PREF_BOOL)"/>
+                <button label="&string.label;" oncommand="ViewConfig.open(Ci.nsIPrefBranch.PREF_STRING)"/>
               </hbox>
             </hbox>
 
             <vbox id="editor" hidden="true">
               <hbox align="center">
                 <textbox id="editor-name" emptytext="&addpref.name;" flex="1"/>
                 <setting id="editor-setting" emptytext="&addpref.value;" onlabel="true" offlabel="false" flex="1"/>
               </hbox>