pointerevent_touch-action_two-finger_interaction-manual.html (3521B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Pointer Event: touch-action test for two-finger interaction</title> 5 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> 6 <link rel="author" title="Google" href="http://www.google.com "/> 7 <link rel="help" href="https://compat.spec.whatwg.org/#touch-action" /> 8 <meta name="assert" content="Tests that a two-finger pan gesture is cancelled in 'touch-action: pan-x pan-y' but is allowed in 'touch-action: pinch-zoom'"/> 9 <link rel="stylesheet" type="text/css" href="../pointerevent_styles.css"> 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 <script type="text/javascript" src="../pointerevent_support.js"></script> 13 <script type="text/javascript"> 14 var event_log = []; 15 var active_pointers = 0; 16 17 function resetTestState() { 18 event_log = []; 19 active_pointers = 0; 20 } 21 22 function run() { 23 var test_pointer_events = [ 24 setup_pointerevent_test("two-finger pan on 'touch-action: pan-x pan-y'", ["touch"]), 25 setup_pointerevent_test("two-finger pan on 'touch-action: pinch-zoom'", ["touch"]) 26 ]; 27 var expected_events = [ 28 "pointerdown@black, pointerdown@black, pointerup@black, pointerup@black", 29 "pointerdown@grey, pointerdown@grey, pointercancel@grey, pointercancel@grey" 30 ]; 31 var current_test_index = 0; 32 33 on_event(document.getElementById("done"), "click", function() { 34 test_pointer_events[current_test_index].step(function () { 35 assert_equals(active_pointers, 0); 36 assert_equals(event_log.join(", "), expected_events[current_test_index]); 37 }); 38 event_log = []; 39 40 test_pointer_events[current_test_index++].done(); 41 }); 42 43 var targets = [document.getElementById("black"), document.getElementById("grey")]; 44 45 ["pointerdown", "pointerup", "pointercancel"].forEach(function(eventName) { 46 targets.forEach(function(target){ 47 on_event(target, eventName, function (event) { 48 event_log.push(event.type + "@" + event.target.id); 49 50 if (event.type == "pointerdown") { 51 active_pointers++; 52 53 } else { 54 active_pointers--; 55 } 56 }); 57 }); 58 }); 59 } 60 </script> 61 <style> 62 .box { 63 width: 250px; 64 height: 150px; 65 float: left; 66 margin: 10px; 67 } 68 69 #black { 70 touch-action: pan-x pan-y; 71 background-color: black; 72 } 73 74 #grey { 75 touch-action: pinch-zoom; 76 background-color: grey; 77 } 78 79 #done { 80 float: left; 81 padding: 20px; 82 } 83 </style> 84 </head> 85 <body onload="run()"> 86 <h1>Pointer Event: touch-action test for two-finger interaction</h1> 87 <h2 id="pointerTypeDescription"></h2> 88 <h4> 89 Tests that a two-finger pan gesture is cancelled in 'touch-action: pan-x pan-y' but is allowed in 'touch-action: pinch-zoom' 90 </h4> 91 <ol> 92 <li>Touch on Black with two fingers and drag both fingers down at same speed.</li> 93 <li>Tap on Done.</li> 94 <li>Touch on Grey with two fingers and drag both fingers down at same speed.</li> 95 <li>Tap on Done.</li> 96 </ol> 97 <div class="box" id="black"></div> 98 <input type="button" id="done" value="Done" /> 99 <div class="box" id="grey"></div> 100 <div id="log"></div> 101 </body> 102 </html>