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

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: Check if element is nullptr to fix the crash Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLInputElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
29 document.body.offsetTop;
30 }
31
32 function buildPage() {
33 var tbody1 = document.getElementById('table1').children[0];
34 var tbody2 = document.getElementById('table2').children[0];
35 var targetHeight = window.innerHeight;
36 var targetWidth = window.innerWidth;
37 var row = targetHeight / tbody1.offsetHeight;
38 var col = targetWidth / tbody1.offsetWidth * 2;
39
40 var i = 0;
41 var j = 0;
42 // Create some room at the top for scrolling.
43 var tr = document.createElement('tr');
44 for (j = 0; j < col; ++j) {
45 var td = document.createElement('td');
46 td.innerHTML = '<div id="box"></div>';
47 tr.appendChild(td);
48 }
49 tbody1.appendChild(tr);
50 // Take up enough space to overflow the page horizontally and vertically.
51 for (i = 0; i < row; ++i) {
52 var tr = document.createElement('tr');
53 for (j = 0; j < col; ++j) {
54 var td = document.createElement('td');
55 td.innerHTML = '<div id="box"></div>';
56 tr.appendChild(td);
57 }
58 tbody2.appendChild(tr);
59 }
60 }
61
62 forceLayoutUpdate();
63 buildPage();
64 forceLayoutUpdate();
65
66 var slider1 = document.getElementById('slider1');
67 var slider2 = document.getElementById('slider2');
68 var slider3 = document.getElementById('slider3')
69 var container1 = internals.shadowRoot(slider1).children[0];
70 var container2 = internals.shadowRoot(slider2).children[0];
71 var container3 = internals.shadowRoot(slider3).children[0];
72 const touchSourceType = 1;
73
74
75 var isMac = navigator.platform.indexOf('Mac') == 0;
76 if (!isMac) {
77 testSlider1H();
78 } else {
79 testTouchAction();
80 }
81
82 function testSlider1H() {
83 var testSlider1H = async_test('Changes the value of a horizontal slider.');
84 testSlider1H.step(function () {
85 var offsetX = window.pageXOffset;
86 var offsetY = window.pageYOffset;
87 var w = slider1.clientWidth;
88 var h = slider1.clientHeight;
89 var x = slider1.offsetLeft + w / 2 - offsetX;
90 var y = slider1.offsetTop + h / 2 - offsetY;
91 assert_equals(parseInt(slider1.value), 50);
92 // Perform a left drag with a bit up on the thumb.
93 chrome.gpuBenchmarking.smoothDrag(x, y, x - w, y - w / 2,
94 function() {
95 // Should set slider1's value to 0.
96 assert_equals(parseInt(slider1.value), 0);
97 // Should not drag the page vertically.
98 assert_approx_equals(window.pageYOffset, offsetY, 10);
99 // Should not drag the page horizontally.
100 assert_approx_equals(window.pageXOffset, offsetX, 0);
101 testSlider1V();
102 testSlider1H.done();
103 }, touchSourceType);
104 });
105 }
106
107 function testSlider1V() {
108 var testSlider1V = async_test('Drags up on a horizontal slider.');
109 testSlider1V.step(function () {
110 var offsetX = window.pageXOffset;
111 var offsetY = window.pageYOffset;
112 var w = slider1.clientWidth;
113 var h = slider1.clientHeight;
114 var x = slider1.offsetLeft - offsetX;
115 var y = slider1.offsetTop - offsetY;
116 assert_equals(parseInt(slider1.value), 0);
117 // Perform an up drag with a bit right on the thumb.
118 chrome.gpuBenchmarking.smoothDrag(x, y, x + 10, y - 100,
119 function() {
120 // Should not change slider1's value.
121 assert_equals(parseInt(slider1.value), 0);
122 // Should drag the page upwards.
123 assert_approx_equals(window.pageYOffset, offsetY + 85, 10);
124 // Should not drag the page horizontally.
125 assert_approx_equals(window.pageXOffset, offsetX, 0);
126 testSlider2();
127 testSlider1V.done();
128 }, touchSourceType);
129 });
130 }
131
132 function testSlider2() {
133 var testSlider2 = async_test('Drags up on a horizontal slider with touch-actio n=none.');
134 testSlider2.step(function () {
135 var offsetX = window.pageXOffset;
136 var offsetY = window.pageYOffset;
137 var w = slider2.clientWidth;
138 var h = slider2.clientHeight;
139 var x = slider2.offsetLeft + w / 2 - offsetX;
140 var y = slider2.offsetTop + h / 2 - offsetY;
141 assert_equals(parseInt(slider2.value), 50);
142 // Perform an up drag with a bit right on the thumb.
143 chrome.gpuBenchmarking.smoothDrag(x, y, x + 10, y - 100,
144 function() {
145 // Should not change slider2's value.
146 assert_equals(parseInt(slider2.value), 50);
147 // Should not drag the page vertically.
148 assert_approx_equals(window.pageYOffset, offsetY, 10);
149 // Should not drag the page horizontally.
150 assert_approx_equals(window.pageXOffset, offsetX, 10);
151 testSlider3V();
152 testSlider2.done();
153 }, touchSourceType);
154 });
155 }
156
157 function testSlider3V() {
158 var testSlider3V = async_test('Changes value of a vertical slider.');
159 testSlider3V.step(function () {
160 var offsetX = window.pageXOffset;
161 var offsetY = window.pageYOffset;
162 var w = slider3.clientWidth;
163 var h = slider3.clientHeight;
164 var x = slider3.offsetLeft + w / 2 - offsetX;
165 var y = slider3.offsetTop + h / 2 - offsetY;
166 assert_equals(parseInt(slider3.value), 50);
167 // Perform an up drag with a bit left on the thumb.
168 chrome.gpuBenchmarking.smoothDrag(x, y, x - h / 2, y - h,
169 function() {
170 // Should set slider3' value to 100.
171 assert_equals(parseInt(slider3.value), 100);
172 // Should not drag the page vertically.
173 assert_approx_equals(window.pageYOffset, offsetY, 10);
174 // Should not drag the page horizontally.
175 assert_approx_equals(window.pageXOffset, offsetX, 10);
176 testSlider3H();
177 testSlider3V.done();
178 }, touchSourceType);
179 });
180 }
181
182 function testSlider3H() {
183 var testSlider3H = async_test('Drags left on a vertical slider.');
184 testSlider3H.step(function () {
185 var offsetX = window.pageXOffset;
186 var offsetY = window.pageYOffset;
187 var w = slider3.clientWidth;
188 var h = slider3.clientHeight;
189 var x = slider3.offsetLeft - offsetX;
190 var y = slider3.offsetTop - offsetY;
191 assert_equals(parseInt(slider3.value), 100);
192 // Perform a left drag with a bit down on the thumb.
193 chrome.gpuBenchmarking.smoothDrag(x, y, x - 100, slider2.offsetTop + 10,
194 function() {
195 // Should not change slider3' value.
196 assert_equals(parseInt(slider3.value), 100);
197 // Should not drag the page vertically.
198 assert_approx_equals(window.pageYOffset, offsetY, 10);
199 // Should drag the page leftwards.
200 assert_approx_equals(window.pageXOffset, offsetX + 85, 10);
201 testTouchAction();
202 testSlider3H.done();
203 }, touchSourceType);
204 });
205 }
206
207 function testTouchAction() {
208 test(() => {
209 assert_equals(getComputedStyle(container1).touchAction, 'pan-y');
210 assert_equals(getComputedStyle(container2).touchAction, 'pan-y');
211 assert_equals(getComputedStyle(container3).touchAction, 'pan-x');
212 assert_equals(getComputedStyle(slider2).touchAction, 'none');
213
214 slider1.style='-webkit-appearance: slider-vertical;';
215 slider3.style='';
216 forceLayoutUpdate();
217 assert_equals(getComputedStyle(container1).touchAction, 'pan-x');
218 assert_equals(getComputedStyle(container3).touchAction, 'pan-y');
219 }, '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.');
220 }
221 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLInputElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698