Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/touch/touch-action-range-input.html

Issue 2209773002: Remove the blocking touch handlers for the input[type=range] and add touch-action instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better code style Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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: 100px;
7 height: 100px;
8 background: red;
9 padding: 0px;
10 margin: 0px;
11 }
12
13 td {
14 padding: 0px;
15 }
16
17 </style>
18
19 <table id='table1'>
20 <tr><td><div id='box'></div></td></tr>
21 </table>
22 <div><input type='range' id='slider1' min = '0' max = '100' step = '10'></input> </div>
23 <div><input type='range' id='slider2' min = '0' max = '100' step = '10' style='t ouch-action:none;'></div>
24 <div><input type='range' id='slider3' min = '0' max = '100' step = '10' style='- webkit-appearance: slider-vertical;'></div>
25 <table id = 'table2'><tbody /></table>
26
27 <script>
28 function forceLayoutUpdate() {
tkent 2016/08/22 06:00:48 Wrong indentation. 'function' should be started a
29 document.body.offsetTop;
30 }
31
32 function buildPage()
tkent 2016/08/22 06:00:48 Ditto.
33 {
34 var tbody1 = document.getElementById('table1').children[0];
35 var tbody2 = document.getElementById('table2').children[0];
36 var targetHeight = window.innerHeight;
37 var targetWidth = window.innerWidth;
38 var row = targetHeight / tbody1.offsetHeight;
39 var col = targetWidth / tbody1.offsetWidth * 2;
40
41 var i = 0;
42 var j = 0;
43 // Create some room at the top for scrolling.
44 var tr = document.createElement('tr');
45 for (j = 0; j < col; ++j) {
46 var td = document.createElement('td');
47 td.innerHTML = '<div id="box"></div>';
48 tr.appendChild(td);
49 }
50 tbody1.appendChild(tr);
51 // Take up enough space to overflow the page horizontally and vertically.
52 for (i = 0; i < row; ++i) {
53 var tr = document.createElement('tr');
54 for (j = 0; j < col; ++j) {
55 var td = document.createElement('td');
56 td.innerHTML = '<div id="box"></div>';
57 tr.appendChild(td);
58 }
59 tbody2.appendChild(tr);
60 }
61 }
62
63 forceLayoutUpdate();
64 buildPage();
65 forceLayoutUpdate();
66
67 var slider1 = document.getElementById('slider1');
68 var slider2 = document.getElementById('slider2');
69 var slider3 = document.getElementById('slider3')
70 var container1 = internals.shadowRoot(slider1).children[0];
71 var container2 = internals.shadowRoot(slider2).children[0];
72 var container3 = internals.shadowRoot(slider3).children[0];
73 const touchSourceType = 1;
74
75
76 var isMac = navigator.platform.indexOf('Mac') == 0;
77 if (!isMac) {
78 testSlider1H();
79 } else {
80 testTouchAction();
81 }
82
83 function testSlider1H() {
84 var testSlider1H = async_test('Changes the value of a horizontal slider.');
85 testSlider1H.step(function () {
86 var offsetX = window.pageXOffset;
87 var offsetY = window.pageYOffset;
88 var w = slider1.clientWidth;
89 var h = slider1.clientHeight;
90 var x = slider1.offsetLeft + w / 2 - offsetX;
91 var y = slider1.offsetTop + h / 2 - offsetY;
92 assert_equals(parseInt(slider1.value), 50);
93 // Perform a left drag with a bit up on the thumb.
94 chrome.gpuBenchmarking.smoothDrag(x, y, x - w, y - w / 2,
95 function() {
96 // Should set slider1's value to 0.
97 assert_equals(parseInt(slider1.value), 0);
98 // Should not drag the page vertically.
99 assert_approx_equals(window.pageYOffset, offsetY, 10);
100 // Should not drag the page horizontally.
101 assert_approx_equals(window.pageXOffset, offsetX, 0);
102 testSlider1V();
103 testSlider1H.done();
104 }, touchSourceType);
105 });
106 }
107
108 function testSlider1V() {
109 var testSlider1V = async_test('Drags up on a horizontal slider.');
110 testSlider1V.step(function () {
111 var offsetX = window.pageXOffset;
112 var offsetY = window.pageYOffset;
113 var w = slider1.clientWidth;
114 var h = slider1.clientHeight;
115 var x = slider1.offsetLeft - offsetX;
116 var y = slider1.offsetTop - offsetY;
117 assert_equals(parseInt(slider1.value), 0);
118 // Perform an up drag with a bit right on the thumb.
119 chrome.gpuBenchmarking.smoothDrag(x, y, x + 10, y - 100,
120 function() {
121 // Should not change slider1's value.
122 assert_equals(parseInt(slider1.value), 0);
123 // Should drag the page upwards.
124 assert_approx_equals(window.pageYOffset, offsetY + 85, 10);
125 // Should not drag the page horizontally.
126 assert_approx_equals(window.pageXOffset, offsetX, 0);
127 testSlider2();
128 testSlider1V.done();
129 }, touchSourceType);
130 });
131 }
132
133 function testSlider2() {
134 var testSlider2 = async_test('Drags up on a horizontal slider with touch-actio n=none.');
135 testSlider2.step(function () {
136 var offsetX = window.pageXOffset;
137 var offsetY = window.pageYOffset;
138 var w = slider2.clientWidth;
139 var h = slider2.clientHeight;
140 var x = slider2.offsetLeft + w / 2 - offsetX;
141 var y = slider2.offsetTop + h / 2 - offsetY;
142 assert_equals(parseInt(slider2.value), 50);
143 // Perform an up drag with a bit right on the thumb.
144 chrome.gpuBenchmarking.smoothDrag(x, y, x + 10, y - 100,
145 function() {
146 // Should not change slider2's value.
147 assert_equals(parseInt(slider2.value), 50);
148 // Should not drag the page vertically.
149 assert_approx_equals(window.pageYOffset, offsetY, 10);
150 // Should not drag the page horizontally.
151 assert_approx_equals(window.pageXOffset, offsetX, 10);
152 testSlider3V();
153 testSlider2.done();
154 }, touchSourceType);
155 });
156 }
157
158 function testSlider3V() {
159 var testSlider3V = async_test('Changes value of a vertical slider.');
160 testSlider3V.step(function () {
161 var offsetX = window.pageXOffset;
162 var offsetY = window.pageYOffset;
163 var w = slider3.clientWidth;
164 var h = slider3.clientHeight;
165 var x = slider3.offsetLeft + w / 2 - offsetX;
166 var y = slider3.offsetTop + h / 2 - offsetY;
167 assert_equals(parseInt(slider3.value), 50);
168 // Perform an up drag with a bit left on the thumb.
169 chrome.gpuBenchmarking.smoothDrag(x, y, x - h / 2, y - h,
170 function() {
171 // Should set slider3' value to 100.
172 assert_equals(parseInt(slider3.value), 100);
173 // Should not drag the page vertically.
174 assert_approx_equals(window.pageYOffset, offsetY, 10);
175 // Should not drag the page horizontally.
176 assert_approx_equals(window.pageXOffset, offsetX, 10);
177 testSlider3H();
178 testSlider3V.done();
179 }, touchSourceType);
180 });
181 }
182
183 function testSlider3H() {
184 var testSlider3H = async_test('Drags left on a vertical slider.');
185 testSlider3H.step(function () {
186 var offsetX = window.pageXOffset;
187 var offsetY = window.pageYOffset;
188 var w = slider3.clientWidth;
189 var h = slider3.clientHeight;
190 var x = slider3.offsetLeft - offsetX;
191 var y = slider3.offsetTop - offsetY;
192 assert_equals(parseInt(slider3.value), 100);
193 // Perform a left drag with a bit down on the thumb.
194 chrome.gpuBenchmarking.smoothDrag(x, y, x - 100, slider2.offsetTop + 10,
195 function() {
196 // Should not change slider3' value.
197 assert_equals(parseInt(slider3.value), 100);
198 // Should not drag the page vertically.
199 assert_approx_equals(window.pageYOffset, offsetY, 10);
200 // Should drag the page leftwards.
201 assert_approx_equals(window.pageXOffset, offsetX + 85, 10);
202 testTouchAction();
203 testSlider3H.done();
204 }, touchSourceType);
205 });
206 }
207
208 function testTouchAction() {
209 test(() => {
210 assert_equals(getComputedStyle(container1).touchAction, 'pan-y');
211 assert_equals(getComputedStyle(container2).touchAction, 'pan-y');
212 assert_equals(getComputedStyle(container3).touchAction, 'pan-x');
213 assert_equals(getComputedStyle(slider2).touchAction, 'none');
214
215 slider1.style='-webkit-appearance: slider-vertical;';
216 slider3.style='';
217 forceLayoutUpdate();
218 assert_equals(getComputedStyle(container1).touchAction, 'pan-x');
219 assert_equals(getComputedStyle(container3).touchAction, 'pan-y');
220 }, 'Tests that each <input range="type"> has the correct pan-x or pan-y touch- action inside its shadow element: container. This touch-action is under the user -specified touch-action, and will update with the -webkit-appearance.');
221 }
222
tkent 2016/08/22 06:00:48 Unnecessary blank lines.
223
224 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698