Bug 1307555 - Mochitest. r=kats
MozReview-Commit-ID: 1e06rX4SQD8
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_hittest_checkerboard.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>APZ hit-testing over a checkerboarded area</title>
+ <script type="application/javascript" src="apz_test_utils.js"></script>
+ <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+ <meta name="viewport" content="width=device-width"/>
+</head>
+<body>
+ <div id="scroller" style="width: 300px; height: 300px; overflow:scroll; margin-top: 100px; margin-left: 50px">
+ <!-- Make the contents tall enough to be sure we can checkerboard -->
+ <div id="contents" style="width: 100%; height: 5000px; background-image: linear-gradient(blue,red)">
+ </div>
+ </div>
+ <div id="make_root_scrollable" style="height: 5000px"></div>
+</body>
+<script type="application/javascript">
+
+function centerOf(element) {
+ var bounds = element.getBoundingClientRect();
+ return { x: bounds.x + (bounds.width / 2), y: bounds.y + (bounds.height / 2) };
+}
+
+function* test(testDriver) {
+ var config = getHitTestConfig();
+ var utils = config.utils;
+
+ var scroller = document.getElementById('scroller');
+
+ // Activate the scrollframe but keep the main-thread scroll position at 0.
+ // Also apply an async scroll offset in the y-direction such that the
+ // scrollframe scrolls all the way to the bottom of its range, where it's
+ // sure to checkerboard.
+ utils.setDisplayPortForElement(0, 0, 300, 1000, scroller, 1);
+ yield waitForAllPaints(testDriver);
+ var scrollY = scroller.scrollTopMax;
+ utils.setAsyncScrollOffset(scroller, 0, scrollY);
+ if (config.isWebRender) {
+ // Tick the refresh driver once to make sure the compositor has applied the
+ // async scroll offset (for APZ hit-testing this doesn't matter, but for
+ // WebRender hit-testing we need to make sure WR has the latest info).
+ utils.advanceTimeAndRefresh(16);
+ utils.restoreNormalRefresh();
+ }
+
+ var scrollerViewId = utils.getViewId(scroller);
+
+ // Hit-test the middle of the scrollframe, which is now inside the
+ // checkerboarded region, and check that we hit the scrollframe and
+ // not its parent.
+ var {hitInfo, scrollId} = hitTest(centerOf(scroller));
+ is(hitInfo, APZHitResultFlags.VISIBLE,
+ "active scrollframe hit info");
+ is(scrollId, scrollerViewId,
+ "active scrollframe scrollid");
+
+ subtestDone();
+}
+
+waitUntilApzStable().then(runContinuation(test));
+
+</script>
+</html>
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -15,16 +15,17 @@
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_hittest_basic.html
+ helper_hittest_checkerboard.html
helper_hittest_subframe_float.html
helper_key_scroll.html
helper_long_tap.html
helper_override_root.html
helper_override_subdoc.html
helper_scroll_inactive_perspective.html
helper_scroll_inactive_zindex.html
helper_scroll_on_position_fixed.html
--- a/gfx/layers/apz/test/mochitest/test_group_hittest.html
+++ b/gfx/layers/apz/test/mochitest/test_group_hittest.html
@@ -24,16 +24,17 @@ var prefs = [
["test.events.async.enabled", true],
// Turns on APZTestData logging which we use to obtain the hit test results.
["apz.test.logging_enabled", true]
];
var subtests = [
{'file': 'helper_hittest_basic.html', 'prefs': prefs},
{'file': 'helper_hittest_subframe_float.html', 'prefs': prefs},
+ {'file': 'helper_hittest_checkerboard.html', 'prefs': prefs},
];
if (isApzEnabled()) {
SimpleTest.waitForExplicitFinish();
window.onload = function() {
runSubtestsSeriallyInFreshWindows(subtests)
.then(SimpleTest.finish, SimpleTest.finish);
};