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

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: Replace with passing Active to be consistent 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..c50a99d2217abdd8f141857952c7f29d4f03f446
--- /dev/null
+++ b/LayoutTests/fast/events/dispatch-mouse-events-to-window-always.html
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<style>
+* {
+ padding: 0;
+ margin: 0;
+}
+
+::-webkit-scrollbar {
+ display: none;
+}
+
+html, body {
+ height: 400px;
+ width: 400px;
+ background: #eee;
+ padding: 0;
+ margin: 0;
+}
+
+div#child {
+ position: absolute;
+ top : 0;
+ left: 400px;
+ width: 400px;
+ height: 10000px;
+ background: #ddd;
+}
+
+</style>
+
+<body>
+ <div id='child'></div>
+ <div id='console'></div>
+</body>
+
+<script src="../../resources/js-test.js"></script>
+<script>
+jsTestIsAsync = true;
+setPrintTestResultsLazily();
+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.receivers = new Map();
+ var eventTypes = ['wheel', 'click', 'mousedown', 'mouseup'];
+ var eventTargets = [window, document, document.body, document.getElementById('child')];
+
+ for (var eventType of eventTypes) {
+ window.receivers[eventType] = [];
+ for (var target of eventTargets) {
+ target.addEventListener(eventType, registerEvent.bind(target));
+ }
+ }
+
+ debug('outside body, inside element'); // received by element, body, doc, window
+ generateEventsAndVerify(500, 500, [document.getElementById('child'), document.body, document, window]);
+ debug('inside body, outside element'); // received by body, doc, window
+ generateEventsAndVerify(10, 10, [document.body, document, window]);
+ debug('outside body, outside element, inside frame'); // received by doc, window
+ generateEventsAndVerify(10, 500, [document, window]);
+ debug('outside body, outside element, outside frame'); // received by doc, window
+ generateEventsAndVerify(10, 2000, [document, window]);
+
+ finishJSTest();
+
+ function registerEvent(e) {
+ window.receivers[e.type].push(this);
+ }
+
+ function generateEventsAndVerify(x, y, expectedReceivers) {
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ verifyReceivers('mousedown', expectedReceivers);
+
+ eventSender.mouseUp();
+ verifyReceivers('mouseup', expectedReceivers);
+ verifyReceivers('click', expectedReceivers);
+
+ eventSender.mouseScrollBy(10, 10);
+ verifyReceivers('wheel', expectedReceivers);
+ }
+
+ function verifyReceivers(eventType, expectedReceivers) {
+ window.expectedReceivers = expectedReceivers;
+ window.actualReceivers = receivers[eventType];
+ debug('eventType: ' + eventType);
+ shouldBe('actualReceivers', 'expectedReceivers');
Rick Byers 2015/06/30 20:14:49 nit: can you remove the quotes from expectedReceiv
majidvp 2015/06/30 22:48:31 ShouldBe does not like non-string arguments. I use
Rick Byers 2015/07/01 13:41:03 Oh right. Sure this looks fine (since you're only
+
+ window.receivers[eventType] = [];
+ }
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698