accessible/tests/mochitest/treeupdate/test_textleaf.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial