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

Unified Diff: LayoutTests/fast/events/dispatch-mouse-events-to-window-always.html

Issue 1210253003: Fix wheel event dispatch logic to fallback to document when hit-test fails (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/events/dispatch-mouse-events-to-window-always.html
diff --git a/LayoutTests/fast/events/dispatch-mouse-events-to-window-always.html b/LayoutTests/fast/events/dispatch-mouse-events-to-window-always.html
new file mode 100644
index 0000000000000000000000000000000000000000..412576d51f9a84c2aae349722117399fd7816ab0
--- /dev/null
+++ b/LayoutTests/fast/events/dispatch-mouse-events-to-window-always.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<style>
+html, body {
+ height: 400px;
+ width: 400px;
+ background: #eee;
+ padding: 0;
+ margin: 0;
+}
+
+div#child {
+ position: absolute;
+ top : 0;
+ width: 400px;
+ height: 10000px;
+ margin-left: 400px;
+ background: #ddd;
+}
+</style>
+
+<body>
Rick Byers 2015/06/26 12:34:49 nit: omit body
majidvp 2015/06/29 16:58:40 I added body element specifically to test that the
Rick Byers 2015/06/29 17:07:58 Duh, of course - sorry.
+ <div id='child'></div>
+ <div id='console'></div>
+</body>
+
+<script src="../../resources/js-test.js"></script>
+<script>
+jsTestIsAsync = true;
+description('Test that wheel and mouse events are dispatched to document ' +
+ 'and window even if they do not hit any element in the page.');
+
+onload = function() {
+ if (!window.eventSender) {
+ testFailed('window.eventSender is required for this test.');
+ return;
+ }
+
+ window.dispatchCount = new Map();
+
+ var eventTypes = ['wheel', 'click', 'mousedown', 'mouseup'];
+ var eventTargets = [window, document, document.body, document.getElementById('child')];
+
+ for (var target of eventTargets) {
+ dispatchCount[target] = new Map();
+ for (var eventType of eventTypes) {
+ target.addEventListener(eventType, countEvent.bind(target));
+ dispatchCount[target][eventType] = 0;
+ }
+ }
+
+ generateEvents(600, 600); // outside body, inside element => received by element, body, doc, window
+ generateEvents(10, 10); // inside body, outside element => received by body, doc, window
+ generateEvents(10, 500); // outside body, outside element, inside frame => received by doc, window
+ generateEvents(10, 2000); // outside body, outside element, outside frame => received by doc, window
+
+ for (var eventType of eventTypes) {
+ window.eventType = eventType;
+ debug('eventType: ' + eventType);
+ shouldBe('dispatchCount[window][eventType]', '4');
Rick Byers 2015/06/26 12:34:49 This seems a little indirect - eg. hard to debug w
majidvp 2015/06/29 16:58:40 Acknowledged.
majidvp 2015/06/30 15:33:04 Done.
+ shouldBe('dispatchCount[document][eventType]', '4');
+ shouldBe('dispatchCount[document.body][eventType]', '2');
+ shouldBe('dispatchCount[document.getElementById("child")][eventType]', '1');
+ }
+
+ finishJSTest();
+
+ function countEvent(e) {
+ window.dispatchCount[this][e.type]++;
+ }
+
+ function generateEvents(x, y) {
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseScrollBy(10, 10);
+ }
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698