Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<title>Whitespace text accessible creation/destruction</title>
<link rel="stylesheet" type="text/css"
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
// //////////////////////////////////////////////////////////////////////////
// Invokers
/**
* Middle image accessible removal results in text accessible removal.
*
* Before:
* DOM: whitespace img1 whitespace img2 whitespace img3 whitespace,
* a11y: img1 whitespace img2 whitespace img3
* After:
* DOM: whitespace img1 whitespace whitespace img3 whitespace,
* a11y: img1 whitespace img3
*/
function removeImg() {
this.containerNode = getNode("container1");
this.imgNode = getNode("img1");
this.img = getAccessible(this.imgNode);
this.text = this.img.nextSibling;
this.eventSeq = [
new invokerChecker(EVENT_HIDE, this.img),
new invokerChecker(EVENT_HIDE, this.text),
new invokerChecker(EVENT_REORDER, this.containerNode),
];
this.finalCheck = function textLeafUpdate_finalCheck() {
var tree =
{ SECTION: [
{ GRAPHIC: [] },
{ TEXT_LEAF: [] },
{ GRAPHIC: [] },
] };
testAccessibleTree(this.containerNode, tree);
};
this.invoke = function setOnClickAttr_invoke() {
var tree =
{ SECTION: [
{ GRAPHIC: [] },
{ TEXT_LEAF: [] },
{ GRAPHIC: [] },
{ TEXT_LEAF: [] },
{ GRAPHIC: [] },
] };
testAccessibleTree(this.containerNode, tree);
this.containerNode.removeChild(this.imgNode);
};
this.getID = function setOnClickAttr_getID() {
return "remove middle img";
};
}
/**
* Append image making the whitespace visible and thus accessible.
* Note: images and whitespaces are on different leves of accessible trees,
* so that image container accessible update doesn't update the tree
* of whitespace container.
*
* Before:
* DOM: whitespace emptylink whitespace linkwithimg whitespace
* a11y: emptylink linkwithimg
* After:
* DOM: whitespace linkwithimg whitespace linkwithimg whitespace
* a11y: linkwithimg whitespace linkwithimg
*/
function insertImg() {
this.containerNode = getNode("container2");
this.topNode = this.containerNode.parentNode;
this.textNode = this.containerNode.nextSibling;
this.imgNode = document.createElement("img");
this.imgNode.setAttribute("src", "../moz.png");
this.eventSeq = [
new asyncInvokerChecker(EVENT_SHOW, getAccessible, this.textNode),
new asyncInvokerChecker(EVENT_SHOW, getAccessible, this.imgNode),
new orderChecker(),
new invokerChecker(EVENT_REORDER, this.topNode),
];
this.invoke = function insertImg_invoke() {
var tree =
{ SECTION: [
{ LINK: [] },
{ LINK: [
{ GRAPHIC: [] },
] },
] };
testAccessibleTree(this.topNode, tree);
this.containerNode.appendChild(this.imgNode);
};
this.finalCheck = function insertImg_finalCheck() {
var tree =
{ SECTION: [
{ LINK: [
{ GRAPHIC: [ ] },
] },
{ TEXT_LEAF: [ ] },
{ LINK: [
{ GRAPHIC: [ ] },
] },
] };
testAccessibleTree(this.topNode, tree);
};
this.getID = function appendImg_getID() {
return "insert img into internal container";
};
}
function dontCreateMapWhiteSpace() {
const tree = { SECTION: [ { role: ROLE_TEXT_LEAF, name: "x" } ] };
testAccessibleTree("container3", tree);
getNode("c3_inner").style.textAlign = "center";
document.body.offsetTop; // Flush layout.
window.windowUtils.advanceTimeAndRefresh(100);
testAccessibleTree("container3", tree);
window.windowUtils.restoreNormalRefresh();
}
// //////////////////////////////////////////////////////////////////////////
// Test
// gA11yEventDumpID = "eventdump"; // debug stuff
// gA11yEventDumpToConsole = true;
var gQueue = null;
function doTest() {
dontCreateMapWhiteSpace();
gQueue = new eventQueue();
gQueue.push(new removeImg());
gQueue.push(new insertImg());
gQueue.invoke(); // SimpleTest.finish() will be called in the end
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
title="Make sure accessible tree is correct when rendered text is changed"
Mozilla Bug 625652
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<!-- Whitespace between the div and img tags will be inconsistent depending
on the image cache state and what optimizations layout was able to
apply. -->
<div id="container1"><img src="../moz.png"> <img id="img1" src="../moz.png"> <img src="../moz.png"></div>
<div><a id="container2" href=""></a> <a href=""><img src="../moz.png"></a></div>
<div id="container3">
<div id="c3_inner" role="presentation">
x<map> </map>
</div>
</div>
<div id="eventdump"></div>
</body>
</html>