<!DOCTYPE html>
<!-- This is an expanded version of external/wpt/css/cssom-view/background-change-during-smooth-scroll.html,
to ensure the test actually exercises the code path to be covered. -->
<style>
#container {
width: 200px;
height: 200px;
overflow: scroll;
background: white;
}
#content {
width: 7500px;
height: 7500px;
}
</style>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
// Disable PreferCompositingToLCDText so that changing background opaqueness
// can change composited scrolling status.
if (window.internals)
internals.settings.setPreferCompositingToLCDTextEnabled(false);
var t = async_test('overflow-scroll-loses-composited-scrolling');
function startSmoothScroll() {
t.step(() => {
if (window.internals) {
assert_true(internals.layerTreeAsText(document).includes('container'),
'container should be composited');
}
});
var scrollToOptions = {behavior: "smooth", top: 6000};
container.scrollTo(scrollToOptions);
requestAnimationFrame(preventCompositedScrolling);
}
function preventCompositedScrolling() {
container.style.background = "transparent";
requestAnimationFrame(() => {
t.step(() => {
if (window.internals) {
assert_false(internals.layerTreeAsText(document).includes('container'),
'container should not be composited');
}
});
waitForSmoothScrollEnd();
});
}
function waitForSmoothScrollEnd() {
if (container.scrollTop == 6000) {
t.done();
} else {
window.requestAnimationFrame(waitForSmoothScrollEnd);
}
}
onload = () => {
requestAnimationFrame(startSmoothScroll);
}
</script>
<div id="container">
<div id="content">Content</div>
</div>