accessible/tests/mochitest/treeupdate/test_recreation.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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 recreateAccessible(aID, aWontBeAccessible)
michael@0 26 {
michael@0 27 this.node = getNode(aID);
michael@0 28 this.accessible =
michael@0 29 isAccessible(this.node) ? getAccessible(this.node) : null;
michael@0 30
michael@0 31 this.eventSeq = [ ];
michael@0 32
michael@0 33 if (this.accessible)
michael@0 34 this.eventSeq.push(new invokerChecker(EVENT_HIDE,
michael@0 35 this.accessible));
michael@0 36
michael@0 37 if (!aWontBeAccessible)
michael@0 38 this.eventSeq.push(new invokerChecker(EVENT_SHOW, getAccessible,
michael@0 39 this.node));
michael@0 40
michael@0 41 this.eventSeq.push(new invokerChecker(EVENT_REORDER,
michael@0 42 getContainerAccessible(this.node)));
michael@0 43
michael@0 44 if (this.accessible) {
michael@0 45 this.unexpectedEventSeq = [
michael@0 46 new invokerChecker(EVENT_SHOW, this.accessible)
michael@0 47 ];
michael@0 48 }
michael@0 49 }
michael@0 50
michael@0 51 function changeAttr(aID, aAttr, aValue)
michael@0 52 {
michael@0 53 this.__proto__ = new recreateAccessible(aID);
michael@0 54
michael@0 55 this.invoke = function changeAttr_invoke()
michael@0 56 {
michael@0 57 this.node.setAttribute(aAttr, aValue);
michael@0 58 }
michael@0 59
michael@0 60 this.getID = function changeAttr_getID()
michael@0 61 {
michael@0 62 return "change " + aAttr + "attribute for " + aID;
michael@0 63 }
michael@0 64 }
michael@0 65
michael@0 66 function removeAttr(aID, aAttr)
michael@0 67 {
michael@0 68 this.__proto__ = new recreateAccessible(aID, true);
michael@0 69
michael@0 70 this.invoke = function remvoeAttr_invoke()
michael@0 71 {
michael@0 72 this.node.removeAttribute(aAttr);
michael@0 73 }
michael@0 74
michael@0 75 this.getID = function remvoeAttr_getID()
michael@0 76 {
michael@0 77 return "remove " + aAttr + "attribute for " + aID;
michael@0 78 }
michael@0 79 }
michael@0 80
michael@0 81 function changeRole(aID, aHasAccessible)
michael@0 82 {
michael@0 83 this.__proto__ = new changeAttr(aID, "role", "button");
michael@0 84 }
michael@0 85
michael@0 86 function removeRole(aID)
michael@0 87 {
michael@0 88 this.__proto__ = new removeAttr(aID, "role");
michael@0 89 }
michael@0 90
michael@0 91 function changeOnclick(aID)
michael@0 92 {
michael@0 93 this.__proto__ = new changeAttr(aID, "onclick", "alert(3);");
michael@0 94 }
michael@0 95
michael@0 96 function changeHref(aID)
michael@0 97 {
michael@0 98 this.__proto__ = new changeAttr(aID, "href", "www");
michael@0 99 }
michael@0 100
michael@0 101 function changeMultiselectable(aID)
michael@0 102 {
michael@0 103 this.__proto__ = new changeAttr(aID, "aria-multiselectable", "true");
michael@0 104 }
michael@0 105
michael@0 106 ////////////////////////////////////////////////////////////////////////////
michael@0 107 // Test
michael@0 108
michael@0 109 //gA11yEventDumpID = "eventdump"; // debug stuff
michael@0 110 //gA11yEventDumpToConsole = true;
michael@0 111
michael@0 112 var gQueue = null;
michael@0 113
michael@0 114 function doTest()
michael@0 115 {
michael@0 116 gQueue = new eventQueue();
michael@0 117
michael@0 118 // make the accessible an inaccessible
michael@0 119 gQueue.push(new changeRole("span"));
michael@0 120
michael@0 121 // make the inaccessible an accessible
michael@0 122 gQueue.push(new removeRole("span"));
michael@0 123
michael@0 124 // recreate an accessible by role change
michael@0 125 gQueue.push(new changeRole("div1"));
michael@0 126
michael@0 127 // recreate an accessible by onclick change
michael@0 128 gQueue.push(new changeOnclick("div2"));
michael@0 129
michael@0 130 // recreate an accessible by href change
michael@0 131 gQueue.push(new changeHref("anchor"));
michael@0 132
michael@0 133 // recreate an accessible by aria-multiselectable change
michael@0 134 gQueue.push(new changeMultiselectable("div3"));
michael@0 135
michael@0 136 gQueue.invoke(); // SimpleTest.finish() will be called in the end
michael@0 137 }
michael@0 138
michael@0 139 SimpleTest.waitForExplicitFinish();
michael@0 140 addA11yLoadEvent(doTest);
michael@0 141 </script>
michael@0 142 </head>
michael@0 143 <body>
michael@0 144
michael@0 145 <a target="_blank"
michael@0 146 title="Rework accessible tree update code"
michael@0 147 href="https://bugzilla.mozilla.org/show_bug.cgi?id=570275">
michael@0 148 Mozilla Bug 570275
michael@0 149 </a>
michael@0 150
michael@0 151 <p id="display"></p>
michael@0 152 <div id="content" style="display: none"></div>
michael@0 153 <pre id="test">
michael@0 154 </pre>
michael@0 155
michael@0 156 <span id="span">span</span>
michael@0 157 <div id="div1">div</div>
michael@0 158 <div id="div2">div</div>
michael@0 159 <a id="anchor">anchor</a>
michael@0 160 <div id="div3" role="listbox">list</div>
michael@0 161
michael@0 162 <div id="eventdump"></div>
michael@0 163 </body>
michael@0 164 </html>

mercurial