diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp
index 057a77325f0..6e8fc3c21cf 100644
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -92,12 +92,16 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTreeAccessible)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULTreeAccessible,
nsAccessible)
-CycleCollectorTraverseCache(tmp->mAccessibleCache, &cb);
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTree)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTreeView)
+ CycleCollectorTraverseCache(tmp->mAccessibleCache, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULTreeAccessible,
nsAccessible)
-ClearCache(tmp->mAccessibleCache);
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTree)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTreeView)
+ ClearCache(tmp->mAccessibleCache);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXULTreeAccessible)
diff --git a/accessible/tests/mochitest/actions/test_tree.xul b/accessible/tests/mochitest/actions/test_tree.xul
index fe4921abfef..94c46f4da13 100644
--- a/accessible/tests/mochitest/actions/test_tree.xul
+++ b/accessible/tests/mochitest/actions/test_tree.xul
@@ -43,7 +43,7 @@
// gA11yEventDumpID = "debug";
//gA11yEventDumpToConsole = true; // debug
- function doTestActions()
+ function doTest()
{
var treeNode = getNode("tree");
@@ -91,15 +91,8 @@
testActions(actions); // Will call SimpleTest.finish();
}
- function doTest()
- {
- var treeNode = getNode("tree");
- waitForEvent(EVENT_REORDER, treeNode, doTestActions);
- treeNode.view = new nsTreeTreeView();
- }
-
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTest);
+ addA11yXULTreeLoadEvent(doTest, "tree", new nsTreeTreeView());
]]>
diff --git a/accessible/tests/mochitest/attributes/test_obj_group_tree.xul b/accessible/tests/mochitest/attributes/test_obj_group_tree.xul
index 1b6ecef7f68..6b8461ef7f3 100644
--- a/accessible/tests/mochitest/attributes/test_obj_group_tree.xul
+++ b/accessible/tests/mochitest/attributes/test_obj_group_tree.xul
@@ -24,7 +24,7 @@
////////////////////////////////////////////////////////////////////////////
// Test
- function doTestAttrs()
+ function doTest()
{
var treeNode = getNode("tree");
@@ -50,15 +50,8 @@
SimpleTest.finish();
}
- function doTest()
- {
- var treeNode = getNode("tree");
- waitForEvent(EVENT_REORDER, treeNode, doTestAttrs);
- treeNode.view = new nsTreeTreeView();
- }
-
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTest);
+ addA11yXULTreeLoadEvent(doTest, "tree", new nsTreeTreeView());
]]>
diff --git a/accessible/tests/mochitest/events/test_focus_tree.xul b/accessible/tests/mochitest/events/test_focus_tree.xul
index 16200adc645..f956de4fc5d 100644
--- a/accessible/tests/mochitest/events/test_focus_tree.xul
+++ b/accessible/tests/mochitest/events/test_focus_tree.xul
@@ -29,23 +29,6 @@
////////////////////////////////////////////////////////////////////////////
// Invokers
- function setTreeView(aTreeID, aView)
- {
- this.DOMNode = getNode(aTreeID);
-
- this.eventSeq = [
- new invokerChecker(EVENT_REORDER, this.DOMNode)
- ];
-
- this.invoke = function setTreeView_invoke()
- {
- this.DOMNode.treeBoxObject.view = aView;
- }
-
- this.getID = function setTreeView_getID()
- { return "set tree view for " + prettyName(aTreeID); }
- };
-
function focusTree(aTreeID)
{
var checker = new focusChecker(getFirstTreeItem, aTreeID);
@@ -82,7 +65,6 @@
{
gQueue = new eventQueue();
- gQueue.push(new setTreeView("tree", new nsTableTreeView(5)));
gQueue.push(new focusTree("tree"));
gQueue.push(new moveToNextItem("tree"));
gQueue.push(new synthFocus("emptytree"));
@@ -94,7 +76,7 @@
}
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTest);
+ addA11yXULTreeLoadEvent(doTest, "tree", new nsTableTreeView(5));
]]>
diff --git a/accessible/tests/mochitest/focus/test_takeFocus.xul b/accessible/tests/mochitest/focus/test_takeFocus.xul
index 7f4c42d6013..50858ce9b2d 100644
--- a/accessible/tests/mochitest/focus/test_takeFocus.xul
+++ b/accessible/tests/mochitest/focus/test_takeFocus.xul
@@ -26,23 +26,6 @@
////////////////////////////////////////////////////////////////////////////
// Invokers
- function setTreeView(aTreeID, aView)
- {
- this.DOMNode = getNode(aTreeID);
-
- this.eventSeq = [
- new invokerChecker(EVENT_REORDER, this.DOMNode)
- ];
-
- this.invoke = function setTreeView_invoke()
- {
- this.DOMNode.treeBoxObject.view = aView;
- }
-
- this.getID = function setTreeView_getID()
- { return "set tree view for " + prettyName(aTreeID); }
- };
-
function takeFocusInvoker(aID, aArgConverterFunc)
{
this.targetFunc = aArgConverterFunc ? aArgConverterFunc : getAccessible;
@@ -77,7 +60,6 @@
// Test focus events.
gQueue = new eventQueue();
- gQueue.push(new setTreeView("tree", new nsTableTreeView(5)));
gQueue.push(new takeFocusInvoker("tree", getLastChild));
gQueue.push(new takeFocusInvoker("listitem2"));
@@ -85,7 +67,7 @@
}
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTests);
+ addA11yXULTreeLoadEvent(doTests, "tree", new nsTableTreeView(5));
]]>
diff --git a/accessible/tests/mochitest/hittest/test_general.xul b/accessible/tests/mochitest/hittest/test_general.xul
index ae9621078e9..cdb91a70b56 100644
--- a/accessible/tests/mochitest/hittest/test_general.xul
+++ b/accessible/tests/mochitest/hittest/test_general.xul
@@ -14,6 +14,8 @@
+
@@ -21,26 +23,13 @@
diff --git a/accessible/tests/mochitest/relations/test_tree.xul b/accessible/tests/mochitest/relations/test_tree.xul
index 6f888776b33..7a74aaeb56c 100644
--- a/accessible/tests/mochitest/relations/test_tree.xul
+++ b/accessible/tests/mochitest/relations/test_tree.xul
@@ -24,7 +24,7 @@
////////////////////////////////////////////////////////////////////////////
// Test
- function doTestRelations()
+ function doTest()
{
var treeNode = getNode("tree");
@@ -54,15 +54,8 @@
SimpleTest.finish();
}
- function doTest()
- {
- var treeNode = getNode("tree");
- waitForEvent(EVENT_REORDER, treeNode, doTestRelations);
- treeNode.view = new nsTreeTreeView();
- }
-
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTest);
+ addA11yXULTreeLoadEvent(doTest, "tree", new nsTreeTreeView());
]]>
diff --git a/accessible/tests/mochitest/table/test_headers_tree.xul b/accessible/tests/mochitest/table/test_headers_tree.xul
index d4add49e09b..9b69e8a0d75 100644
--- a/accessible/tests/mochitest/table/test_headers_tree.xul
+++ b/accessible/tests/mochitest/table/test_headers_tree.xul
@@ -24,26 +24,11 @@
////////////////////////////////////////////////////////////////////////////
// Test
- var gTree = null;
- var gTreeBox = null;
- var gTreeView = null;
-
// gA11yEventDumpID = "debug";
function doTest()
{
- // Initialize the tree
- gTree = document.getElementById("tree");
- gTreeBox = gTree.treeBoxObject;
- gView = new nsTableTreeView(3);
-
- waitForEvent(EVENT_REORDER, gTree, continueTest);
- gTreeBox.view = gView;
- }
-
- function continueTest()
- {
- var treeAcc = getAccessible(gTree, [nsIAccessibleTable]);
+ var treeAcc = getAccessible("tree", [nsIAccessibleTable]);
var headerInfoMap = [
{
@@ -84,7 +69,7 @@
}
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTest);
+ addA11yXULTreeLoadEvent(doTest, "tree", new nsTableTreeView(3));
]]>
diff --git a/accessible/tests/mochitest/table/test_indexes_tree.xul b/accessible/tests/mochitest/table/test_indexes_tree.xul
index c61e9a2a0ab..89a751419bc 100644
--- a/accessible/tests/mochitest/table/test_indexes_tree.xul
+++ b/accessible/tests/mochitest/table/test_indexes_tree.xul
@@ -24,37 +24,22 @@
////////////////////////////////////////////////////////////////////////////
// Test
- var gTree = null;
- var gTreeBox = null;
- var gTreeView = null;
-
// gA11yEventDumpID = "debug";
function doTest()
- {
- // Initialize the tree
- gTree = document.getElementById("tree");
- gTreeBox = gTree.treeBoxObject;
- gView = new nsTableTreeView(3);
-
- waitForEvent(EVENT_REORDER, gTree, continueTest);
- gTreeBox.view = gView;
- }
-
- function continueTest()
{
var idxes = [
[0, 1],
[2, 3],
[4, 5]
];
- testTableIndexes(gTree, idxes);
+ testTableIndexes("tree", idxes);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTest);
+ addA11yXULTreeLoadEvent(doTest, "tree", new nsTableTreeView(3));
]]>
diff --git a/accessible/tests/mochitest/table/test_sels_tree.xul b/accessible/tests/mochitest/table/test_sels_tree.xul
index f73fd03cd5d..0e1d0ad0eb9 100644
--- a/accessible/tests/mochitest/table/test_sels_tree.xul
+++ b/accessible/tests/mochitest/table/test_sels_tree.xul
@@ -26,24 +26,9 @@
////////////////////////////////////////////////////////////////////////////
// Test
- var gTree = null;
- var gTreeBox = null;
- var gTreeView = null;
-
// gA11yEventDumpID = "debug";
function doTest()
- {
- // Initialize the tree
- gTree = document.getElementById("tree");
- gTreeBox = gTree.treeBoxObject;
- gView = new nsTableTreeView(3);
-
- waitForEvent(EVENT_REORDER, gTree, continueTest);
- gTreeBox.view = gView;
- }
-
- function continueTest()
{
var cellsArray =
[
@@ -52,15 +37,15 @@
[false, false]
];
- testTableSelection(gTree, cellsArray);
- testSelectTableRow(gTree, 0, cellsArray);
- testUnselectTableRow(gTree, 0, cellsArray);
+ testTableSelection("tree", cellsArray);
+ testSelectTableRow("tree", 0, cellsArray);
+ testUnselectTableRow("tree", 0, cellsArray);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTest);
+ addA11yXULTreeLoadEvent(doTest, "tree", new nsTableTreeView(3));
]]>
diff --git a/accessible/tests/mochitest/table/test_struct_tree.xul b/accessible/tests/mochitest/table/test_struct_tree.xul
index b06ca53268b..2037bf7149c 100644
--- a/accessible/tests/mochitest/table/test_struct_tree.xul
+++ b/accessible/tests/mochitest/table/test_struct_tree.xul
@@ -26,24 +26,9 @@
////////////////////////////////////////////////////////////////////////////
// Test
- var gTree = null;
- var gTreeBox = null;
- var gTreeView = null;
-
// gA11yEventDumpID = "debug";
function doTest()
- {
- // Initialize the tree
- gTree = document.getElementById("table");
- gTreeBox = gTree.treeBoxObject;
- gView = new nsTableTreeView(3);
-
- waitForEvent(EVENT_REORDER, gTree, continueTest);
- gTreeBox.view = gView;
- }
-
- function continueTest()
{
var cellsArray = [
[kDataCell, kDataCell],
@@ -51,13 +36,13 @@
[kDataCell, kDataCell]
];
- testTableStruct(gTree, cellsArray, kTreeColumnHeader);
+ testTableStruct("table", cellsArray, kTreeColumnHeader);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
- addA11yLoadEvent(doTest);
+ addA11yXULTreeLoadEvent(doTest, "table", new nsTableTreeView(3));
]]>
diff --git a/accessible/tests/mochitest/treeview.js b/accessible/tests/mochitest/treeview.js
index 874be9ad6eb..4971059534b 100644
--- a/accessible/tests/mochitest/treeview.js
+++ b/accessible/tests/mochitest/treeview.js
@@ -1,3 +1,44 @@
+/**
+ * Helper method to start a single XUL tree test.
+ */
+var gXULTreeLoadQueue = null;
+function addA11yXULTreeLoadEvent(aDoTestFunc, aTreeID, aTreeView)
+{
+ function loadXULTree(aTreeID, aTreeView)
+ {
+ this.treeNode = getNode(aTreeID);
+
+ this.eventSeq = [
+ new invokerChecker(EVENT_REORDER, this.treeNode)
+ ];
+
+ this.invoke = function loadXULTree_invoke()
+ {
+ this.treeNode.treeBoxObject.view = aTreeView;
+ }
+
+ this.getID = function loadXULTree_getID()
+ {
+ return "Load XUL tree " + prettyName(aTreeID);
+ }
+ }
+
+ function doXULTreeTest()
+ {
+ gXULTreeLoadQueue = new eventQueue();
+ gXULTreeLoadQueue.push(new loadXULTree(aTreeID, aTreeView));
+ gXULTreeLoadQueue.onFinish = function()
+ {
+ SimpleTest.executeSoon(aDoTestFunc);
+ return DO_NOT_FINISH_TEST;
+ }
+ gXULTreeLoadQueue.invoke();
+ }
+
+ addA11yLoadEvent(doXULTreeTest);
+}
+
+
function nsTableTreeView(aRowCount)
{
this.__proto__ = new nsTreeView();