Debian Codegraph @

dijit/tests/form/robot/Spinner_a11y.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <title>doh.robot Spinner Test</title>
6
7 <style>
8 @import "../../../../util/doh/robot/robot.css";
9 </style>
10
11 <!-- required: dojo.js -->
12 <script type="text/javascript" src="../../../../dojo/dojo.js"></script>
13
14 <script type="text/javascript">
15 dojo.require("dijit.robotx");
16
17 dojo.ready(function(){
18 var spin1;
19 var spin2;
20 var spin3;
21 var spinnerIds = ["integerspinner1", "integerspinner2", "integertextbox3", "realspinner1"];
22 doh.robot.initRobot('../test_Spinner.html');
23
24 // focus handlers for noticing tab/shift+tab navigation
25 var focusCountZ = 0;
26 var blurCountZ = 0;
27 var countFocus = function(){
28 focusCountZ++;
29 };
30 var countBlur = function(){
31 blurCountZ++;
32 };
33 var focusConnect;
34 var blurConnect;
35 var tabFocusSetup = function(inSpinnerId){
36 var spinner = dijit.byId(inSpinnerId);
37 dijit.byId('integerspinner1').focus();
38 focusCountZ = 0;
39 blurCountZ = 0;
40 focusConnect = spinner.connect(spinner.focusNode, "onfocus", countFocus);
41 blurConnect = spinner.connect(spinner.focusNode, "onblur", countBlur);
42 };
43
44 // Setup to test manipulation of spinner via keystrokes.
45 var results; // array holding both expected value and actual value after each keypress
46 var strokeIndex = 0;
47 var noteConnect;
48 function keyStrokeSetup(inSpinnerId){
49 // summary:
50 // Populates results[] with expected values after each keypress.
51 // Also sets up listener to every keyboard event (arrow key etc) on a spinner and
52 // records to record the actual spinner values into results[].
53 var spinner = dijit.byId(inSpinnerId);
54 results = populateExpected(spinner);
55 strokeIndex = 0;
56 noteConnect = spinner.connect(spinner.focusNode, "onkeydown", function(){
57 setTimeout(function(){
58 results[strokeIndex].actual = spinner.get('value');
59 strokeIndex++;
60 }, 5);
61 });
62 }
63
64 // Use spinner api to calculate values for a set of keystrokes.
65 // Returns array of expected values.
66 var populateExpected = function(/*Spinner Widget*/inSpinner){
67 var initVal = inSpinner.get('value');
68 var eVals = [];
69 var newVal;
70 var i;
71
72 // The values expected by pressing HOME, right arrow five times,
73 // PgUp twice, PgDn, up arrow twice, down arrow once,
74 // left arrow once, and END.
75 if(inSpinner.constraints.min){
76 inSpinner.set('value', inSpinner.constraints.min);
77 }
78 newVal = inSpinner.get('value');
79 eVals.push({stroke: "HOME", expected: newVal});
80 // UP 5 times
81 for(i = 0; i < 5; i++){
82 newVal = inSpinner.adjust(newVal, inSpinner.smallDelta);
83 inSpinner.set('value', newVal);
84 newVal = inSpinner.get('value');
85 eVals.push({stroke: "UP", expected: newVal});
86 }
87 // PgUp twice
88 for(i = 0; i < 2; i++){
89 newVal = inSpinner.adjust(newVal, inSpinner.largeDelta);
90 inSpinner.set('value', newVal);
91 newVal = inSpinner.get('value');
92 eVals.push({stroke: "PgUp", expected: newVal});
93 }
94 // PgDn once.
95 newVal = inSpinner.adjust(newVal, -inSpinner.largeDelta);
96 inSpinner.set('value', newVal);
97 newVal = inSpinner.get('value');
98 eVals.push({stroke: "PgDn", expected: newVal});
99 // DOWN
100 newVal = inSpinner.adjust(newVal, -inSpinner.smallDelta);
101 inSpinner.set('value', newVal);
102 newVal = inSpinner.get('value');
103 eVals.push({stroke: "DOWN", expected: newVal});
104 // END
105 if(inSpinner.constraints.max){
106 inSpinner.set('value', inSpinner.constraints.max);
107 }
108 newVal = inSpinner.get('value');
109 eVals.push({stroke: "END", expected: newVal});
110
111 // reset <inSpinner> back to its initial value, and return
112 inSpinner.set('value', initVal);
113 return eVals;
114 };
115
116 // execute some test as soon as the widget gets focus
117 var focusThenRun = function(widget, fcn){
118 if(!widget.focused){
119 var handler = widget.connect(widget, '_onFocus', function(){
120 widget.disconnect(handler);
121 setTimeout(fcn, 1);
122 });
123 widget.focus();
124 }else{
125 fcn();
126 }
127 };
128
129 // common robot TAB-focus test function.
130 var a11yTabFocus = function(inSpinnerId){
131 var d = new doh.Deferred();
132 var spinner = dijit.byId(inSpinnerId);
133 focusThenRun(spinner, function(){
134 var handler = spinner.connect(spinner, '_onBlur', function(){
135 spinner.disconnect(handler);
136 setTimeout(function(){
137 handler = spinner.connect(spinner, '_onFocus', function(){
138 spinner.disconnect(handler);
139 setTimeout(function(){
140 handler = spinner.connect(spinner, '_onBlur', function(){
141 spinner.disconnect(handler);
142 setTimeout(function(){
143 handler = spinner.connect(spinner, '_onFocus', function(){
144 spinner.disconnect(handler);
145 setTimeout(d.getTestCallback(function(){
146 spinner.disconnect(focusConnect);
147 spinner.disconnect(blurConnect);
148 doh.is(3, focusCountZ, "# of times focused (" + spinner.id + ")");
149 doh.is(2, blurCountZ, "# of times lost focus (" + spinner.id + ")");
150 }), 1);
151 });
152 doh.robot.keyPress(dojo.keys.TAB, 1, {shift:true}); // refocus
153 }, 1);
154 });
155 doh.robot.keyPress(dojo.keys.TAB, 1); // reblur
156 }, 1);
157 });
158 doh.robot.keyPress(dojo.keys.TAB, 1); // refocus
159 }, 1);
160 });
161 doh.robot.keyPress(dojo.keys.TAB, 1, {shift:true}); // blur
162 });
163 return d;
164 };
165
166 // common robot keystroke test function.
167 var a11yKeystrokeTest = function(inSpinnerId){
168 var d = new doh.Deferred();
169 var spinner = dijit.byId(inSpinnerId);
170 var initVal = spinner.get('value');
171
172 focusThenRun(spinner, function(){
173 doh.robot.keyPress(dojo.keys.HOME, 1);
174 doh.robot.keyPress(dojo.keys.UP_ARROW, 200);
175 doh.robot.keyPress(dojo.keys.UP_ARROW, 200);
176 doh.robot.keyPress(dojo.keys.UP_ARROW, 200);
177 doh.robot.keyPress(dojo.keys.UP_ARROW, 200);
178 doh.robot.keyPress(dojo.keys.UP_ARROW, 200);
179 doh.robot.keyPress(dojo.keys.PAGE_UP, 200);
180 doh.robot.keyPress(dojo.keys.PAGE_UP, 200);
181 doh.robot.keyPress(dojo.keys.PAGE_DOWN, 200);
182 doh.robot.keyPress(dojo.keys.DOWN_ARROW, 200);
183 doh.robot.keyPress(dojo.keys.END, 200);
184 var testPresses = function(){
185 spinner.disconnect(noteConnect);
186 spinner.set('value', initVal);
187 for(var i = 0; i < results.length; i++){
188 var aResult = results[i];
189 if(!(isNaN(aResult.expected) && isNaN(aResult.actual))){
190 doh.is(aResult.expected, aResult.actual, aResult.stroke);
191 }
192 }
193 };
194 doh.robot.sequence(d.getTestCallback(testPresses), 1000, 1000);
195 });
196 return d;
197 };
198
199 doh.register("setUp",{
200 name: "setUp",
201 timeout: 5000,
202 setUp:function(){
203 spin1 = dijit.byId('integerspinner1');
204 spin2 = dijit.byId('integerspinner2');
205 spin3 = dijit.byId('realspinner1');
206 spin4 = dijit.byId('spinnerMinOnly');
207 safeClick = dojo.byId('form1');
208 },
209 runTest: function(){
210 // assert onChange not fired
211 doh.is("not fired yet!", dojo.byId('oc1').value, "onChange should not have fired");
212
213 // make sure initial values are what we expect
214 doh.is(1, spin1.smallDelta);
215 doh.is(900, spin1.get('value'), "integerspinner1");
216 doh.is(1000, spin2.get('value'), "integerspinner2");
217 doh.is(1.0, spin3.get('value'), "realspinner1");
218 doh.is(1.0, spin4.get('value'), "spinnerMinOnly");
219 }
220 });
221
222 doh.register("dojo.query() input by name",
223 dojo.map(spinnerIds, function(id){
224 return {
225 name: id,
226 spinner: id,
227 spinnerName: id,
228 runTest:function(){
229 this.spinner = dijit.byId(this.spinner);
230 var queried=dojo.query("input[name="+this.spinnerName+"]");
231 doh.is(1, queried.length,"Expected 1 spinner with name "+this.spinnerName+", found "+queried.length);
232 doh.is(this.spinner.valueNode, queried[0],"Spinner's valueNode did not match the one found by dojo.query.");
233 }
234 };
235 })
236 );
237
238 doh.register("a11y", [
239 {
240 name: "spinner2_typematic",
241 timeout: 9000,
242 runTest: function(){
243 // test typematic
244 var d=new doh.Deferred();
245 spin2.set('value', 900);
246 focusThenRun(spin2, function(){
247 doh.robot.keyDown(dojo.keys.DOWN_ARROW, 1);
248 doh.robot.keyUp(dojo.keys.DOWN_ARROW, 5000);
249 doh.robot.sequence(d.getTestCallback(function(){
250 var v = spin2.get('value');
251 doh.t(v <= 800, 'Error in typematic test. Expected <=800, got '+v);
252 }), 1000);
253 });
254 return d;
255 }
256 },
257
258 {
259 name: "spinner2_max",
260 timeout: 5000,
261 runTest: function(){
262 // test max with arrow key
263 var d=new doh.Deferred();
264 spin2.set('value', 1549);
265 focusThenRun(spin2, function(){
266 // press once: should move up
267 doh.robot.keyPress(dojo.keys.UP_ARROW, 1);
268 doh.robot.sequence(d.getTestErrback(function(){
269 doh.is(1550, spin2.get('value'), "value 1: " + spin2.get('value'));
270 doh.is("1550", spin2.focusNode.value, "displayed value 1: " + spin2.focusNode.value);
271 doh.t(spin2.isValid(), "invalid 1");
272 // press again: shouldn't move
273 doh.robot.keyPress(dojo.keys.UP_ARROW, 500);
274 doh.robot.sequence(d.getTestCallback(function(){
275 doh.is(1550, spin2.get('value'), "value 2: " + spin2.get('value'));
276 doh.is("1550", spin2.focusNode.value, "displayed value 2: " + spin2.focusNode.value);
277 doh.t(spin2.isValid(), "invalid 2");
278 }), 500);
279 }), 500);
280 });
281 return d;
282 }
283 },
284
285 {
286 name: "spinner2_min",
287 timeout: 5000,
288 runTest: function(){
289 // test min with arrow key
290 var d=new doh.Deferred();
291 spin2.set('value', 10);
292 focusThenRun(spin2, function(){
293 // press once: should move up
294 doh.robot.keyPress(dojo.keys.DOWN_ARROW, 1);
295 doh.robot.sequence(d.getTestErrback(function(){
296 doh.is(9, spin2.get('value'), "value 1: " + spin2.get('value'));
297 doh.is("9", spin2.focusNode.value, "displayed value 1: " + spin2.focusNode.value);
298 doh.t(spin2.isValid(), "invalid 1");
299 // press again: shouldn't move
300 doh.robot.keyPress(dojo.keys.DOWN_ARROW, 500);
301 doh.robot.sequence(d.getTestCallback(function(){
302 doh.is(9, spin2.get('value'), "value 2: " + spin2.get('value'));
303 doh.is("9", spin2.focusNode.value, "displayed value 2: " + spin2.focusNode.value);
304 doh.t(spin2.isValid(), "invalid 2");
305 }), 500);
306 }), 500);
307 });
308 return d;
309 }
310 },
311
312 {
313 name: "spinner2_invalid",
314 timeout: 3000,
315 runTest: function(){
316 // assert invalid works
317 var d=new doh.Deferred();
318 spin2.set("value", NaN);
319 focusThenRun(spin2, function(){
320 doh.robot.typeKeys("0.5", 1, 600);
321 doh.robot.sequence(d.getTestCallback(function(){
322 doh.f(spin2.isValid(), "valid");
323 }), 500);
324 });
325 return d;
326 }
327 }
328 ]);
329
330 // Test ARIA role. Since role attribute is set in template,
331 // checking one should be sufficient.
332 doh.register("a11yAriaRole",
333 function spinnerRole(){
334 var spinner = dijit.byId("integerspinner1");
335 doh.isNot(spinner, null, "can't find 'integerspinner1'");
336 doh.is(dojo.attr(spinner.focusNode, "role"), "spinbutton", spinner.id + ": aria role (spinbutton)");
337 }
338 );
339
340 // Check ARIA min/max values.
341 // - both min and max.
342 // - min, no max.
343 // - max, no min.
344 // - neither.
345 doh.register("a11yMinMaxValues",
346 [
347 function minAndMax(){
348 var spinner = dijit.byId("integerspinner2");
349 doh.isNot(spinner, null, "can't find 'integerspinner2'");
350 doh.is(spinner.focusNode.getAttribute("aria-valuemin"), spinner.constraints.min, spinner.id + ": aria-valuemin");
351 doh.is(spinner.focusNode.getAttribute("aria-valuemax"), spinner.constraints.max, spinner.id + ": aria-valuemax");
352 },
353 function minOnly(){
354 var spinner = dijit.byId("spinnerMinOnly");
355 doh.isNot(spinner, null, "can't find 'spinnerMinOnly'");
356 doh.is(spinner.focusNode.getAttribute("aria-valuemin"), spinner.constraints.min, spinner.id + ": aria-valuemin");
357 if(spinner.constraints.max){
358 doh.is(spinner.focusNode.getAttribute("aria-valuemax"), spinner.constraints.max, spinner.id + ": aria-valuemax");
359 }else{
360 if(spinner.focusNode.hasAttribute){ // not available on IE6/7
361 doh.f(spinner.focusNode.hasAttribute("aria-valuemax"), spinner.id + ": aria-valuemax");
362 }
363 }
364 },
365 function maxOnly(){
366 var spinner = dijit.byId("integertextbox3");
367 doh.isNot(spinner, null, "can't find 'integertextbox3'");
368 doh.is(spinner.focusNode.getAttribute("aria-valuemax"), spinner.constraints.max, spinner.id + ": aria-valuemax");
369 if(spinner.constraints.min){
370 doh.is(spinner.focusNode.getAttribute("aria-valuemin"), spinner.constraints.min, spinner.id + ": aria-valuemin");
371 }else{
372 if(spinner.focusNode.hasAttribute){ // not available on IE6/7
373 doh.f(spinner.focusNode.hasAttribute("aria-valuemin"), spinner.id + ": aria-valuemin");
374 }
375 }
376 },
377 function neitherMinNorMax(){
378 var spinner = dijit.byId("integertextbox3");
379 doh.isNot(spinner, null, "can't find 'integertextbox3'");
380 if(spinner.constraints.min){
381 doh.is(spinner.focusNode.getAttribute("aria-valuemin"), spinner.constraints.min, spinner.id + ": aria-valuemin");
382 }else{
383 if(spinner.focusNode.hasAttribute){ // not available on IE6/7
384 doh.f(spinner.focusNode.hasAttribute("aria-valuemin"), spinner.id + ": aria-valuemin");
385 }
386 }
387 if(spinner.constraints.max){
388 doh.is(spinner.focusNode.getAttribute("aria-valuemax"), spinner.constraints.max, spinner.id + ": aria-valuemax");
389 }else{
390 if(spinner.focusNode.hasAttribute){ // not available on IE6/7
391 doh.f(spinner.focusNode.hasAttribute("aria-valuemax"), spinner.id + ": aria-valuemax");
392 }
393 }
394 }
395 ]
396 );
397
398 // Loop to test each spinner for aria-valuenow
399 // TODO:
400 // Is testing one spinner sufficient?
401 //
402 // test aria valuemin, valuemax, valuenow.
403 doh.register("a11yValueNow",
404 dojo.map(spinnerIds, function(id){
405 return {
406 name: id+"_value",
407 spinnerId: id,
408 runTest:function(){
409 var spinner = dijit.byId(this.spinnerId);
410 spinner.set('value', 100);
411 var ariaVal = spinner.focusNode.getAttribute("aria-valuenow");
412 doh.is(100, ariaVal, spinner.id + ": aria-valuenow");
413 }
414 };
415 })
416 );
417
418
419 // test "null" aria-valuenow
420 /* Remove null aria-valuenow test until #7866 is resolved
421 doh.register("a11yNullValuenow", {
422 name:spinnerIds[i]+"_nullValueNow",
423 spinnerId:spinnerIds[i],
424 runTest:function(){
425 var spinner = dijit.byId(this.spinnerId);
426 var initVal = spinner.get('value');
427 spinner.set('value', null);
428 var spinnerVal = spinner.get('value');
429 var nowVal = spinner.focusNode.getAttribute("aria-valuenow");
430 var invalid = spinner.focusNode.getAttribute("aria-invalid");
431 spinner.set('value', initVal);
432 doh.t(invalid, spinner.id + ": aria-invalid");
433 if(!(isNaN(spinnerVal) && isNaN(nowVal))){
434 doh.is(spinnerVal, nowVal, spinner.id + ": null aria-valuenow");
435 }
436 }
437 });
438 */
439
440 // a11y tab focus tests (robot)
441 doh.register("a11yTabFocus",
442 [
443 // don't test integerspinner1 since shift-tab from there goes to address bar and the robot doesn't like that at all
444 {
445 name:"integertextbox3TabFocus",
446 timeout:3000,
447 setUp:function(){
448 tabFocusSetup("integertextbox3");
449 },
450 runTest:function(){
451 return a11yTabFocus("integertextbox3");
452 }
453 },
454 { // test integerspinner2 second since the previous test group already had it focused
455 name:"integerspinner2TabFocus",
456 timeout:3000,
457 setUp:function(){
458 tabFocusSetup("integerspinner2");
459 },
460 runTest:function(){
461 return a11yTabFocus("integerspinner2");
462 }
463 },
464 {
465 name:"realspinner1TabFocus",
466 timeout:3000,
467 setUp:function(){
468 tabFocusSetup("realspinner1");
469 },
470 runTest:function(){
471 return a11yTabFocus("realspinner1");
472 }
473 }
474 ]);
475
476 // a11y keystroke tests
477 doh.register("a11yKeystrokes",
478 [
479 {
480 name:"integerspinner1Keystrokes",
481 timeout:9000,
482 setUp:function(){
483 keyStrokeSetup("integerspinner1");
484 },
485 runTest:function(){
486 return a11yKeystrokeTest("integerspinner1");
487 }
488 },
489 {
490 name:"integerspinner2Keystrokes",
491 timeout:9000,
492 setUp:function(){
493 keyStrokeSetup("integerspinner2");
494 },
495 runTest:function(){
496 return a11yKeystrokeTest("integerspinner2");
497 }
498 },
499 {
500 name:"integertextbox3Keystrokes",
501 timeout:9000,
502 setUp:function(){
503 keyStrokeSetup("integertextbox3");
504 },
505 runTest:function(){
506 return a11yKeystrokeTest("integertextbox3");
507 }
508 },
509 {
510 name:"realspinner1Keystrokes",
511 timeout:9000,
512 setUp:function(){
513 keyStrokeSetup("realspinner1");
514 },
515 runTest:function(){
516 return a11yKeystrokeTest("realspinner1");
517 }
518 }
519 ]);
520
521 // exponential value keystroke tests
522 doh.register("exponential",
523 [
524 {
525 name: "spinnerMinOnly large exp",
526 timeout: 5000,
527 runTest: function(){
528 var d=new doh.Deferred();
529 spin4.set("value", NaN);
530 focusThenRun(spin4, function(){
531 var handler = spin4.connect(spin4, '_onBlur',
532 function(){
533 spin4.disconnect(handler);
534 setTimeout(d.getTestCallback(function(){
535 doh.f(spin4.isValid(false), "large exponential is invalid");
536 doh.f(spin4.isInRange(false), "large exponential is out of range");
537 doh.is(spin4.getErrorMessage(true), spin4.rangeMessage, "large exponential showing out of range message");
538 doh.is("5e+98", spin4.get('displayedValue'), "large exponential reformatted to standard form");
539 }), 150);
540 });
541 doh.robot.typeKeys("0.5e99", 1, 1200);
542 doh.robot.keyPress(dojo.keys.TAB, 500, {shift:true});
543 });
544 return d;
545 }
546 },
547 {
548 name: "spinnerMinOnly adjust small exp",
549 timeout: 5000,
550 runTest: function(){
551 var d=new doh.Deferred();
552 spin4.set("value", NaN);
553 focusThenRun(spin4, function(){
554 var handler = spin4.connect(spin4, '_onBlur',
555 function(){
556 spin4.disconnect(handler);
557 setTimeout(d.getTestCallback(function(){
558 doh.t(spin4.isValid(false), "small exponential is valid");
559 doh.t(spin4.isInRange(false), "small exponential is in range");
560 doh.is(500000000.1, spin4.get('value'), "small exponential converted to whole number");
561 doh.is("500,000,000.1", spin4.get('displayedValue'), "small exponential converted to whole number with formatting");
562 }), 150);
563 });
564 doh.robot.typeKeys("0.5e9", 1, 1000);
565 doh.robot.keyPress(dojo.keys.UP_ARROW, 500);
566 doh.robot.keyPress(dojo.keys.TAB, 500, {shift:true});
567 });
568 return d;
569 }
570 },
571 {
572 name: "spinnerMinOnly adjust max exp",
573 timeout: 9000,
574 runTest: function(){
575 var d=new doh.Deferred();
576 spin4.set("value", NaN);
577 focusThenRun(spin4, function(){
578 var handler = spin4.connect(spin4, '_onBlur',
579 function(){
580 spin4.disconnect(handler);
581 setTimeout(d.getTestCallback(function(){
582 doh.t(spin4.isValid(false), "large exponential converted to max is valid");
583 doh.t(spin4.isInRange(false), "max value is in range");
584 doh.is(89999999999999.9, spin4.get('value'), "max value (-.1)");
585 doh.is("89,999,999,999,999.9", spin4.get('displayedValue'), "max value (-.1) with formatting");
586 }), 150);
587 });
588 doh.robot.typeKeys("0.5e99", 1, 1200);
589 doh.robot.keyPress(dojo.keys.DOWN_ARROW, 500); // convert to max
590 doh.robot.keyPress(dojo.keys.DOWN_ARROW, 500);
591 doh.robot.keyPress(dojo.keys.TAB, 500, {shift:true});
592 });
593 return d;
594 }
595 }
596 ]);
597
598 // invalid editing keystroke tests
599 doh.register("invalid editing",
600 [
601 {
602 name: "HOME key, out of range",
603 timeout: 5000,
604 runTest: function(){
605 var d=new doh.Deferred();
606 spin4.set("value", NaN);
607 focusThenRun(spin4, function(){
608 doh.robot.typeKeys("0.5e99", 1, 1200);
609 doh.robot.keyPress(dojo.keys.HOME, 500);
610 doh.robot.sequence(d.getTestCallback(function(){
611 doh.t(spin4.isValid(true), "HOME changed large exponential to valid min, value is instead: "+spin4.focusNode.value);
612 doh.t(spin4.isInRange(true), "HOME changed large exponential to in range");
613 doh.is(-10.9, spin4.get('value'), "HOME changed large exponential to min value");
614 doh.is("-10.9", spin4.get('displayedValue'), "HOME changed large exponential to min display");
615 }), 500);
616 });
617 return d;
618 }
619 },
620 {
621 name: "HOME key, invalid",
622 timeout: 9000,
623 runTest: function(){
624 var d=new doh.Deferred();
625 spin4.set("value", NaN);
626 focusThenRun(spin4, function(){
627 doh.robot.typeKeys(".5e9a", 1, 1000);
628 doh.robot.keyPress(dojo.keys.HOME, 500);
629 if(dojo.isMac){
630 doh.robot.keyPress(dojo.keys.LEFT_ARROW, 500, {meta:true});
631 }
632 doh.robot.typeKeys("1", 500, 200);
633 doh.robot.keyPress(dojo.keys.END, 500);
634 if(dojo.isMac){
635 doh.robot.keyPress(dojo.keys.RIGHT_ARROW, 500, {meta:true});
636 }
637 doh.robot.keyPress(dojo.keys.BACKSPACE, 500);
638 doh.robot.sequence(d.getTestCallback(function(){
639 doh.t(spin4.isValid(true), "edited exponential is now valid");
640 doh.is(1.5e+9, spin4.get('value'), "edited exponential");
641 }), 500);
642 });
643 return d;
644 }
645 },
646 {
647 name: "out-of-range formatting",
648 timeout: 5000,
649 runTest: function(){
650 var d=new doh.Deferred();
651 spin3.set("value", NaN);
652 focusThenRun(spin3, function(){
653 var handler = spin3.connect(spin3, '_onBlur',
654 function(){
655 spin3.disconnect(handler);
656 setTimeout(d.getTestCallback(function(){
657 doh.f(spin3.isValid(), "out-of-range is invalid");
658 doh.is('156.0', spin3.get('displayedValue'), "fraction not removed from out-of-range");
659 doh.is(156, spin3.get('value'), "out-of-range number returns number");
660 }), 150);
661 });
662 doh.robot.typeKeys("156.0", 1, 1000);
663 doh.robot.keyPress(dojo.keys.TAB, 500);
664 });
665 return d;
666 }
667 }
668 ]);
669
670 doh.register("rounding",
671 [
672 {
673 name: "simple",
674 timeout: 5000,
675 runTest: function(){
676 var d=new doh.Deferred();
677 var spinner = dijit.byId("integertextbox3");
678 spinner.set('value', '');
679 focusThenRun(spinner, function(){
680 var handler = spinner.connect(spinner, '_onBlur',
681 function(){
682 spinner.disconnect(handler);
683 setTimeout(d.getTestCallback(function(){
684 doh.t(spinner.isValid(false), "no error when rounding");
685 doh.is(1.234, spinner.get('value'), "value is rounded");
686 doh.is("1.234", spinner.get('displayedValue'), "rounded value correctly displayed");
687 }), 150);
688 });
689 doh.robot.typeKeys("1.2339", 1, 1200);
690 doh.robot.keyPress(dojo.keys.TAB, 500);
691 });
692 return d;
693 }
694 }
695 ]);
696
697 doh.run();
698 });
699 </script>
700 </head>
701 </html>