test_textleaf.html (4867B)
1 <!DOCTYPE html> 2 <html> 3 4 <head> 5 <title>Test accessible recreation</title> 6 7 <link rel="stylesheet" type="text/css" 8 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 9 10 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 11 12 <script type="application/javascript" 13 src="../common.js"></script> 14 <script type="application/javascript" 15 src="../role.js"></script> 16 <script type="application/javascript" 17 src="../events.js"></script> 18 19 <script type="application/javascript"> 20 21 // ////////////////////////////////////////////////////////////////////////// 22 // Invokers 23 24 function textLeafUpdate(aID, aIsTextLeafLinkable) { 25 this.node = getNode(aID); 26 27 this.eventSeq = [ 28 new invokerChecker(EVENT_REORDER, this.node.parentNode), 29 ]; 30 31 this.finalCheck = function textLeafUpdate_finalCheck() { 32 var textLeaf = getAccessible(this.node).firstChild; 33 is(textLeaf.actionCount, (aIsTextLeafLinkable ? 1 : 0), 34 "Wrong action numbers!"); 35 }; 36 } 37 38 function setOnClickAttr(aID) { 39 var node = getNode(aID); 40 node.setAttribute("onclick", "alert(3);"); 41 var textLeaf = getAccessible(node).firstChild; 42 is(textLeaf.actionCount, 1, "setOnClickAttr: wrong action numbers!"); 43 } 44 45 function removeOnClickAttr(aID) { 46 var node = getNode(aID); 47 node.removeAttribute("onclick"); 48 var textLeaf = getAccessible(node).firstChild; 49 is(textLeaf.actionCount, 0, 50 "removeOnClickAttr: wrong action numbers!"); 51 } 52 53 function setOnClickNRoleAttrs(aID) { 54 this.__proto__ = new textLeafUpdate(aID, true); 55 56 this.invoke = function setOnClickAttr_invoke() { 57 this.node.setAttribute("role", "link"); 58 this.node.setAttribute("onclick", "alert(3);"); 59 }; 60 61 this.getID = function setOnClickAttr_getID() { 62 return "make " + prettyName(aID) + " linkable"; 63 }; 64 } 65 66 function removeTextData(aID, aRole) { 67 this.containerNode = getNode(aID); 68 this.textNode = this.containerNode.firstChild; 69 70 this.eventSeq = [ 71 new invokerChecker(EVENT_REORDER, this.containerNode), 72 ]; 73 74 this.invoke = function removeTextData_invoke() { 75 var tree = { 76 role: aRole, 77 children: [ 78 { 79 role: ROLE_TEXT_LEAF, 80 name: "text", 81 }, 82 ], 83 }; 84 testAccessibleTree(this.containerNode, tree); 85 86 this.textNode.data = ""; 87 }; 88 89 this.finalCheck = function removeTextData_finalCheck() { 90 var tree = { 91 role: aRole, 92 children: [], 93 }; 94 testAccessibleTree(this.containerNode, tree); 95 }; 96 97 this.getID = function removeTextData_finalCheck() { 98 return "remove text data of text node inside '" + aID + "'."; 99 }; 100 } 101 102 // ////////////////////////////////////////////////////////////////////////// 103 // Test 104 105 // gA11yEventDumpID = "eventdump"; // debug stuff 106 // gA11yEventDumpToConsole = true; 107 108 var gQueue = null; 109 110 function doTest() { 111 // adds onclick on element, text leaf should inherit its action 112 setOnClickAttr("div"); 113 // remove onclick attribute, text leaf shouldn't have any action 114 removeOnClickAttr("div"); 115 116 // Call rest of event tests. 117 gQueue = new eventQueue(); 118 119 // set onclick attribute making span accessible, it's inserted into tree 120 // and adopts text leaf accessible, text leaf should have an action 121 gQueue.push(new setOnClickNRoleAttrs("span")); 122 123 // text data removal of text node should remove its text accessible 124 gQueue.push(new removeTextData("p", ROLE_PARAGRAPH)); 125 gQueue.push(new removeTextData("pre", ROLE_TEXT_CONTAINER)); 126 127 gQueue.invoke(); // SimpleTest.finish() will be called in the end 128 } 129 130 SimpleTest.waitForExplicitFinish(); 131 addA11yLoadEvent(doTest); 132 </script> 133 </head> 134 <body> 135 136 <a target="_blank" 137 title="Clean up the code of accessible initialization and binding to the tree" 138 href="https://bugzilla.mozilla.org/show_bug.cgi?id=545465"> 139 Mozilla Bug 545465 140 </a> 141 <a target="_blank" 142 title="Make sure accessible tree is correct when rendered text is changed" 143 href="https://bugzilla.mozilla.org/show_bug.cgi?id=625652"> 144 Mozilla Bug 625652 145 </a> 146 <a target="_blank" 147 title="Remove text accesible getting no text inside a preformatted area" 148 href="https://bugzilla.mozilla.org/show_bug.cgi?id=706335"> 149 Mozilla Bug 706335 150 </a> 151 152 <p id="display"></p> 153 <div id="content" style="display: none"></div> 154 <pre id="test"> 155 </pre> 156 157 <div id="container"> 158 <div id="div">div</div> 159 <span id="span">span</span> 160 </div> 161 162 <p id="p">text</p> 163 <pre id="pre">text</pre> 164 165 <div id="eventdump"></div> 166 </body> 167 </html>