Index: LayoutTests/fast/scrolling/scrollbar-prevent-default.html |
diff --git a/LayoutTests/fast/scrolling/scrollbar-prevent-default.html b/LayoutTests/fast/scrolling/scrollbar-prevent-default.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..847e77224b25b27981983666113759af21e138c4 |
--- /dev/null |
+++ b/LayoutTests/fast/scrolling/scrollbar-prevent-default.html |
@@ -0,0 +1,65 @@ |
+<head> |
+ <script src="../../resources/js-test.js"></script> |
+ <style> |
+ body { |
+ height: 200vh; |
+ width: 200vw; |
+ margin: 0; |
+ } |
+ #subframe { |
+ width: 100px; |
+ height: 100px; |
+ background-color: black; |
+ overflow: scroll; |
+ } |
+ #subframe-content { |
+ width: 200px; |
+ height: 200px; |
+ background-color: black; |
+ } |
+ </style> |
+</head> |
+<body> |
+ <div id="subframe"> |
+ <div id="subframe-content"></div> |
+ </div> |
+ <pre id="console"></pre> |
+</body> |
+<script> |
+ description('This tests that scrollbars always receive events even when there is an element underneath the scrollbar which swallows the event. In this case an event handler is added to the window which swallows the event but this may also happen with elements underneath of overlay scrollbars.'); |
+ if (window.testRunner) |
+ testRunner.dumpAsText(); |
+ if (window.internals) |
+ internals.settings.setMockScrollbarsEnabled(true) |
+ |
+ var receivedMousedownEvent = false; |
+ |
+ document.addEventListener('mousedown', function(e) { |
+ e.preventDefault(); |
+ receivedMousedownEvent = true; |
+ }); |
+ |
+ // Test the frame scrollbar. |
+ window.scrollTo(0, 10); |
+ if (window.eventSender) { |
+ eventSender.mouseMoveTo(window.innerWidth - 5, 1); |
+ eventSender.mouseDown(); |
+ eventSender.mouseUp(); |
+ } |
+ |
+ shouldBe('window.scrollY', '0'); |
+ shouldBe('receivedMousedownEvent', 'true'); |
+ |
+ // Test a div scrollbar. |
+ receivedMousedownEvent = false; |
+ var subframe = document.getElementById('subframe'); |
+ subframe.scrollTop = 10; |
+ if (window.eventSender) { |
+ eventSender.mouseMoveTo(100 - 5, 1); |
+ eventSender.mouseDown(); |
+ eventSender.mouseUp(); |
+ } |
+ |
+ shouldBe('subframe.scrollTop', '0'); |
+ shouldBe('receivedMousedownEvent', 'true'); |
+</script> |