accessible/tests/mochitest/jsat/test_pointer_relay.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/jsat/test_pointer_relay.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +<html>
     1.5 +
     1.6 +<head>
     1.7 +  <title>AccessFu tests for pointer relay.</title>
     1.8 +
     1.9 +  <link rel="stylesheet" type="text/css"
    1.10 +        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
    1.11 +  <script type="application/javascript"
    1.12 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="application/javascript" src="../common.js"></script>
    1.14 +  <script type="application/javascript" src="../layout.js"></script>
    1.15 +  <script type="application/javascript" src="./jsatcommon.js"></script>
    1.16 +  <script type="application/javascript" src="./dom_helper.js"></script>
    1.17 +  <script type="application/javascript">
    1.18 +
    1.19 +    Components.utils.import(
    1.20 +      "resource://gre/modules/accessibility/PointerAdapter.jsm");
    1.21 +
    1.22 +    var tests = [
    1.23 +      {
    1.24 +        type: 'touchstart', target: [{base: 'button'}],
    1.25 +        expected: {type: 'pointerdown', length: 1}
    1.26 +      },
    1.27 +      {
    1.28 +        type: 'touchmove', target: [{base: 'button'}],
    1.29 +        expected: {type: 'pointermove', length: 1}
    1.30 +      },
    1.31 +      {
    1.32 +        type: 'touchend', target: [{base: 'button'}],
    1.33 +        expected: {type: 'pointerup'}
    1.34 +      },
    1.35 +      {
    1.36 +        type: 'touchstart', target: [{base: 'button'},
    1.37 +          {base: 'button', x: 0.5, y: 0.3}],
    1.38 +          expected: {type: 'pointerdown', length: 2}
    1.39 +      },
    1.40 +      {
    1.41 +        type: 'touchend', target: [{base: 'button'},
    1.42 +          {base: 'button', x: 0.5, y: 0.3}],
    1.43 +          expected: {type: 'pointerup'}
    1.44 +      },
    1.45 +      {
    1.46 +        type: 'touchstart', target: [{base: 'button'},
    1.47 +          {base: 'button', x: 0.5, y: 0.3},
    1.48 +          {base: 'button', x: 0.5, y: -0.3}],
    1.49 +          expected: {type: 'pointerdown', length: 3}
    1.50 +      },
    1.51 +      {
    1.52 +        type: 'touchend', target: [{base: 'button'},
    1.53 +          {base: 'button', x: 0.5, y: 0.3},
    1.54 +          {base: 'button', x: 0.5, y: -0.3}],
    1.55 +          expected: {type: 'pointerup'}
    1.56 +      }
    1.57 +    ];
    1.58 +
    1.59 +    function makeTestFromSpec(test) {
    1.60 +      return function runTest() {
    1.61 +        PointerRelay.start(function onPointerEvent(aDetail) {
    1.62 +          is(aDetail.type, test.expected.type,
    1.63 +            'mozAccessFuPointerEvent is correct.');
    1.64 +          if (test.expected.length) {
    1.65 +            is(aDetail.points.length, test.expected.length,
    1.66 +            'mozAccessFuPointerEvent points length is correct.');
    1.67 +          }
    1.68 +          PointerRelay.stop();
    1.69 +          AccessFuTest.nextTest();
    1.70 +        });
    1.71 +        eventMap[test.type](test.target, test.type);
    1.72 +      };
    1.73 +    }
    1.74 +
    1.75 +    function doTest() {
    1.76 +      tests.forEach(function addTest(test) {
    1.77 +        AccessFuTest.addFunc(makeTestFromSpec(test));
    1.78 +      });
    1.79 +      AccessFuTest.waitForExplicitFinish();
    1.80 +      AccessFuTest.runTests();
    1.81 +    }
    1.82 +
    1.83 +    SimpleTest.waitForExplicitFinish();
    1.84 +    addA11yLoadEvent(doTest);
    1.85 +  </script>
    1.86 +
    1.87 +</head>
    1.88 +<body id="root">
    1.89 +  <a target="_blank"
    1.90 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=976082"
    1.91 +     title="[AccessFu] Provide tests for pointer relay.">
    1.92 +    Mozilla Bug 981015
    1.93 +  </a>
    1.94 +  <div>
    1.95 +    <button id="button">I am a button</button>
    1.96 +  </div>
    1.97 +</body>
    1.98 +</html>

mercurial