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

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: Add parseAttribute back to pass one more test 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 </style>
17
18 <table id="table1">
19 <tr><td><div id="box"></div></td></tr>
20 </table>
21 <div><input type="range" id="slider1" min = "0" max = "100" step = "10"></input> </div>
22 <div><input type="range" id="slider2" min = "0" max = "100" step = "10" style="t ouch-action:none;"></div>
23 <div><input type="range" id="slider3" min = "0" max = "100" step = "10" style="- webkit-appearance: slider-vertical;"></div>
24 <table id = "table2"><tbody /></table>
25
26 <script>
tkent 2016/08/18 05:13:49 Indentation and coding style in this element look
27 function forceLayoutUpdate() {
28 document.body.offsetTop;
29 }
30
31 function buildPage()
32 {
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 var testSlider1 = async_test("Testing slider1, horizontal and touch-action=pan-y ");
75 testSlider1.step(function () {
76 var offsetX = window.pageXOffset;
77 var offsetY = window.pageYOffset;
78 var w = slider1.clientWidth;
79 var h = slider1.clientHeight;
80 var x = slider1.offsetLeft + w / 2 - offsetX;
81 var y = slider1.offsetTop + h / 2 - offsetY;
82 assert_equals(parseInt(slider1.value), 50);
83 // Perform an up-left drag on the thumb.
84 chrome.gpuBenchmarking.smoothDrag(x, y, slider1.offsetLeft - offsetX, y - 100,
85 function() {
86 // Should set slider1's value to 0.
87 assert_equals(parseInt(slider1.value), 0);
88 // Should drag the page upwards.
89 assert_approx_equals(window.pageYOffset, offsetY + 85, 10);
90 // Should not drag the page horizontally.
91 assert_approx_equals(window.pageXOffset, offsetX, 0);
92 testSlider2();
93 testSlider1.done();
94 }, touchSourceType);
95 });
96
97 function testSlider2() {
98 var testSlider2 = async_test("Testing slider2, horizontal and touch-action=none" );
99 testSlider2.step(function () {
100 var offsetX = window.pageXOffset;
101 var offsetY = window.pageYOffset;
102 var w = slider2.clientWidth;
103 var h = slider2.clientHeight;
104 var x = slider2.offsetLeft + w / 2 - offsetX;
105 var y = slider2.offsetTop + h / 2 - offsetY;
106 // Perform an up-left drag on the thumb.
107 chrome.gpuBenchmarking.smoothDrag(x, y, slider2.offsetLeft - offsetX, y - 100,
108 function() {
109 // Should set slider2's value to 0.
110 assert_equals(parseInt(slider2.value), 0);
111 // Should not drag the page vertically.
112 assert_approx_equals(window.pageYOffset, offsetY, 10);
113 // Should not drag the page horizontally.
114 assert_approx_equals(window.pageXOffset, offsetX, 10);
115 testSlider3();
116 testSlider2.done();
117 }, touchSourceType);
118 });
119 }
120
121 function testSlider3() {
122 var testSlider3 = async_test("Testing slider3, vertical and touch-action=pan-x") ;
123 testSlider3.step(function () {
124 var offsetX = window.pageXOffset;
125 var offsetY = window.pageYOffset;
126 var w = slider3.clientWidth;
127 var h = slider3.clientHeight;
128 var x = slider3.offsetLeft + w / 2 - offsetX;
129 var y = slider3.offsetTop + h / 2 - offsetY;
130 // Perform an up-left drag on the thumb.
131 chrome.gpuBenchmarking.smoothDrag(x, y, x - 100, slider2.offsetTop - scrollY,
132 function() {
133 // Should set slider3' value to 100.
134 assert_equals(parseInt(slider3.value), 100);
135 // Should not drag the page vertically.
136 assert_approx_equals(window.pageYOffset, offsetY, 10);
137 // Should drag the page leftwards.
138 assert_approx_equals(window.pageXOffset, offsetX + 85, 10);
139 testTouchAction();
140 testSlider3.done();
141 }, touchSourceType);
142 });
143 }
144
145 function testTouchAction() {
146 test(() => {
147 assert_equals(getComputedStyle(container1).touchAction, 'pan-y');
148 assert_equals(getComputedStyle(container2).touchAction, 'pan-y');
149 assert_equals(getComputedStyle(container3).touchAction, 'pan-x');
150 assert_equals(getComputedStyle(slider2).touchAction, 'none');
151
152 slider1.style="-webkit-appearance: slider-vertical;";
153 slider3.style="";
154 forceLayoutUpdate();
155 assert_equals(getComputedStyle(container1).touchAction, 'pan-x');
156 assert_equals(getComputedStyle(container3).touchAction, 'pan-y');
157 }, "Tests that each <input range='type'> has the correct pan-x or pan-y touch-ac tion inside its shadow element: container. This touch-action is under the user-s pecified touch-action, and will update with the -webkit-appearance.");
158 }
159
160 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698