2009-02-27 02:45:21 -08:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
|
|
|
type="text/css"?>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
Bug 368835 - fire TreeViewChanged/TreeRowCountChanged events.
|
|
|
|
Bug 308564 - no accessibility events when data in a tree row changes.
|
|
|
|
-->
|
|
|
|
|
|
|
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
title="DOM TreeViewChanged/TreeRowCountChanged and a11y name change events.">
|
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/MochiKit/packed.js" />
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/a11y/accessible/treeview.js" />
|
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/a11y/accessible/common.js" />
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/a11y/accessible/events.js" />
|
|
|
|
|
|
|
|
<script type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Invoker's checkers
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
/**
|
|
|
|
* Check TreeViewChanged event and run through accessible tree to ensure
|
|
|
|
* it's created.
|
|
|
|
*/
|
|
|
|
function treeViewChangedChecker(aMsg)
|
|
|
|
{
|
|
|
|
this.type = "TreeViewChanged";
|
|
|
|
this.target = gTree;
|
|
|
|
this.check = function check(aEvent)
|
|
|
|
{
|
|
|
|
ensureAccessibleTree(gTree);
|
|
|
|
}
|
|
|
|
this.getID = function getID()
|
|
|
|
{
|
|
|
|
return "TreeViewChanged";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-27 02:45:21 -08:00
|
|
|
/**
|
|
|
|
* Check TreeRowCountChanged event.
|
|
|
|
*/
|
|
|
|
function rowCountChangedChecker(aMsg, aIdx, aCount)
|
|
|
|
{
|
|
|
|
this.type = "TreeRowCountChanged";
|
|
|
|
this.target = gTree;
|
|
|
|
this.check = function check(aEvent)
|
|
|
|
{
|
|
|
|
var index = aEvent.getData("index");
|
|
|
|
is(index, aIdx, "Wrong 'index' data of 'treeRowCountChanged' event.");
|
|
|
|
|
|
|
|
var count = aEvent.getData("count");
|
|
|
|
is(count, aCount, "Wrong 'count' data of 'treeRowCountChanged' event.");
|
|
|
|
}
|
|
|
|
this.getID = function getID()
|
|
|
|
{
|
|
|
|
return aMsg + "TreeRowCountChanged";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check TreeInvalidated event.
|
|
|
|
*/
|
|
|
|
function treeInvalidatedChecker(aMsg, aStartRow, aEndRow, aStartCol, aEndCol)
|
|
|
|
{
|
|
|
|
this.type = "TreeInvalidated";
|
|
|
|
this.target = gTree;
|
|
|
|
this.check = function check(aEvent)
|
|
|
|
{
|
|
|
|
var startRow = aEvent.getData("startrow");
|
|
|
|
is(startRow, aStartRow,
|
|
|
|
"Wrong 'startrow' of 'treeInvalidated' event on " + aMsg);
|
|
|
|
|
|
|
|
var endRow = aEvent.getData("endrow");
|
|
|
|
is(endRow, aEndRow,
|
|
|
|
"Wrong 'endrow' of 'treeInvalidated' event on " + aMsg);
|
|
|
|
|
|
|
|
var startCol = aEvent.getData("startcolumn");
|
|
|
|
is(startCol, aStartCol,
|
|
|
|
"Wrong 'startcolumn' of 'treeInvalidated' event on " + aMsg);
|
|
|
|
|
|
|
|
var endCol = aEvent.getData("endcolumn");
|
|
|
|
is(endCol, aEndCol,
|
|
|
|
"Wrong 'endcolumn' of 'treeInvalidated' event on " + aMsg);
|
|
|
|
}
|
|
|
|
this.getID = function getID()
|
|
|
|
{
|
|
|
|
return "TreeInvalidated on " + aMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check name changed a11y event.
|
|
|
|
*/
|
|
|
|
function nameChangeChecker(aMsg, aRow, aCol)
|
|
|
|
{
|
|
|
|
this.type = EVENT_NAME_CHANGE;
|
|
|
|
|
|
|
|
this.target getter = function()
|
|
|
|
{
|
|
|
|
var acc = getAccessible(gTree);
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
var tableAcc = getAccessible(acc, [nsIAccessibleTable]);
|
2009-09-10 18:07:56 -07:00
|
|
|
return tableAcc.getCellAt(aRow, aCol);
|
2009-02-27 02:45:21 -08:00
|
|
|
}
|
|
|
|
this.getID = function getID()
|
|
|
|
{
|
|
|
|
return aMsg + "name changed";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Invokers
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set tree view and process TreeViewChanged handler.
|
|
|
|
*/
|
|
|
|
function setTreeView()
|
|
|
|
{
|
|
|
|
this.invoke = function setTreeView_invoke()
|
|
|
|
{
|
|
|
|
gTreeBox.view = gView;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getID = function setTreeView_getID() { return "TreeViewChanged"; }
|
|
|
|
|
2009-08-19 23:45:19 -07:00
|
|
|
this.eventSeq = [ new treeViewChangedChecker() ];
|
2009-02-27 02:45:21 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert row at 0 index and checks TreeRowCountChanged and TreeInvalidated
|
|
|
|
* event.
|
|
|
|
*/
|
|
|
|
function insertRow()
|
|
|
|
{
|
|
|
|
this.invoke = function insertRow_invoke()
|
|
|
|
{
|
2009-08-19 23:45:19 -07:00
|
|
|
gView.appendItem("last");
|
2009-02-27 02:45:21 -08:00
|
|
|
gTreeBox.rowCountChanged(0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.eventSeq =
|
|
|
|
[
|
|
|
|
new rowCountChangedChecker("insertRow: ", 0, 1),
|
|
|
|
new treeInvalidatedChecker("insertRow", 0, 5, null, null)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invalidates first column and checks six name changed events for each
|
|
|
|
* treeitem plus TreeInvalidated event.
|
|
|
|
*/
|
|
|
|
function invalidateColumn()
|
|
|
|
{
|
|
|
|
this.invoke = function()
|
|
|
|
{
|
|
|
|
// Make sure accessibles for the tree is created because it makes
|
|
|
|
// sure accessible events will be fired.
|
2009-08-19 23:45:19 -07:00
|
|
|
// Make sure tree children accessibles are created otherwise they won't
|
2009-02-27 02:45:21 -08:00
|
|
|
// be a cause of name changed events.
|
2009-08-19 23:45:19 -07:00
|
|
|
ensureAccessibleTree(gTree);
|
2009-02-27 02:45:21 -08:00
|
|
|
|
|
|
|
// Fire 'TreeInvalidated' event by InvalidateColumn()
|
|
|
|
var firstCol = gTree.columns.getFirstColumn();
|
2009-08-19 23:45:19 -07:00
|
|
|
for (var i = 0; i < gView.rowCount; i++)
|
|
|
|
gView.setCellText(i, firstCol, "hey " + String(i) + "x0");
|
2009-02-27 02:45:21 -08:00
|
|
|
|
|
|
|
gTreeBox.invalidateColumn(firstCol);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.eventSeq =
|
|
|
|
[
|
|
|
|
new nameChangeChecker("invalidateColumn: ", 0, 0),
|
|
|
|
new nameChangeChecker("invalidateColumn: ", 1, 0),
|
|
|
|
new nameChangeChecker("invalidateColumn: ", 2, 0),
|
|
|
|
new nameChangeChecker("invalidateColumn: ", 3, 0),
|
|
|
|
new nameChangeChecker("invalidateColumn: ", 4, 0),
|
|
|
|
new nameChangeChecker("invalidateColumn: ", 5, 0),
|
|
|
|
new treeInvalidatedChecker("invalidateColumn", null, null, 0, 0)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invalidates second row and checks name changed event for first treeitem
|
|
|
|
* (note, there are two name changed events on linux due to different
|
|
|
|
* accessible tree for xul:tree element) plus TreeInvalidated event.
|
|
|
|
*/
|
|
|
|
function invalidateRow()
|
|
|
|
{
|
|
|
|
this.invoke = function()
|
|
|
|
{
|
|
|
|
// Fire 'TreeInvalidated' event by InvalidateRow()
|
|
|
|
var colCount = gTree.columns.count;
|
2009-08-19 23:45:19 -07:00
|
|
|
var column = gTree.columns.getFirstColumn();
|
|
|
|
while (column) {
|
|
|
|
gView.setCellText(1, column, "aloha 1x" + String(column.index));
|
|
|
|
column = column.getNext();
|
2009-02-27 02:45:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
gTreeBox.invalidateRow(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.eventSeq =
|
|
|
|
[
|
|
|
|
new nameChangeChecker("invalidateColumn: ", 1, 0),
|
2009-08-19 23:45:19 -07:00
|
|
|
new nameChangeChecker("invalidateColumn: ", 1, 1),
|
2009-02-27 02:45:21 -08:00
|
|
|
new treeInvalidatedChecker("invalidateColumn", 1, 1, null, null)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Test
|
|
|
|
|
|
|
|
var gTree = null;
|
|
|
|
var gTreeBox = null;
|
|
|
|
var gTreeView = null;
|
|
|
|
var gQueue = null;
|
|
|
|
|
|
|
|
// gA11yEventDumpID = "debug";
|
|
|
|
|
|
|
|
function doTest()
|
|
|
|
{
|
|
|
|
// Initialize the tree
|
|
|
|
gTree = document.getElementById("tree");
|
|
|
|
gTreeBox = gTree.treeBoxObject;
|
2009-08-19 23:45:19 -07:00
|
|
|
gView = new nsTableTreeView(5);
|
2009-02-27 02:45:21 -08:00
|
|
|
|
|
|
|
// Perform actions
|
|
|
|
gQueue = new eventQueue();
|
|
|
|
|
|
|
|
gQueue.push(new setTreeView());
|
|
|
|
gQueue.push(new insertRow());
|
|
|
|
gQueue.push(new invalidateColumn());
|
|
|
|
gQueue.push(new invalidateRow());
|
|
|
|
|
|
|
|
gQueue.invoke();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
addA11yLoadEvent(doTest);
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<hbox flex="1" style="overflow: auto;">
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=368835"
|
|
|
|
title="Fire TreeViewChanged/TreeRowCountChanged events.">
|
|
|
|
Mozilla Bug 368835
|
|
|
|
</a><br/>
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=308564"
|
|
|
|
title="No accessibility events when data in a tree row changes.">
|
|
|
|
Mozilla Bug 308564
|
|
|
|
</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
<vbox id="debug"/>
|
|
|
|
<tree id="tree" flex="1">
|
|
|
|
<treecols>
|
2009-08-19 23:45:19 -07:00
|
|
|
<treecol id="col1" flex="1" primary="true" label="column"/>
|
|
|
|
<treecol id="col2" flex="1" label="column 2"/>
|
2009-02-27 02:45:21 -08:00
|
|
|
</treecols>
|
|
|
|
<treechildren id="treechildren"/>
|
|
|
|
</tree>
|
|
|
|
</hbox>
|
|
|
|
|
|
|
|
</window>
|
|
|
|
|