Bug 587960. XUL trees can have their methods called at werid times, so guard against that in test. r=roc

This commit is contained in:
Timothy Nikkel 2010-08-27 18:15:08 -05:00
parent 60fce64064
commit e8ca8cd0e7

View File

@ -25,9 +25,9 @@ var view =
{ {
value: "", value: "",
rowCount: 8, rowCount: 8,
getCellText: function(row, column) { return treeData[row % 4][column.index]; }, getCellText: function(row, column) { return ((typeof treeData) != "undefined") ? treeData[row % 4][column.index] : ""; },
getCellValue: function(row, column) { return this.value; }, getCellValue: function(row, column) { return this.value; },
setCellText: function(row, column, val) { treeData[row % 4][column.index] = val; }, setCellText: function(row, column, val) { if ((typeof treeData) != "undefined") treeData[row % 4][column.index] = val; },
setCellValue: function(row, column, val) { this.value = val; }, setCellValue: function(row, column, val) { this.value = val; },
setTree: function(tree) { this.tree = tree; }, setTree: function(tree) { this.tree = tree; },
isContainer: function(row) { return false; }, isContainer: function(row) { return false; },
@ -37,7 +37,7 @@ var view =
isSorted: function(row) { return false; }, isSorted: function(row) { return false; },
isSelectable: function(row, column) { return true; }, isSelectable: function(row, column) { return true; },
isEditable: function(row, column) { return row != 2 || column.index != 1; }, isEditable: function(row, column) { return row != 2 || column.index != 1; },
getProgressMode: function(row, column) { return Components.interfaces.nsITreeView.PROGRESS_NORMAL; }, getProgressMode: function(row, column) { return ((typeof Components) != "undefined") ? Components.interfaces.nsITreeView.PROGRESS_NORMAL : null; },
getParentIndex: function(row, column) { return -1; }, getParentIndex: function(row, column) { return -1; },
getLevel: function(row) { return 0; }, getLevel: function(row) { return 0; },
hasNextSibling: function(row, column) { return row != this.rowCount - 1; }, hasNextSibling: function(row, column) { return row != this.rowCount - 1; },
@ -47,6 +47,9 @@ var view =
getCellProperties: function(row, column, props) { }, getCellProperties: function(row, column, props) { },
getColumnProperties: function(column, props) getColumnProperties: function(column, props)
{ {
if ((typeof netscape) == "undefined")
return;
if (!column.index) { if (!column.index) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var atomService = Components.classes["@mozilla.org/atom-service;1"]. var atomService = Components.classes["@mozilla.org/atom-service;1"].
@ -61,6 +64,9 @@ function getCustomTreeViewCellInfo()
{ {
var obj = { rows: [] }; var obj = { rows: [] };
if ((typeof view) == "undefined" || (typeof treeData) == "undefined")
return;
for (var row = 0; row < view.rowCount; row++) { for (var row = 0; row < view.rowCount; row++) {
var cellInfo = [ ]; var cellInfo = [ ];
for (var column = 0; column < 1; column++) { for (var column = 0; column < 1; column++) {