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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-event-test.html

Issue 1815093002: Canvas2d: fix event.region being null on mouseleave/out events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/HTMLCanvasElement.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>HitRegion Event Test</title> 2 <title>HitRegion Event Test</title>
3 <script src="../../resources/testharness.js"></script> 3 <script src="../../resources/testharness.js"></script>
4 <script src="../../resources/testharnessreport.js"></script> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="./resources/test-helpers.js"></script> 5 <script src="./resources/test-helpers.js"></script>
6 <canvas width="400" height="400"> 6 <canvas width="400" height="400">
7 <button id="button"></button> 7 <button id="button"></button>
8 <button id="button2"></button> 8 <button id="button2"></button>
9 </canvas> 9 </canvas>
10 <style> 10 <style>
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 context.fill(); 102 context.fill();
103 context.addHitRegion({ id: 'button', control: button }); 103 context.addHitRegion({ id: 'button', control: button });
104 104
105 var expected = [ 105 var expected = [
106 { type: 'mouseover', target: button, region: 'button' }, 106 { type: 'mouseover', target: button, region: 'button' },
107 { type: 'mouseenter', target: button, region: 'button' }, 107 { type: 'mouseenter', target: button, region: 'button' },
108 { type: 'mousemove', target: button, region: 'button' }, 108 { type: 'mousemove', target: button, region: 'button' },
109 { type: 'mousemove', target: button, region: 'button' }, 109 { type: 'mousemove', target: button, region: 'button' },
110 { type: 'mousedown', target: button, region: 'button' }, 110 { type: 'mousedown', target: button, region: 'button' },
111 { type: 'mouseup', target: button, region: 'button' }, 111 { type: 'mouseup', target: button, region: 'button' },
112 // TODO(zino): The expected value of region should be "button" instead of 112 { type: 'mouseout', target: button, region: 'button' },
113 // null in case of mouseout/mouseleave. Please see http://crbug.com/592992. 113 { type: 'mouseleave', target: button, region: 'button' },
114 { type: 'mouseout', target: button, region: null },
115 { type: 'mouseleave', target: button, region: null },
116 { type: 'touchstart', target: button, region: 'button' }, 114 { type: 'touchstart', target: button, region: 'button' },
117 { type: 'touchend', target: button, region: 'button' }, 115 { type: 'touchend', target: button, region: 'button' },
118 ]; 116 ];
119 var actual = []; 117 var actual = [];
120 118
121 button.addEventListener('mouseover', e => actual.push(e)); 119 button.addEventListener('mouseover', e => actual.push(e));
122 button.addEventListener('mouseenter', e => actual.push(e)); 120 button.addEventListener('mouseenter', e => actual.push(e));
123 button.addEventListener('mousemove', e => actual.push(e)); 121 button.addEventListener('mousemove', e => actual.push(e));
124 button.addEventListener('mousedown', e => actual.push(e)); 122 button.addEventListener('mousedown', e => actual.push(e));
125 button.addEventListener('mouseup', e => actual.push(e)); 123 button.addEventListener('mouseup', e => actual.push(e));
(...skipping 14 matching lines...) Expand all
140 eventSender.touchStart(); 138 eventSender.touchStart();
141 eventSender.releaseTouchPoint(0); 139 eventSender.releaseTouchPoint(0);
142 eventSender.touchEnd(); 140 eventSender.touchEnd();
143 } 141 }
144 142
145 assert_event_array_equivalent(actual, expected); 143 assert_event_array_equivalent(actual, expected);
146 this.done(); 144 this.done();
147 }, 'Rerouting mouse/touch event test'); 145 }, 'Rerouting mouse/touch event test');
148 146
149 async_test(function() { 147 async_test(function() {
148 context.rect(1, 1, 50, 50);
149 context.fill();
150 context.addHitRegion({ control: button });
151
152 var expected = [
153 { type: 'mouseover', target: button, region: null },
154 { type: 'mouseenter', target: button, region: null },
155 { type: 'mousemove', target: button, region: null },
156 { type: 'mousemove', target: button, region: null },
157 { type: 'mousedown', target: button, region: null },
158 { type: 'mouseup', target: button, region: null },
159 { type: 'mouseout', target: button, region: null },
160 { type: 'mouseleave', target: button, region: null },
161 { type: 'touchstart', target: button, region: null },
162 { type: 'touchend', target: button, region: null },
163 ];
164 var actual = [];
165
166 button.addEventListener('mouseover', e => actual.push(e));
167 button.addEventListener('mouseenter', e => actual.push(e));
168 button.addEventListener('mousemove', e => actual.push(e));
169 button.addEventListener('mousedown', e => actual.push(e));
170 button.addEventListener('mouseup', e => actual.push(e));
171 button.addEventListener('mouseout', e => actual.push(e));
172 button.addEventListener('mouseleave', e => actual.push(e));
173 button.addEventListener('touchstart', e => actual.push(e));
174 button.addEventListener('touchend', e => actual.push(e));
175
176 if (eventSender) {
177 eventSender.mouseMoveTo(0, 0);
178 eventSender.mouseMoveTo(10, 10);
179 eventSender.mouseDown();
180 eventSender.mouseUp();
181 eventSender.mouseMoveTo(60, 60);
182
183 eventSender.clearTouchPoints();
184 eventSender.addTouchPoint(10, 10);
185 eventSender.touchStart();
186 eventSender.releaseTouchPoint(0);
187 eventSender.touchEnd();
188 }
189
190 assert_event_array_equivalent(actual, expected);
191 this.done();
192 }, 'Rerouting mouse/touch event test but the id of hit region is unset.');
193
194 async_test(function() {
150 context.clearRect(0, 0, 400, 400); 195 context.clearRect(0, 0, 400, 400);
151 context.rect(0, 0, 50, 50); 196 context.rect(0, 0, 50, 50);
152 context.fill(); 197 context.fill();
153 context.addHitRegion({ id: 'button', control: button }); 198 context.addHitRegion({ id: 'button', control: button });
154 context.beginPath(); 199 context.beginPath();
155 context.rect(50, 0, 50, 50); 200 context.rect(50, 0, 50, 50);
156 context.fill(); 201 context.fill();
157 context.addHitRegion({ id: 'button2', control: button2 }); 202 context.addHitRegion({ id: 'button2', control: button2 });
158 203
159 var expected = [ 204 var expected = [
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 called.push(e.touches[1].region); 303 called.push(e.touches[1].region);
259 called.push(e.touches[2].region); 304 called.push(e.touches[2].region);
260 }); 305 });
261 306
262 tmp_canvas.dispatchEvent(touch_event); 307 tmp_canvas.dispatchEvent(touch_event);
263 assert_array_equals(called, [ null, null, 'touch', null, null, 'touch' ]); 308 assert_array_equals(called, [ null, null, 'touch', null, null, 'touch' ]);
264 this.done(); 309 this.done();
265 }, 'TouchEventInit.'); 310 }, 'TouchEventInit.');
266 311
267 </script> 312 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698