2010-05-17 09:17:50 -07:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>Accessible mutation events testing</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" type="text/css"
|
|
|
|
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
|
|
|
|
<script type="application/javascript"
|
2010-09-01 15:09:56 -07:00
|
|
|
src="../common.js"></script>
|
2010-05-17 09:17:50 -07:00
|
|
|
<script type="application/javascript"
|
2010-09-01 15:09:56 -07:00
|
|
|
src="../events.js"></script>
|
2010-05-17 09:17:50 -07:00
|
|
|
|
|
|
|
<script type="application/javascript">
|
2010-06-09 20:29:56 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Invokers
|
|
|
|
|
2010-05-17 09:17:50 -07:00
|
|
|
/**
|
2010-06-09 20:29:56 -07:00
|
|
|
* Base text remove invoker and checker.
|
2010-05-17 09:17:50 -07:00
|
|
|
*/
|
2010-06-09 20:29:56 -07:00
|
|
|
function textRemoveInvoker(aID, aStart, aEnd, aText)
|
2010-05-17 09:17:50 -07:00
|
|
|
{
|
|
|
|
this.DOMNode = getNode(aID);
|
|
|
|
|
2010-06-09 20:29:56 -07:00
|
|
|
this.eventSeq = [
|
2010-07-01 18:50:03 -07:00
|
|
|
new textChangeChecker(aID, aStart, aEnd, aText, false)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function textInsertInvoker(aID, aStart, aEnd, aText)
|
|
|
|
{
|
|
|
|
this.DOMNode = getNode(aID);
|
|
|
|
|
|
|
|
this.eventSeq = [
|
|
|
|
new textChangeChecker(aID, aStart, aEnd, aText, true)
|
2010-06-09 20:29:56 -07:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-01 18:50:03 -07:00
|
|
|
* Remove inaccessible child node containing accessibles.
|
2010-06-09 20:29:56 -07:00
|
|
|
*/
|
|
|
|
function removeChildSpan(aID)
|
|
|
|
{
|
|
|
|
this.__proto__ = new textRemoveInvoker(aID, 0, 5, "33322");
|
|
|
|
|
2010-05-17 09:17:50 -07:00
|
|
|
this.invoke = function removeChildSpan_invoke()
|
|
|
|
{
|
|
|
|
// remove HTML span, a first child of the node
|
2010-06-30 19:18:08 -07:00
|
|
|
ensureAccessibleTree(this.DOMNode);
|
2010-05-17 09:17:50 -07:00
|
|
|
this.DOMNode.removeChild(this.DOMNode.firstChild);
|
|
|
|
}
|
|
|
|
|
2010-06-09 20:29:56 -07:00
|
|
|
this.getID = function removeChildSpan_getID()
|
|
|
|
{
|
|
|
|
return "Remove inaccessible span containing accessible nodes" + prettyName(aID);
|
|
|
|
}
|
|
|
|
}
|
2010-05-17 09:17:50 -07:00
|
|
|
|
2010-07-01 18:50:03 -07:00
|
|
|
/**
|
|
|
|
* Insert inaccessible child node containing accessibles.
|
|
|
|
*/
|
2010-10-20 21:16:10 -07:00
|
|
|
function insertChildSpan(aID, aInsertAllTogether)
|
2010-07-01 18:50:03 -07:00
|
|
|
{
|
|
|
|
this.__proto__ = new textInsertInvoker(aID, 0, 5, "33322");
|
|
|
|
|
|
|
|
this.invoke = function insertChildSpan_invoke()
|
|
|
|
{
|
|
|
|
// <span><span>333</span><span>22</span></span>
|
2010-10-20 21:16:10 -07:00
|
|
|
if (aInsertAllTogether) {
|
|
|
|
var topSpan = document.createElement("span");
|
|
|
|
var fSpan = document.createElement("span");
|
|
|
|
fSpan.textContent = "333";
|
|
|
|
topSpan.appendChild(fSpan);
|
|
|
|
var sSpan = document.createElement("span");
|
|
|
|
sSpan.textContent = "22";
|
|
|
|
topSpan.appendChild(sSpan);
|
|
|
|
|
|
|
|
this.DOMNode.insertBefore(topSpan, this.DOMNode.childNodes[0]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
var topSpan = document.createElement("span");
|
|
|
|
this.DOMNode.insertBefore(topSpan, this.DOMNode.childNodes[0]);
|
|
|
|
|
|
|
|
var fSpan = document.createElement("span");
|
|
|
|
fSpan.textContent = "333";
|
|
|
|
topSpan.appendChild(fSpan);
|
|
|
|
|
|
|
|
var sSpan = document.createElement("span");
|
|
|
|
sSpan.textContent = "22";
|
|
|
|
topSpan.appendChild(sSpan);
|
|
|
|
}
|
2010-07-01 18:50:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
this.getID = function insertChildSpan_getID()
|
|
|
|
{
|
|
|
|
return "Insert inaccessible span containing accessibles" +
|
|
|
|
prettyName(aID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 20:29:56 -07:00
|
|
|
/**
|
|
|
|
* Remove child embedded accessible.
|
|
|
|
*/
|
2010-07-01 18:50:03 -07:00
|
|
|
function removeChildDiv(aID)
|
2010-06-09 20:29:56 -07:00
|
|
|
{
|
2010-07-01 18:49:42 -07:00
|
|
|
this.__proto__ = new textRemoveInvoker(aID, 5, 6, kEmbedChar);
|
2010-06-09 20:29:56 -07:00
|
|
|
|
|
|
|
this.invoke = function removeChildDiv_invoke()
|
2010-05-17 09:17:50 -07:00
|
|
|
{
|
2010-07-01 18:50:03 -07:00
|
|
|
var childDiv = this.DOMNode.childNodes[1];
|
2010-06-09 20:29:56 -07:00
|
|
|
|
|
|
|
// Ensure accessible is created to get text remove event when it's
|
|
|
|
// removed.
|
|
|
|
getAccessible(childDiv);
|
|
|
|
|
|
|
|
this.DOMNode.removeChild(childDiv);
|
2010-05-17 09:17:50 -07:00
|
|
|
}
|
|
|
|
|
2010-06-09 20:29:56 -07:00
|
|
|
this.getID = function removeChildDiv_getID()
|
2010-05-17 09:17:50 -07:00
|
|
|
{
|
2010-06-09 20:29:56 -07:00
|
|
|
return "Remove accessible div from the middle of text accessible " +
|
|
|
|
prettyName(aID);
|
2010-05-17 09:17:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-01 18:50:03 -07:00
|
|
|
/**
|
|
|
|
* Insert child embedded accessible.
|
|
|
|
*/
|
|
|
|
function insertChildDiv(aID)
|
|
|
|
{
|
|
|
|
this.__proto__ = new textInsertInvoker(aID, 5, 6, kEmbedChar);
|
|
|
|
|
|
|
|
this.invoke = function insertChildDiv_invoke()
|
|
|
|
{
|
|
|
|
var childDiv = document.createElement("div");
|
|
|
|
this.DOMNode.insertBefore(childDiv, this.DOMNode.childNodes[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getID = function insertChildDiv_getID()
|
|
|
|
{
|
|
|
|
return "Insert accessible div into the middle of text accessible " +
|
|
|
|
prettyName(aID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-01 18:49:42 -07:00
|
|
|
/**
|
|
|
|
* Remove children from text container from first to last child or vice
|
|
|
|
* versa.
|
|
|
|
*/
|
|
|
|
function removeChildren(aID, aLastToFirst, aStart, aEnd, aText)
|
|
|
|
{
|
|
|
|
this.__proto__ = new textRemoveInvoker(aID, aStart, aEnd, aText);
|
|
|
|
|
|
|
|
this.invoke = function removeChildren_invoke()
|
|
|
|
{
|
|
|
|
ensureAccessibleTree(this.DOMNode);
|
|
|
|
|
|
|
|
if (aLastToFirst) {
|
|
|
|
while (this.DOMNode.firstChild)
|
|
|
|
this.DOMNode.removeChild(this.DOMNode.lastChild);
|
|
|
|
} else {
|
|
|
|
while (this.DOMNode.firstChild)
|
|
|
|
this.DOMNode.removeChild(this.DOMNode.firstChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getID = function removeChildren_getID()
|
|
|
|
{
|
|
|
|
return "remove children of " + prettyName(aID) +
|
|
|
|
(aLastToFirst ? " from last to first" : " from first to last");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-17 09:17:50 -07:00
|
|
|
/**
|
2010-06-09 20:29:56 -07:00
|
|
|
* Remove text from HTML input.
|
2010-05-17 09:17:50 -07:00
|
|
|
*/
|
2010-06-09 20:29:56 -07:00
|
|
|
function removeTextFromInput(aID, aStart, aEnd, aText)
|
|
|
|
{
|
|
|
|
this.__proto__ = new textRemoveInvoker(aID, aStart, aEnd, aText);
|
|
|
|
|
|
|
|
this.eventSeq.push(new invokerChecker(EVENT_VALUE_CHANGE, this.DOMNode));
|
|
|
|
|
|
|
|
this.invoke = function removeTextFromInput_invoke()
|
|
|
|
{
|
|
|
|
const nsIDOMNSEditableElement =
|
|
|
|
Components.interfaces.nsIDOMNSEditableElement;
|
|
|
|
|
|
|
|
this.DOMNode.focus();
|
|
|
|
this.DOMNode.setSelectionRange(aStart, aEnd);
|
|
|
|
|
|
|
|
synthesizeKey("VK_DELETE", {});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getID = function removeTextFromInput_getID()
|
|
|
|
{
|
|
|
|
return "Remove text from " + aStart + " to " + aEnd + " for " +
|
|
|
|
prettyName(aID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-01 18:50:03 -07:00
|
|
|
/**
|
|
|
|
* Add text into HTML input.
|
|
|
|
*/
|
|
|
|
function insertTextIntoInput(aID, aStart, aEnd, aText)
|
|
|
|
{
|
|
|
|
this.__proto__ = new textInsertInvoker(aID, aStart, aEnd, aText);
|
|
|
|
|
|
|
|
this.eventSeq.push(new invokerChecker(EVENT_VALUE_CHANGE, this.DOMNode));
|
|
|
|
|
|
|
|
this.invoke = function insertTextIntoInput_invoke()
|
|
|
|
{
|
|
|
|
this.DOMNode.focus();
|
|
|
|
synthesizeKey("a", {});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getID = function insertTextIntoInput_getID()
|
|
|
|
{
|
|
|
|
return "Insert text to " + aStart + " for " + prettyName(aID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 20:29:56 -07:00
|
|
|
/**
|
|
|
|
* Remove text data from text node of editable area.
|
|
|
|
*/
|
|
|
|
function removeTextFromEditable(aID, aStart, aEnd, aText, aTextNode)
|
|
|
|
{
|
|
|
|
this.__proto__ = new textRemoveInvoker(aID, aStart, aEnd, aText);
|
|
|
|
|
|
|
|
this.invoke = function removeTextFromEditable_invoke()
|
|
|
|
{
|
|
|
|
this.DOMNode.focus();
|
|
|
|
|
|
|
|
var selection = window.getSelection();
|
|
|
|
var range = document.createRange();
|
|
|
|
range.setStart(this.textNode, aStart);
|
|
|
|
range.setEnd(this.textNode, aEnd);
|
|
|
|
selection.addRange(range);
|
|
|
|
|
|
|
|
synthesizeKey("VK_DELETE", {});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.getID = function removeTextFromEditable_getID()
|
|
|
|
{
|
|
|
|
return "Remove text from " + aStart + " to " + aEnd + " for " +
|
|
|
|
prettyName(aID);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.textNode = getNode(aTextNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Do tests
|
2010-05-17 09:17:50 -07:00
|
|
|
var gQueue = null;
|
2010-07-01 18:49:42 -07:00
|
|
|
//gA11yEventDumpID = "eventdump"; // debug stuff
|
2010-05-17 09:17:50 -07:00
|
|
|
|
|
|
|
function doTests()
|
|
|
|
{
|
|
|
|
gQueue = new eventQueue();
|
|
|
|
|
|
|
|
// Text remove event on inaccessible child HTML span removal containing
|
|
|
|
// accessible text nodes.
|
|
|
|
gQueue.push(new removeChildSpan("p"));
|
2010-10-20 21:16:10 -07:00
|
|
|
gQueue.push(new insertChildSpan("p"), true);
|
|
|
|
gQueue.push(new insertChildSpan("p"), false);
|
2010-05-17 09:17:50 -07:00
|
|
|
|
2010-06-09 20:29:56 -07:00
|
|
|
// Remove embedded character.
|
2010-07-01 18:50:03 -07:00
|
|
|
gQueue.push(new removeChildDiv("div"));
|
|
|
|
gQueue.push(new insertChildDiv("div"));
|
2010-06-09 20:29:56 -07:00
|
|
|
|
2010-07-01 18:49:42 -07:00
|
|
|
// Remove all children.
|
|
|
|
var text = kEmbedChar + "txt" + kEmbedChar;
|
|
|
|
gQueue.push(new removeChildren("div2", true, 0, 5, text));
|
|
|
|
gQueue.push(new removeChildren("div3", false, 0, 5, text));
|
|
|
|
|
2010-06-09 20:29:56 -07:00
|
|
|
// Text remove from text node within hypertext accessible.
|
|
|
|
gQueue.push(new removeTextFromInput("input", 1, 3, "al"));
|
2010-07-01 18:50:03 -07:00
|
|
|
gQueue.push(new insertTextIntoInput("input", 1, 2, "a"));
|
2010-06-09 20:29:56 -07:00
|
|
|
|
|
|
|
// bug 570691
|
|
|
|
todo(false, "Fix text change events from editable area, see bug 570691");
|
|
|
|
//var textNode = getNode("editable").firstChild;
|
|
|
|
//gQueue.push(new removeTextFromEditable("editable", 1, 3, "al", textNode));
|
|
|
|
//textNode = getNode("editable2").firstChild.firstChild;
|
|
|
|
//gQueue.push(new removeTextFromEditable("editable2", 1, 3, "al", textNode));
|
|
|
|
|
2010-05-17 09:17:50 -07:00
|
|
|
gQueue.invoke(); // Will call SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
addA11yLoadEvent(doTests);
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=566293"
|
|
|
|
title=" wrong length of text remove event when inaccessible node containing accessible nodes is removed">
|
|
|
|
Mozilla Bug 566293
|
2010-07-01 18:49:42 -07:00
|
|
|
</a><br>
|
2010-06-09 20:29:56 -07:00
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=570710"
|
|
|
|
title="Avoid extra array traversal during text event creation">
|
|
|
|
Mozilla Bug 570710
|
2010-07-01 18:49:42 -07:00
|
|
|
</a><br>
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=574003"
|
|
|
|
title="Coalesce text events on nodes removal">
|
|
|
|
Mozilla Bug 574003
|
2010-06-09 20:29:56 -07:00
|
|
|
</a>
|
2010-07-01 18:50:03 -07:00
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=575052"
|
|
|
|
title="Cache text offsets within hypertext accessible">
|
|
|
|
Mozilla Bug 575052
|
|
|
|
</a>
|
2010-10-20 21:16:10 -07:00
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=570275"
|
|
|
|
title="Rework accessible tree update code">
|
|
|
|
Mozilla Bug 570275
|
|
|
|
</a>
|
2010-05-17 09:17:50 -07:00
|
|
|
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none"></div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
<div id="eventdump"></div>
|
|
|
|
|
|
|
|
<p id="p"><span><span>333</span><span>22</span></span>1111</p>
|
2010-06-09 20:29:56 -07:00
|
|
|
<div id="div">hello<div>hello</div>hello</div>
|
2010-07-01 18:49:42 -07:00
|
|
|
<div id="div2"><div>txt</div>txt<div>txt</div></div>
|
|
|
|
<div id="div3"><div>txt</div>txt<div>txt</div></div>
|
2010-06-09 20:29:56 -07:00
|
|
|
<input id="input" value="value">
|
|
|
|
<div contentEditable="true" id="editable">value</div>
|
|
|
|
<div contentEditable="true" id="editable2"><span>value</span></div>
|
2010-05-17 09:17:50 -07:00
|
|
|
</body>
|
|
|
|
</html>
|