tests/touch-events-v1/submissions/Mozilla/single-touch.html
changeset 161 59c414982391
parent 151 e0189d342a0c
equal deleted inserted replaced
160:e0e3783147f0 161:59c414982391
    33         test_touchstart.done();
    33         test_touchstart.done();
    34         test_mousedown.done(); // If we got here, then the mouse event test is not needed.
    34         test_mousedown.done(); // If we got here, then the mouse event test is not needed.
    35 
    35 
    36         test(function() {
    36         test(function() {
    37           assert_true(ev.target instanceof Element, "target must be an Element.");
    37           assert_true(ev.target instanceof Element, "target must be an Element.");
    38           assert_equals(ev.relatedTarget, null, "relatedTarget must be null for touchstart event.");
    38         }, "touchstart TouchEvent target attribute is correct.");
    39         }, "touchstart TouchEvent target attributes are correct.");
       
    40 
    39 
    41         test(function() {
    40         test(function() {
    42           var attrs = ["altKey", "metaKey", "ctrlKey", "shiftKey"];
    41           var attrs = ["altKey", "metaKey", "ctrlKey", "shiftKey"];
    43           for (var i = 0; i < attrs.length; i++) {
    42           for (var i = 0; i < attrs.length; i++) {
    44             assert_true(attrs[i] in ev);
    43             assert_true(attrs[i] in ev);
    68         }, "Touch identifiers are consistent.");
    67         }, "Touch identifiers are consistent.");
    69 
    68 
    70         test(function() {
    69         test(function() {
    71           assert_equals(ev.touches.identifiedTouch(touchstart_identifier), t, "touches.identifiedTouch is correct.");
    70           assert_equals(ev.touches.identifiedTouch(touchstart_identifier), t, "touches.identifiedTouch is correct.");
    72         }, "identifiedTouch");
    71         }, "identifiedTouch");
    73 
       
    74         test(function() {
       
    75           assert_true(t.rotationAngle >= 0, "rotationAngle must be >= 0.");
       
    76           assert_true(t.rotationAngle < 90, "rotationAngle must be > 90.");
       
    77 
       
    78           assert_true(t.radiusX > 0, "radiusX is positive.");
       
    79           assert_true(t.radiusY > 0, "radiusY is positive.");
       
    80 
       
    81           assert_true(t.force >= 0, "force >= 0.");
       
    82           assert_true(t.force <= 1, "force <= 1.");
       
    83         }, "Touch attribute values are valid");
       
    84 
    72 
    85         test(function() {
    73         test(function() {
    86           var attrs = ["screenX", "screenY", "clientX", "clientY",
    74           var attrs = ["screenX", "screenY", "clientX", "clientY",
    87                        "pageX", "pageY"];
    75                        "pageX", "pageY"];
    88           for (var i = 0; i < attrs.length; i++) {
    76           for (var i = 0; i < attrs.length; i++) {
   120 
   108 
   121       on_event(target1, "touchmove", function onTouchMove(ev) {
   109       on_event(target1, "touchmove", function onTouchMove(ev) {
   122         invalid_touchmove_received = true;
   110         invalid_touchmove_received = true;
   123       });
   111       });
   124 
   112 
   125       on_event(window, "touchend", function onTouchStart(ev) {
   113       on_event(window, "touchend", function onTouchEnd(ev) {
   126         touchend_received = true;
   114         touchend_received = true;
   127 
   115 
   128         test_touchend.step(function() {
   116         test_touchend.step(function() {
   129           assert_equals(ev.target, target0, "touchend is dispatched to the original target");
   117           assert_equals(ev.target, target0, "touchend is dispatched to the original target");
   130           assert_true(touchstart_received, "touchend follows touchstart");
   118           assert_true(touchstart_received, "touchend follows touchstart");
   149         var t = ev.changedTouches[0];
   137         var t = ev.changedTouches[0];
   150 
   138 
   151         test(function() {
   139         test(function() {
   152           assert_equals(t.identifier, touchstart_identifier, "changedTouches identifier matches.");
   140           assert_equals(t.identifier, touchstart_identifier, "changedTouches identifier matches.");
   153         }, "touchend identifier matches.");
   141         }, "touchend identifier matches.");
   154 
       
   155         test(function() {
       
   156           assert_true(t.rotationAngle >= 0, "rotationAngle must be >= 0.");
       
   157           assert_true(t.rotationAngle < 90, "rotationAngle must be > 90.");
       
   158 
       
   159           assert_true(t.radiusX > 0, "radiusX is positive.");
       
   160           assert_true(t.radiusY > 0, "radiusY is positive.");
       
   161 
       
   162           assert_true(t.force >= 0, "force >= 0.");
       
   163           assert_true(t.force <= 1, "force <= 1.");
       
   164         }, "Touch attribute values are valid");
       
   165 
   142 
   166         test(function() {
   143         test(function() {
   167           var attrs = ["screenX", "screenY", "clientX", "clientY",
   144           var attrs = ["screenX", "screenY", "clientX", "clientY",
   168                        "pageX", "pageY"];
   145                        "pageX", "pageY"];
   169           for (var i = 0; i < attrs.length; i++) {
   146           for (var i = 0; i < attrs.length; i++) {