Bug 613194 - Fix some JS errors we see in the browser-chrome tests [r=vingtetun]
authorMark Finkle <mfinkle@mozilla.com>
Thu, 18 Nov 2010 09:51:10 -0500
changeset 67047 73bc5dd7de901e0afa11fa7f9e20e66e0a9814ee
parent 67046 6f36c4bfa491d129e0fc1ffa60221d97b0cdea99
child 67048 42cc5f8295a1919380843863103a5f87bb1520a4
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)
reviewersvingtetun
bugs613194
Bug 613194 - Fix some JS errors we see in the browser-chrome tests [r=vingtetun]
mobile/chrome/content/bindings.xml
mobile/chrome/content/browser-ui.js
mobile/chrome/content/tabs.xml
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -686,17 +686,18 @@
             if (!this.itemId || this.isReadOnly)
               return;
 
             this._isEditing = true;
             if (this.control) {
               this.setAttribute("selected", "true");
               let self = this;
               setTimeout(function() {
-                self.control.scrollBoxObject.ensureElementIsVisible(self); 
+                if (self.control)
+                  self.control.scrollBoxObject.ensureElementIsVisible(self); 
               }, 0);
               this.control.activeItem = this;
             }
 
             this.updateFields();
 
             this._nameField.focus();
             if (autoSelect)
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -2310,38 +2310,47 @@ var SelectHelperUI = {
     for (let i = 0; i < options.length; i++) {
       let option = options[i];
       option.getAttribute("label").match(reg) ? option.removeAttribute("filtered")
                                               : option.setAttribute("filtered", "true");
     }
   },
 
   unselectAll: function() {
+    if (!this._list)
+      return;
+
     let choices = this._list.choices;
     this._forEachOption(function(aItem, aIndex) {
       aItem.selected = false;
       choices[aIndex].selected = false;
     });
   },
 
   selectByIndex: function(aIndex) {
+    if (!this._list)
+      return;
+
     let choices = this._list.choices;
     for (let i = 0; i < this._container.childNodes.length; i++) {
       let option = this._container.childNodes[i];
       if (option.optionIndex == aIndex) {
         option.selected = true;
         this._choices[i].selected = true;
         this._scrollElementIntoView(option);
         break;
       }
     }
   },
 
   _getSelectedIndexes: function() {
     let indexes = [];
+    if (!this._list)
+      return indexes;
+
     let choices = this._list.choices;
     let choiceLength = choices.length;
     for (let i = 0; i < choiceLength; i++) {
       let choice = choices[i];
       if (choice.selected)
         indexes.push(choice.optionIndex);
     }
     return indexes;
--- a/mobile/chrome/content/tabs.xml
+++ b/mobile/chrome/content/tabs.xml
@@ -131,17 +131,20 @@
 
             if (!closedTab || closedTab != aTab) {
               if (aTab.thumbnail && !aTab.thumbnail.hasAttribute("empty")) {
                 // duplicate the old thumbnail to the new one because moving the
                 // tab in the dom clear the canvas
                 let oldThumbnail = aTab.thumbnail.toDataURL("image/png");
                 this._tabsUndo.appendChild(aTab);
                 let thumbnailImg = new Image();
-                thumbnailImg.onload = function() aTab.thumbnail.getContext("2d").drawImage(thumbnailImg, 0, 0);
+                thumbnailImg.onload = function() {
+                  if (aTab.thumbnail)
+                    aTab.thumbnail.getContext("2d").drawImage(thumbnailImg, 0, 0);
+                };
                 thumbnailImg.src = oldThumbnail;
               }
               else
                 this._tabsUndo.appendChild(aTab);
 
               aTab.setAttribute("reload", "true");
               this._closedTab = aTab;
             }