1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/treeupdate/test_textleaf.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,193 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 + 1.7 +<head> 1.8 + <title>Test accessible recreation</title> 1.9 + 1.10 + <link rel="stylesheet" type="text/css" 1.11 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.12 + 1.13 + <script type="application/javascript" 1.14 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.15 + 1.16 + <script type="application/javascript" 1.17 + src="../common.js"></script> 1.18 + <script type="application/javascript" 1.19 + src="../role.js"></script> 1.20 + <script type="application/javascript" 1.21 + src="../events.js"></script> 1.22 + 1.23 + <script type="application/javascript"> 1.24 + 1.25 + //////////////////////////////////////////////////////////////////////////// 1.26 + // Invokers 1.27 + 1.28 + function textLeafUpdate(aID, aIsTextLeafLinkable) 1.29 + { 1.30 + this.node = getNode(aID); 1.31 + 1.32 + this.eventSeq = [ 1.33 + new invokerChecker(EVENT_REORDER, this.node.parentNode) 1.34 + ]; 1.35 + 1.36 + this.finalCheck = function textLeafUpdate_finalCheck() 1.37 + { 1.38 + var textLeaf = getAccessible(this.node).firstChild; 1.39 + is(textLeaf.actionCount, (aIsTextLeafLinkable ? 1 : 0), 1.40 + "Wrong action numbers!"); 1.41 + } 1.42 + } 1.43 + 1.44 + function setOnClickAttr(aID) 1.45 + { 1.46 + this.__proto__ = new textLeafUpdate(aID, true); 1.47 + 1.48 + this.invoke = function setOnClickAttr_invoke() 1.49 + { 1.50 + this.node.setAttribute("onclick", "alert(3);"); 1.51 + } 1.52 + 1.53 + this.getID = function setOnClickAttr_getID() 1.54 + { 1.55 + return "make " + prettyName(aID) + " linkable"; 1.56 + } 1.57 + } 1.58 + 1.59 + function removeOnClickAttr(aID) 1.60 + { 1.61 + this.__proto__ = new textLeafUpdate(aID, false); 1.62 + 1.63 + this.invoke = function removeOnClickAttr_invoke() 1.64 + { 1.65 + this.node.removeAttribute("onclick"); 1.66 + } 1.67 + 1.68 + this.getID = function removeOnClickAttr_getID() 1.69 + { 1.70 + return "unmake " + prettyName(aID) + " linkable"; 1.71 + } 1.72 + } 1.73 + 1.74 + function setOnClickNRoleAttrs(aID) 1.75 + { 1.76 + this.__proto__ = new textLeafUpdate(aID, true); 1.77 + 1.78 + this.invoke = function setOnClickAttr_invoke() 1.79 + { 1.80 + this.node.setAttribute("role", "link"); 1.81 + this.node.setAttribute("onclick", "alert(3);"); 1.82 + } 1.83 + 1.84 + this.getID = function setOnClickAttr_getID() 1.85 + { 1.86 + return "make " + prettyName(aID) + " linkable"; 1.87 + } 1.88 + } 1.89 + 1.90 + function removeTextData(aID) 1.91 + { 1.92 + this.containerNode = getNode(aID); 1.93 + this.textNode = this.containerNode.firstChild; 1.94 + 1.95 + this.eventSeq = [ 1.96 + new invokerChecker(EVENT_REORDER, this.containerNode) 1.97 + ]; 1.98 + 1.99 + this.invoke = function removeTextData_invoke() 1.100 + { 1.101 + var tree = { 1.102 + role: ROLE_PARAGRAPH, 1.103 + children: [ 1.104 + { 1.105 + role: ROLE_TEXT_LEAF, 1.106 + name: "text" 1.107 + } 1.108 + ] 1.109 + }; 1.110 + testAccessibleTree(this.containerNode, tree); 1.111 + 1.112 + this.textNode.data = ""; 1.113 + } 1.114 + 1.115 + this.finalCheck = function removeTextData_finalCheck() 1.116 + { 1.117 + var tree = { 1.118 + role: ROLE_PARAGRAPH, 1.119 + children: [] 1.120 + }; 1.121 + testAccessibleTree(this.containerNode, tree); 1.122 + } 1.123 + 1.124 + this.getID = function removeTextData_finalCheck() 1.125 + { 1.126 + return "remove text data of text node inside '" + aID + "'."; 1.127 + } 1.128 + } 1.129 + 1.130 + //////////////////////////////////////////////////////////////////////////// 1.131 + // Test 1.132 + 1.133 + //gA11yEventDumpID = "eventdump"; // debug stuff 1.134 + //gA11yEventDumpToConsole = true; 1.135 + 1.136 + var gQueue = null; 1.137 + 1.138 + function doTest() 1.139 + { 1.140 + gQueue = new eventQueue(); 1.141 + 1.142 + // adds onclick on element, text leaf should inherit its action 1.143 + gQueue.push(new setOnClickAttr("div")); 1.144 + 1.145 + // remove onclick attribute, text leaf shouldn't have any action 1.146 + gQueue.push(new removeOnClickAttr("div")); 1.147 + 1.148 + // set onclick attribute making span accessible, it's inserted into tree 1.149 + // and adopts text leaf accessible, text leaf should have an action 1.150 + gQueue.push(new setOnClickNRoleAttrs("span")); 1.151 + 1.152 + // text data removal of text node should remove its text accessible 1.153 + gQueue.push(new removeTextData("p")); 1.154 + gQueue.push(new removeTextData("pre")); 1.155 + 1.156 + gQueue.invoke(); // SimpleTest.finish() will be called in the end 1.157 + } 1.158 + 1.159 + SimpleTest.waitForExplicitFinish(); 1.160 + addA11yLoadEvent(doTest); 1.161 + </script> 1.162 +</head> 1.163 +<body> 1.164 + 1.165 + <a target="_blank" 1.166 + title="Clean up the code of accessible initialization and binding to the tree" 1.167 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=545465"> 1.168 + Mozilla Bug 545465 1.169 + </a> 1.170 + <a target="_blank" 1.171 + title="Make sure accessible tree is correct when rendered text is changed" 1.172 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=625652"> 1.173 + Mozilla Bug 625652 1.174 + </a> 1.175 + <a target="_blank" 1.176 + title="Remove text accesible getting no text inside a preformatted area" 1.177 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=706335"> 1.178 + Mozilla Bug 706335 1.179 + </a> 1.180 + 1.181 + <p id="display"></p> 1.182 + <div id="content" style="display: none"></div> 1.183 + <pre id="test"> 1.184 + </pre> 1.185 + 1.186 + <div id="container"> 1.187 + <div id="div">div</div> 1.188 + <span id="span">span</span> 1.189 + </div> 1.190 + 1.191 + <p id="p">text</p> 1.192 + <pre id="pre">text</pre> 1.193 + 1.194 + <div id="eventdump"></div> 1.195 +</body> 1.196 +</html>