1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/events/test_valuechange.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,216 @@ 1.4 +<html> 1.5 + 1.6 +<head> 1.7 + <title>Accessible value change events testing</title> 1.8 + 1.9 + <link rel="stylesheet" type="text/css" 1.10 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.11 + 1.12 + <script type="application/javascript" 1.13 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.16 + 1.17 + <script type="application/javascript" 1.18 + src="../common.js"></script> 1.19 + <script type="application/javascript" 1.20 + src="../events.js"></script> 1.21 + 1.22 + <script type="application/javascript" 1.23 + src="../value.js"></script> 1.24 + 1.25 + <script type="application/javascript"> 1.26 + 1.27 + 1.28 + /** 1.29 + * Do tests. 1.30 + */ 1.31 + var gQueue = null; 1.32 + 1.33 + // Value change invoker 1.34 + function changeARIAValue(aNodeOrID, aValuenow, aValuetext) 1.35 + { 1.36 + this.DOMNode = getNode(aNodeOrID); 1.37 + 1.38 + this.invoke = function changeARIAValue_invoke() { 1.39 + 1.40 + // Note: this should not fire an EVENT_VALUE_CHANGE when aria-valuetext 1.41 + // is not empty 1.42 + if (aValuenow != undefined) 1.43 + this.DOMNode.setAttribute("aria-valuenow", aValuenow); 1.44 + 1.45 + // Note: this should always fire an EVENT_VALUE_CHANGE 1.46 + if (aValuetext != undefined) 1.47 + this.DOMNode.setAttribute("aria-valuetext", aValuetext); 1.48 + } 1.49 + 1.50 + this.check = function changeARIAValue_check() { 1.51 + var acc = getAccessible(aNodeOrID, [nsIAccessibleValue]); 1.52 + if (!acc) 1.53 + return; 1.54 + 1.55 + // Note: always test against valuetext first because the existence of 1.56 + // aria-valuetext takes precedence over aria-valuenow in gecko. 1.57 + is(acc.value, (aValuetext != undefined)? aValuetext : aValuenow, 1.58 + "Wrong value of " + prettyName(aNodeOrID)); 1.59 + } 1.60 + 1.61 + this.getID = function changeARIAValue_getID() { 1.62 + return prettyName(aNodeOrID) + " value changed"; 1.63 + } 1.64 + } 1.65 + 1.66 + function changeValue(aID, aValue) 1.67 + { 1.68 + this.DOMNode = getNode(aID); 1.69 + 1.70 + this.invoke = function changeValue_invoke() 1.71 + { 1.72 + this.DOMNode.value = aValue; 1.73 + } 1.74 + 1.75 + this.check = function changeValue_check() 1.76 + { 1.77 + var acc = getAccessible(this.DOMNode); 1.78 + is(acc.value, aValue, "Wrong value for " + prettyName(aID)); 1.79 + } 1.80 + 1.81 + this.getID = function changeValue_getID() 1.82 + { 1.83 + return prettyName(aID) + " value changed"; 1.84 + } 1.85 + } 1.86 + 1.87 + function changeProgressValue(aID, aValue) 1.88 + { 1.89 + this.DOMNode = getNode(aID); 1.90 + 1.91 + this.invoke = function changeProgressValue_invoke() 1.92 + { 1.93 + this.DOMNode.value = aValue; 1.94 + } 1.95 + 1.96 + this.check = function changeProgressValue_check() 1.97 + { 1.98 + var acc = getAccessible(this.DOMNode); 1.99 + is(acc.value, aValue+"%", "Wrong value for " + prettyName(aID)); 1.100 + } 1.101 + 1.102 + this.getID = function changeProgressValue_getID() 1.103 + { 1.104 + return prettyName(aID) + " value changed"; 1.105 + } 1.106 + } 1.107 + 1.108 + function changeRangeValue(aID) 1.109 + { 1.110 + this.DOMNode = getNode(aID); 1.111 + 1.112 + this.invoke = function changeRangeValue_invoke() 1.113 + { 1.114 + synthesizeMouse(getNode(aID), 5, 5, { }); 1.115 + } 1.116 + 1.117 + this.finalCheck = function changeRangeValue_finalCheck() 1.118 + { 1.119 + var acc = getAccessible(this.DOMNode); 1.120 + is(acc.value, "0", "Wrong value for " + prettyName(aID)); 1.121 + } 1.122 + 1.123 + this.getID = function changeRangeValue_getID() 1.124 + { 1.125 + return prettyName(aID) + " range value changed"; 1.126 + } 1.127 + } 1.128 + 1.129 + function doTests() 1.130 + { 1.131 + // Test initial values 1.132 + testValue("slider_vn", "5", 5, 0, 1000, 0); 1.133 + testValue("slider_vnvt", "plain", 0, 0, 5, 0); 1.134 + testValue("slider_vt", "hi", 0, 0, 3, 0); 1.135 + testValue("scrollbar", "5", 5, 0, 1000, 0); 1.136 + testValue("progress", "22%", 22, 0, 100, 0); 1.137 + testValue("range", "6", 6, 0, 10, 1); 1.138 + 1.139 + // Test value change events 1.140 + gQueue = new eventQueue(nsIAccessibleEvent.EVENT_VALUE_CHANGE); 1.141 + 1.142 + gQueue.push(new changeARIAValue("slider_vn", "6", undefined)); 1.143 + gQueue.push(new changeARIAValue("slider_vt", undefined, "hey!")); 1.144 + gQueue.push(new changeARIAValue("slider_vnvt", "3", "sweet")); 1.145 + gQueue.push(new changeARIAValue("scrollbar", "6", undefined)); 1.146 + 1.147 + gQueue.push(new changeValue("combobox", "hello")); 1.148 + 1.149 + gQueue.push(new changeProgressValue("progress", "50")); 1.150 + gQueue.push(new changeRangeValue("range")); 1.151 + 1.152 + gQueue.invoke(); // Will call SimpleTest.finish(); 1.153 + } 1.154 + 1.155 + SimpleTest.waitForExplicitFinish(); 1.156 + addA11yLoadEvent(doTests); 1.157 + </script> 1.158 +</head> 1.159 + 1.160 +<body> 1.161 + 1.162 + <a target="_blank" 1.163 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=478032" 1.164 + title=" Fire delayed value changed event for aria-valuetext changes"> 1.165 + Mozilla Bug 478032 1.166 + </a> 1.167 + <a target="_blank" 1.168 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=529289" 1.169 + title="We dont expose new aria role 'scrollbar' and property aria-orientation"> 1.170 + Mozilla Bug 529289 1.171 + </a> 1.172 + <a target="_blank" 1.173 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=559764" 1.174 + title="Make HTML5 input@type=range element accessible"> 1.175 + Mozilla Bug 559764 1.176 + </a> 1.177 + <a target="_blank" 1.178 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=703202" 1.179 + title="ARIA comboboxes don't fire value change events"> 1.180 + Mozilla Bug 703202 1.181 + </a> 1.182 + <a target="_blank" 1.183 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=761901" 1.184 + title=" HTML5 progress accessible should fire value change event"> 1.185 + Mozilla Bug 761901 1.186 + </a> 1.187 + 1.188 + 1.189 + <p id="display"></p> 1.190 + <div id="content" style="display: none"></div> 1.191 + <pre id="test"> 1.192 + </pre> 1.193 + <div id="eventdump"></div> 1.194 + 1.195 + <!-- ARIA sliders --> 1.196 + <div id="slider_vn" role="slider" aria-valuenow="5" 1.197 + aria-valuemin="0" aria-valuemax="1000">slider</div> 1.198 + 1.199 + <div id="slider_vt" role="slider" aria-valuetext="hi" 1.200 + aria-valuemin="0" aria-valuemax="3">greeting slider</div> 1.201 + 1.202 + <div id="slider_vnvt" role="slider" aria-valuenow="0" aria-valuetext="plain" 1.203 + aria-valuemin="0" aria-valuemax="5">sweetness slider</div> 1.204 + 1.205 + <!-- ARIA scrollbar --> 1.206 + <div id="scrollbar" role="scrollbar" aria-valuenow="5" 1.207 + aria-valuemin="0" aria-valuemax="1000">slider</div> 1.208 + 1.209 + <!-- ARIA combobox --> 1.210 + <input id="combobox" role="combobox" aria-autocomplete="inline"> 1.211 + 1.212 + <!-- progress bar --> 1.213 + <progress id="progress" value="22" max="100"></progress> 1.214 + 1.215 + <!-- input@type="range" --> 1.216 + <input type="range" id="range" min="0" max="10" value="6"> 1.217 + 1.218 +</body> 1.219 +</html>