Bug 1629710 - Add a hit-testing test with a very deep stack of results. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D96467
This commit is contained in:
Kartikaya Gupta 2020-11-10 15:35:49 +00:00
Родитель 5831b3e790
Коммит 4fce064277
2 изменённых файлов: 72 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,57 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Exercising the APZ/WR hit-test with a deep scene that produces many results</title>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<meta name="viewport" content="width=device-width"/>
<style>
body {
transform-style: preserve-3d;
}
div {
height: 100px;
background-color: rgba(0, 255, 0, 0.1);
transform: translateX(1px);
}
</style>
</head>
<body>
<script>
// Create a 1000-deep set of nested divs with some transparency and transforms.
// This ensures that the WR hit-test will return all of the divs at the tested
// point, rather than just the topmost one. We set a touch-action property on
// this div so that we can ensure we're hit-testing at the right spot.
var div = document.createElement('div');
div.id = "innermost";
div.style.touchAction = "pan-x pan-y";
div.style.width = "2px";
for (var i = 3; i < 1000; i++) {
var container = document.createElement('div');
container.style.width = i + "px";
container.appendChild(div);
div = container;
}
document.body.appendChild(div);
async function test(testDriver) {
var config = getHitTestConfig();
var utils = config.utils;
// Hit-test at the deepest point of divs.
checkHitResult(hitTest(centerOf(document.getElementById("innermost"))),
APZHitResultFlags.VISIBLE | APZHitResultFlags.PINCH_ZOOM_DISABLED | APZHitResultFlags.DOUBLE_TAP_ZOOM_DISABLED,
utils.getViewId(document.scrollingElement),
utils.getLayersId(),
"innermost div");
}
waitUntilApzStable().then(test).then(subtestDone, subtestFailed);
</script>
</body>

Просмотреть файл

@ -44,10 +44,24 @@ var subtests = [
{"file": "helper_hittest_hidden_inactive_scrollframe.html", "prefs": prefs},
];
function addConditionalTests(tests) {
// Add some more tests only useful with WebRender. Note that we do this in
// function run after loading, because trying to read layerManagerType can
// throw an NS_ERROR_FAILURE if called too early.
var utils = SpecialPowers.getDOMWindowUtils(window);
var isWebRender = utils.layerManagerType == "WebRender";
if (isWebRender) {
tests = tests.concat([
{"file": "helper_hittest_deep_scene_stack.html", "prefs": prefs},
]);
}
return tests;
}
if (isApzEnabled()) {
SimpleTest.waitForExplicitFinish();
window.onload = function() {
runSubtestsSeriallyInFreshWindows(subtests)
runSubtestsSeriallyInFreshWindows(addConditionalTests(subtests))
.then(SimpleTest.finish, SimpleTest.finishWithFailure);
};
}