Bug 1645433 - Add a test. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D96077
This commit is contained in:
Kartikaya Gupta 2020-11-20 02:28:25 +00:00
parent 94bd7fb7c9
commit 408750fcc0
2 changed files with 90 additions and 1 deletions

View File

@ -50,11 +50,12 @@ add_task(async function test_main() {
file: "helper_fission_tap.html",
prefs: [["apz.max_tap_time", 10000]],
},
{ file: "helper_fission_inactivescroller_under_oopif.html" },
// add additional tests here
];
if (isWebRender) {
subtests = subtests.concat([
// add additional WebRender-specific tests here
// add WebRender-specific tests here
]);
} else {
subtests = subtests.concat([

View File

@ -0,0 +1,88 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Ensure inactive scollframes under OOPIFs hit-test properly</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script src="helper_fission_utils.js"></script>
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<script>
fission_subtest_init();
FissionTestHelper.startTestPromise
.then(waitUntilApzStable)
.then(loadOOPIFrame("testframe", "helper_fission_empty.html"))
.then(waitUntilApzStable)
.then(test)
.then(FissionTestHelper.subtestDone, FissionTestHelper.subtestFailed);
let make_oopif_scrollable = function() {
// ensure the oopif is scrollable, and wait for the paint so that the
// compositor also knows it's scrollable.
document.body.style.height = "200vh";
promiseApzFlushedRepaints().then(() => {
let utils = SpecialPowers.getDOMWindowUtils(window);
let result = {
layersId: utils.getLayersId(),
viewId: utils.getViewId(document.scrollingElement)
};
dump(`OOPIF computed IDs ${JSON.stringify(result)}\n`);
FissionTestHelper.fireEventInEmbedder("OOPIF:Scrollable", result);
});
return true;
};
async function test() {
let iframe = document.getElementById("testframe");
let letScrollerIdPromise = promiseOneEvent(window, "OOPIF:Scrollable", null);
ok(await FissionTestHelper.sendToOopif(iframe, `(${make_oopif_scrollable})()`),
"Ran code to make OOPIF scrollable");
let oopifScrollerIds = (await letScrollerIdPromise).data;
// The #scroller div is (a) inactive, and (b) under the OOPIF. Hit-testing
// against it should hit the OOPIF.
checkHitResult(await fissionHitTest(centerOf("scroller"), iframe),
APZHitResultFlags.VISIBLE,
oopifScrollerIds.viewId,
oopifScrollerIds.layersId,
"Part of OOPIF sitting on top of the inactive scrollframe should hit OOPIF");
}
</script>
</head>
<body>
<style>
html, body {
margin: 0;
}
body {
/* Ensure root document is scrollable so that #scroller is inactive by
default */
height: 200vh;
}
iframe {
position: fixed;
top: 0;
left: 0;
width: 300px;
height: 200px;
}
#scroller {
width: 200px;
height: 200px;
background-color: transparent;
overflow-y: scroll;
}
</style>
<div id="scroller">
<div style="height:500px">inside scroller</div>
</div>
<iframe id="testframe"></iframe>
</body>
</html>