|
1 <html> |
|
2 |
|
3 <head> |
|
4 <title>AccessFu tests for pointer relay.</title> |
|
5 |
|
6 <link rel="stylesheet" type="text/css" |
|
7 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
8 <script type="application/javascript" |
|
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 <script type="application/javascript" src="../common.js"></script> |
|
11 <script type="application/javascript" src="../layout.js"></script> |
|
12 <script type="application/javascript" src="./jsatcommon.js"></script> |
|
13 <script type="application/javascript" src="./dom_helper.js"></script> |
|
14 <script type="application/javascript"> |
|
15 |
|
16 Components.utils.import( |
|
17 "resource://gre/modules/accessibility/PointerAdapter.jsm"); |
|
18 |
|
19 var tests = [ |
|
20 { |
|
21 type: 'touchstart', target: [{base: 'button'}], |
|
22 expected: {type: 'pointerdown', length: 1} |
|
23 }, |
|
24 { |
|
25 type: 'touchmove', target: [{base: 'button'}], |
|
26 expected: {type: 'pointermove', length: 1} |
|
27 }, |
|
28 { |
|
29 type: 'touchend', target: [{base: 'button'}], |
|
30 expected: {type: 'pointerup'} |
|
31 }, |
|
32 { |
|
33 type: 'touchstart', target: [{base: 'button'}, |
|
34 {base: 'button', x: 0.5, y: 0.3}], |
|
35 expected: {type: 'pointerdown', length: 2} |
|
36 }, |
|
37 { |
|
38 type: 'touchend', target: [{base: 'button'}, |
|
39 {base: 'button', x: 0.5, y: 0.3}], |
|
40 expected: {type: 'pointerup'} |
|
41 }, |
|
42 { |
|
43 type: 'touchstart', target: [{base: 'button'}, |
|
44 {base: 'button', x: 0.5, y: 0.3}, |
|
45 {base: 'button', x: 0.5, y: -0.3}], |
|
46 expected: {type: 'pointerdown', length: 3} |
|
47 }, |
|
48 { |
|
49 type: 'touchend', target: [{base: 'button'}, |
|
50 {base: 'button', x: 0.5, y: 0.3}, |
|
51 {base: 'button', x: 0.5, y: -0.3}], |
|
52 expected: {type: 'pointerup'} |
|
53 } |
|
54 ]; |
|
55 |
|
56 function makeTestFromSpec(test) { |
|
57 return function runTest() { |
|
58 PointerRelay.start(function onPointerEvent(aDetail) { |
|
59 is(aDetail.type, test.expected.type, |
|
60 'mozAccessFuPointerEvent is correct.'); |
|
61 if (test.expected.length) { |
|
62 is(aDetail.points.length, test.expected.length, |
|
63 'mozAccessFuPointerEvent points length is correct.'); |
|
64 } |
|
65 PointerRelay.stop(); |
|
66 AccessFuTest.nextTest(); |
|
67 }); |
|
68 eventMap[test.type](test.target, test.type); |
|
69 }; |
|
70 } |
|
71 |
|
72 function doTest() { |
|
73 tests.forEach(function addTest(test) { |
|
74 AccessFuTest.addFunc(makeTestFromSpec(test)); |
|
75 }); |
|
76 AccessFuTest.waitForExplicitFinish(); |
|
77 AccessFuTest.runTests(); |
|
78 } |
|
79 |
|
80 SimpleTest.waitForExplicitFinish(); |
|
81 addA11yLoadEvent(doTest); |
|
82 </script> |
|
83 |
|
84 </head> |
|
85 <body id="root"> |
|
86 <a target="_blank" |
|
87 href="https://bugzilla.mozilla.org/show_bug.cgi?id=976082" |
|
88 title="[AccessFu] Provide tests for pointer relay."> |
|
89 Mozilla Bug 981015 |
|
90 </a> |
|
91 <div> |
|
92 <button id="button">I am a button</button> |
|
93 </div> |
|
94 </body> |
|
95 </html> |