Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src='../../../resources/testharness.js'></script> | |
| 3 <script src='../../../resources/testharnessreport.js'></script> | |
| 4 <style type="text/css"> | |
| 5 #box { | |
| 6 width: 600px; | |
| 7 height: 600px; | |
| 8 touch-action: none; | |
| 9 } | |
| 10 </style> | |
| 11 <div id="box" ></div> | |
| 12 | |
| 13 <script type="text/javascript"> | |
| 14 | |
| 15 var touchMoveCount = 0; | |
| 16 var pointerMoveCount = 0; | |
| 17 var box = document.getElementById('box'); | |
| 18 var targetRect = box.getBoundingClientRect(); | |
| 19 var offset = 50; | |
| 20 var x = targetRect.left + offset; | |
| 21 var y = targetRect.top + offset; | |
| 22 | |
| 23 function validTouchMoveResult(event) { | |
| 24 touchMoveCount++; | |
| 25 testTouchMove.step(function () { | |
| 26 assert_equals(event.target.id, "box"); | |
| 27 }); | |
| 28 } | |
| 29 | |
| 30 function validPointerMoveResult(event) { | |
| 31 pointerMoveCount++; | |
| 32 testTouchMove.step(function () { | |
| 33 assert_equals(event.target.id, "box"); | |
| 34 assert_equals(event.pointerType, "touch"); | |
| 35 }); | |
| 36 } | |
| 37 | |
| 38 function callbackValidMoveCount() { | |
| 39 testTouchMove.step(function () { | |
| 40 assert_equals(touchMoveCount, 3); | |
| 41 assert_equals(pointerMoveCount, 5); | |
| 42 }); | |
| 43 testTouchMove.done(); | |
| 44 } | |
| 45 | |
| 46 function testTouchMoveSuppressionInSlopRegion() { | |
| 47 if (window.chrome && chrome.gpuBenchmarking) { | |
| 48 var pointerActions = [{'source': 'touch'}]; | |
|
tdresser
2017/02/06 21:49:59
This might as well be a single object literal, ins
Rick Byers
2017/02/07 18:51:43
+1
Also you can make it slightly easier to read b
lanwei
2017/02/21 18:10:28
Done.
| |
| 49 var pointerAction = pointerActions[0]; | |
| 50 pointerAction.actions = []; | |
| 51 pointerAction.actions.push( | |
| 52 {'name': 'pointerDown', 'x': x, 'y': y }); | |
| 53 pointerAction.actions.push( | |
| 54 {'name': 'pointerMove', 'x': x, 'y': y + 10 }); | |
| 55 pointerAction.actions.push( | |
| 56 {'name': 'pointerMove', 'x': x, 'y': y + 20 }); | |
| 57 pointerAction.actions.push( | |
| 58 {'name': 'pointerMove', 'x': x, 'y': y + 10 }); | |
| 59 pointerAction.actions.push({'name': 'pointerUp' }); | |
| 60 pointerAction.actions.push( | |
| 61 {'name': 'pointerDown', 'x': x, 'y': y }); | |
| 62 pointerAction.actions.push( | |
| 63 {'name': 'pointerMove', 'x': x, 'y': y + 10 }); | |
| 64 pointerAction.actions.push( | |
| 65 {'name': 'pointerMove', 'x': x, 'y': y + 20 }); | |
| 66 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackVal idMoveCount); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 var testTouchMove = async_test('Move in the slop region.'); | |
| 71 box.addEventListener('touchmove', validTouchMoveResult); | |
| 72 box.addEventListener('pointermove', validPointerMoveResult); | |
| 73 testTouchMoveSuppressionInSlopRegion(); | |
| 74 | |
| 75 </script> | |
| OLD | NEW |