tests/touch-events-v1/approved/single-touch.html
changeset 177 19c6f3d0eb8a
parent 167 418583839ba5
child 179 7cd6d8c1e3bc
equal deleted inserted replaced
167:418583839ba5 177:19c6f3d0eb8a
    17   <meta name="viewport" content="width=device-width">
    17   <meta name="viewport" content="width=device-width">
    18   <script src="/resources/testharness.js"></script>
    18   <script src="/resources/testharness.js"></script>
    19   <script>
    19   <script>
    20     setup({explicit_done: true});
    20     setup({explicit_done: true});
    21 
    21 
    22     var hasIdentifiedTouch = true;
       
    23     
       
    24     // Check a Touch object's atttributes for existence and correct type
    22     // Check a Touch object's atttributes for existence and correct type
    25     // TA: 1.1.2, 1.1.3
    23     // TA: 1.1.2, 1.1.3
    26     function check_Touch_object (t) {
    24     function check_Touch_object (t) {
    27         test(function() {
    25         test(function() {
    28            assert_equals(Object.prototype.toString.call(t), "[object Touch]", name + " attribute of type TouchList");
    26            assert_equals(Object.prototype.toString.call(t), "[object Touch]", name + " attribute of type TouchList");
    72            assert_equals(Object.prototype.toString.call(tl), "[object TouchList]", name + " attribute of type TouchList");
    70            assert_equals(Object.prototype.toString.call(tl), "[object TouchList]", name + " attribute of type TouchList");
    73         }, "touch list is a TouchList object");
    71         }, "touch list is a TouchList object");
    74         [
    72         [
    75           ["unsigned long", "length"],
    73           ["unsigned long", "length"],
    76           ["function", "item"],
    74           ["function", "item"],
    77           ["function", "identifiedTouch"],
       
    78         ].forEach(function(attr) {
    75         ].forEach(function(attr) {
    79             var type = attr[0];
    76             var type = attr[0];
    80             var name = attr[1];
    77             var name = attr[1];
    81 
    78 
    82             if (name == "identifiedTouch" && !hasIdentifiedTouch)
       
    83               return;
       
    84               
       
    85             // existence check
    79             // existence check
    86             test(function() {
    80             test(function() {
    87                 assert_true(name in tl, name + " attribute in TouchList");
    81                 assert_true(name in tl, name + " attribute in TouchList");
    88             }, "TouchList." + name + " attribute exists");
    82             }, "TouchList." + name + " attribute exists");
    89 
    83 
    94                     assert_equals(typeof tl[name], "number", name + " attribute of type long");
    88                     assert_equals(typeof tl[name], "number", name + " attribute of type long");
    95                 }, "TouchList." + name + " attribute is of type number (unsigned long)");
    89                 }, "TouchList." + name + " attribute is of type number (unsigned long)");
    96                 break;
    90                 break;
    97             case "function":
    91             case "function":
    98                 test(function() {
    92                 test(function() {
    99                     assert_equals(typeof tl[name], "function", name + " attribute of type long");
    93                     assert_equals(typeof tl[name], "function", name + " attribute of type function");
   100                 }, "TouchList." + name + " attribute is of type function");
    94                 }, "TouchList." + name + " attribute is of type function");
   101                 break;
    95                 break;
   102             default:
    96             default:
   103                 break;
    97                 break;
   104             }
    98             }
   196         touchList = document.createTouchList(touch);
   190         touchList = document.createTouchList(touch);
   197         assert_equals(touchList.length, 1, "touchList.length is 1");
   191         assert_equals(touchList.length, 1, "touchList.length is 1");
   198         assert_equals(touchList.item(0), touch, "touchList.item(0) is input touch");
   192         assert_equals(touchList.item(0), touch, "touchList.item(0) is input touch");
   199       }, "document.createTouchList exists and correctly creates a TouchList from a single Touch");
   193       }, "document.createTouchList exists and correctly creates a TouchList from a single Touch");
   200 
   194 
   201       test(function() {
       
   202         // A common failure mode (eg. WebKit bug 96294), don't report multiple errors for it
       
   203         hasIdentifiedTouch = 'identifiedTouch' in touchList;
       
   204         assert_true(hasIdentifiedTouch);
       
   205       }, "TouchList contains an identifiedTouch property");
       
   206 
       
   207       if (touchList)
   195       if (touchList)
   208         check_TouchList_object(touchList);
   196         check_TouchList_object(touchList);
   209 
   197 
   210       test(function() {
   198       test(function() {
   211         touchList = document.createTouchList([touch]);
   199         touchList = document.createTouchList([touch]);
   251         // TA: 1.3.3.9
   239         // TA: 1.3.3.9
   252         test(function() {
   240         test(function() {
   253           assert_equals(tt.target, ev.target, "event target same as targetTouches target.");
   241           assert_equals(tt.target, ev.target, "event target same as targetTouches target.");
   254         }, "touchstart: event target same as targetTouches target");
   242         }, "touchstart: event target same as targetTouches target");
   255 
   243 
   256         // TA: @TBD
       
   257         if (hasIdentifiedTouch) {
       
   258           test(function() {
       
   259             assert_equals(ev.touches.identifiedTouch(touchstart_identifier), t, "touches.identifiedTouch is correct.");
       
   260           }, "touchstart: touches.identifiedTouch same as first touch point id");
       
   261         }
       
   262         
       
   263         // TA: @TBD
   244         // TA: @TBD
   264         test(function() {
   245         test(function() {
   265           assert_true(is_touch_over_element(t, target0), "touch.pageX/pageY is over target0.");
   246           assert_true(is_touch_over_element(t, target0), "touch.pageX/pageY is over target0.");
   266         }, "touchstart: touch pageX/pageY inside of target element");
   247         }, "touchstart: touch pageX/pageY inside of target element");
   267         test(function() { 
   248         test(function() {