Bug 1355374 - Mochitest for dragging partially offscreen scroll thumb. r=kats
MozReview-Commit-ID: 2EhSKLlFWSo
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_bug1355374.html
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width; initial-scale=1.0">
+ <title>Dragging a scrollbar that's partially offscreen</title>
+ <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
+ <script type="application/javascript" src="apz_test_utils.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+ <style>
+ button {
+ position: fixed;
+ top: 100px;
+ left: 400px;
+ }
+ button.spinning{
+ animation-name: spin;
+ animation-duration: 4000ms;
+ animation-iteration-count: infinite;
+ animation-timing-function: linear;
+ }
+ @keyframes spin {
+ from {
+ transform:rotate(0deg);
+ }
+ to {
+ transform:rotate(360deg);
+ }
+ }
+ #scrollable {
+ position: fixed;
+ bottom: -300px;
+ width: 300px;
+ height: 600px;
+ background: gray;
+ overflow-y: scroll;
+ }
+ #scrolled-content {
+ height: 1500px;
+ }
+ </style>
+ <script type="text/javascript">
+var scrollable;
+var scrollPos;
+var expectedScrollDelta;
+
+function scrolled(e) {
+ // Test that we have scrolled by the desired amount
+ var scrollDelta = scrollable.scrollTop - scrollPos;
+ var epsilon = 5;
+ ok(Math.abs(scrollDelta - expectedScrollDelta) < epsilon, "Scrolled by the expected amount");
+ subtestDone();
+}
+
+function* synthesizeNativeMouseDrag(target, startX, startY, endX, endY, continuation) {
+ // Move the mouse to the start position
+ yield synthesizeNativeMouseEvent(target, startX, startY, nativeMouseMoveEventMsg(), continuation);
+ // mouse down
+ yield synthesizeNativeMouseEvent(target, startX, startY, nativeMouseDownEventMsg(), continuation);
+ // drag vertically
+ yield synthesizeNativeMouseEvent(target, endX, endY, nativeMouseMoveEventMsg(), continuation);
+ // and release
+ yield synthesizeNativeMouseEvent(target, endX, endY, nativeMouseUpEventMsg(), continuation);
+}
+
+function* test(testDriver) {
+ scrollable = document.getElementById("scrollable");
+ var scrolledContent = document.getElementById("scrolled-content");
+ scrollPos = scrollable.scrollTop;
+ scrollable.addEventListener('scroll', scrolled);
+
+ var scrollbarX = (scrollable.offsetWidth + scrollable.clientWidth) / 2;
+ var startY = 50;
+ var endY = 250;
+ var ratio = scrolledContent.clientHeight / scrollable.clientHeight;
+ expectedScrollDelta = (endY - startY) * ratio;
+ yield* synthesizeNativeMouseDrag(scrollable, scrollbarX, startY, scrollbarX, endY, testDriver);
+}
+
+waitUntilApzStable()
+.then(runContinuation(test));
+
+ </script>
+</head>
+<body>
+ <div id="scrollable">
+ <div id="scrolled-content"></div>
+ </div>
+ <button class="spinning">The long button</button>
+</body>
+</html>
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -6,16 +6,17 @@
helper_bug982141.html
helper_bug1151663.html
helper_bug1162771.html
helper_bug1271432.html
helper_bug1280013.html
helper_bug1285070.html
helper_bug1299195.html
helper_bug1346632.html
+ helper_bug1355374.html
helper_click.html
helper_div_pan.html
helper_drag_click.html
helper_drag_scroll.html
helper_iframe_pan.html
helper_iframe1.html
helper_iframe2.html
helper_long_tap.html
--- a/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
@@ -14,17 +14,19 @@ var subtests = [
// Same as above, but with a dispatch-to-content region that exercises the
// main-thread notification codepaths for mouse events
{'file': 'helper_click.html?dtc=true'},
// Sanity test for click but with some mouse movement between the down and up
{'file': 'helper_drag_click.html'},
// Test for dragging on a fake-scrollbar element that scrolls the page
{'file': 'helper_drag_scroll.html'},
// Test for dragging the scrollbar with a fixed-pos element overlaying it
- {'file': 'helper_bug1346632.html'}
+ {'file': 'helper_bug1346632.html'},
+ // Test for dragging a scrollbar that's partially offscreen
+ {'file': 'helper_bug1355374.html'},
];
if (isApzEnabled()) {
SimpleTest.waitForExplicitFinish();
window.onload = function() {
runSubtestsSeriallyInFreshWindows(subtests)
.then(SimpleTest.finish);
};