OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src='../../../resources/testharness.js'></script> | 2 <script src='../../../resources/testharness.js'></script> |
3 <script src='../../../resources/testharnessreport.js'></script> | 3 <script src='../../../resources/testharnessreport.js'></script> |
4 <style type="text/css"> | 4 <style type="text/css"> |
5 #box { | 5 #box { |
6 width: 600px; | 6 width: 600px; |
7 height: 600px; | 7 height: 600px; |
8 touch-action: none; | 8 touch-action: none; |
9 } | 9 } |
10 </style> | 10 </style> |
11 <div id="box" ></div> | 11 <div id="box" ></div> |
12 | 12 |
13 <script type="text/javascript"> | 13 <script type="text/javascript"> |
14 | 14 |
15 var touchMoveCount = 0; | 15 var touchMoveCount = 0; |
16 var pointerMoveCount = 0; | 16 var pointerMoveCount = 0; |
17 var box = document.getElementById("box"); | 17 var box = document.getElementById("box"); |
18 var targetRect = box.getBoundingClientRect(); | 18 var targetRect = box.getBoundingClientRect(); |
19 var offset = 50; | 19 var offset = 50; |
20 var x = targetRect.left + offset; | 20 var x = targetRect.left + offset; |
21 var y = targetRect.top + offset; | 21 var y = targetRect.top + offset; |
22 | 22 |
| 23 function touchstartHandler(event) { |
| 24 event.preventDefault(); |
| 25 } |
| 26 |
23 function validTouchMoveResult(event) { | 27 function validTouchMoveResult(event) { |
24 touchMoveCount++; | 28 touchMoveCount++; |
25 testTouchMove.step(function () { | 29 testTouchMove.step(function () { |
26 assert_equals(event.target.id, "box"); | 30 assert_equals(event.target.id, "box"); |
27 }); | 31 }); |
28 } | 32 } |
29 | 33 |
30 function validPointerMoveResult(event) { | 34 function validPointerMoveResult(event) { |
31 pointerMoveCount++; | 35 pointerMoveCount++; |
32 testTouchMove.step(function () { | 36 testTouchMove.step(function () { |
33 assert_equals(event.target.id, "box"); | 37 assert_equals(event.target.id, "box"); |
34 assert_equals(event.pointerType, "touch"); | 38 assert_equals(event.pointerType, "touch"); |
35 }); | 39 }); |
36 } | 40 } |
37 | 41 |
38 function callbackValidMoveCount() { | 42 function callbackValidMoveCount() { |
39 testTouchMove.step(function () { | 43 testTouchMove.step(function () { |
40 assert_equals(touchMoveCount, 3); | 44 assert_equals(touchMoveCount, 3); |
41 assert_equals(pointerMoveCount, 5); | 45 assert_equals(pointerMoveCount, 3); |
42 }); | 46 }); |
43 testTouchMove.done(); | 47 testTouchMove.done(); |
44 } | 48 } |
45 | 49 |
46 function testTouchMoveSuppressionInSlopRegion() { | 50 function testTouchMoveSuppressionInSlopRegion() { |
47 if (window.chrome && chrome.gpuBenchmarking) { | 51 if (window.chrome && chrome.gpuBenchmarking) { |
48 var pointerActions = | 52 var pointerActions = |
49 [{source: "touch", | 53 [{source: "touch", |
50 actions: [ | 54 actions: [ |
51 { name: "pointerDown", x: x, y: y }, | 55 { name: "pointerDown", x: x, y: y }, |
52 { name: "pointerMove", x: x, y: y + 10 }, | 56 { name: "pointerMove", x: x, y: y + 1 }, |
53 { name: "pointerMove", x: x, y: y + 20 }, | |
54 { name: "pointerMove", x: x, y: y + 10 }, | |
55 { name: "pointerUp" }, | |
56 { name: "pointerDown", x: x, y: y }, | |
57 { name: "pointerMove", x: x, y: y + 10 }, | 57 { name: "pointerMove", x: x, y: y + 10 }, |
58 { name: "pointerMove", x: x, y: y + 20 }]}]; | 58 { name: "pointerMove", x: x, y: y + 20 }]}]; |
59 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackVal
idMoveCount); | 59 chrome.gpuBenchmarking.pointerActionSequence(pointerActions, callbackVal
idMoveCount); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 var testTouchMove = async_test('Tests that TouchMoves are suppressed if within t
he slop suppression region.'); | 63 var testTouchMove = async_test('Tests that the TouchMoves are not suppressed if
the touch start is consumed.'); |
| 64 box.addEventListener('touchstart', touchstartHandler); |
64 box.addEventListener('touchmove', validTouchMoveResult); | 65 box.addEventListener('touchmove', validTouchMoveResult); |
65 box.addEventListener('pointermove', validPointerMoveResult); | 66 box.addEventListener('pointermove', validPointerMoveResult); |
66 testTouchMoveSuppressionInSlopRegion(); | 67 testTouchMoveSuppressionInSlopRegion(); |
67 | 68 |
68 </script> | 69 </script> |
OLD | NEW |