Bug 738635 - fix XUL tree accessible leak and add XUL tree mochitest sugar, r=marcoz

This commit is contained in:
Alexander Surkov 2012-03-24 11:30:11 +09:00
Родитель 750cb23e3c
Коммит 1a037afb2c
12 изменённых файлов: 69 добавлений и 152 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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());
]]>
</script>

Просмотреть файл

@ -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());
]]>
</script>

Просмотреть файл

@ -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));
]]>
</script>

Просмотреть файл

@ -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));
]]>
</script>

Просмотреть файл

@ -14,6 +14,8 @@
<script type="application/javascript"
src="../common.js" />
<script type="application/javascript"
src="../events.js" />
<script type="application/javascript"
src="../layout.js" />
@ -21,26 +23,13 @@
<![CDATA[
function doTest()
{
// Initialize the tree
var view = new nsTableTreeView(5);
var tree = getNode("tree");
var treeBox = tree.treeBoxObject;
treeBox.view = view;
// Tests
var treecols = getNode("treecols");
var x = treecols.boxObject.x;
var y = treecols.boxObject.y;
testChildAtPoint(tree, x, y, false, treecols);
testChildAtPoint(tree, x, y, true, "col1");
hitTest("tree", "treecols", "col1");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
addA11yXULTreeLoadEvent(doTest, "tree", new nsTableTreeView(5));
]]>
</script>

Просмотреть файл

@ -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());
]]>
</script>

Просмотреть файл

@ -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));
]]>
</script>

Просмотреть файл

@ -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));
]]>
</script>

Просмотреть файл

@ -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));
]]>
</script>

Просмотреть файл

@ -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));
]]>
</script>

Просмотреть файл

@ -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();