Bug 1447131 - Move centerOf() into apz_test_utils.js. r=kats
MozReview-Commit-ID: CwO5SnWmhb9
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -517,16 +517,22 @@ function getHitTestConfig() {
var utils = SpecialPowers.getDOMWindowUtils(window);
var isWebRender = (utils.layerManagerType == 'WebRender');
var isWindows = (getPlatform() == 'windows');
window.hitTestConfig = { utils, isWebRender, isWindows };
}
return window.hitTestConfig;
}
+// Compute the coordinates of the center of the given element.
+function centerOf(element) {
+ var bounds = element.getBoundingClientRect();
+ return { x: bounds.x + (bounds.width / 2), y: bounds.y + (bounds.height / 2) };
+}
+
// Peform a compositor hit test at the given point and return the result.
// The returned object has two fields:
// hitInfo: a combination of APZHitResultFlags
// scrollId: the view-id of the scroll frame that was hit
function hitTest(point) {
var utils = getHitTestConfig().utils;
dump("Hit-testing point (" + point.x + ", " + point.y + ")\n");
utils.sendMouseEvent("MozMouseHittest", point.x, point.y, 0, 0, 0, true, 0, 0, true, true);
--- a/gfx/layers/apz/test/mochitest/helper_hittest_basic.html
+++ b/gfx/layers/apz/test/mochitest/helper_hittest_basic.html
@@ -12,21 +12,16 @@
<div id="contents" style="width: 500px; height: 500px; background-image: linear-gradient(blue,red)">
<div id="apzaware" style="position: relative; width: 100px; height: 100px; top: 300px; background-color: red" onwheel="return false;"></div>
</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');
var apzaware = document.getElementById('apzaware');
var {hitInfo, scrollId} = hitTest(centerOf(scroller));
--- a/gfx/layers/apz/test/mochitest/helper_hittest_checkerboard.html
+++ b/gfx/layers/apz/test/mochitest/helper_hittest_checkerboard.html
@@ -12,21 +12,16 @@
<!-- 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