Bug 613194 - Fix some JS errors we see in the browser-chrome tests [r=vingtetun]
--- 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;
}