Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-overflow/scrollbar-events.html - WPT Dashboard Interop Dashboard
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#container {
width: 100px;
height: 100px;
border: 1px;
}
#child {
height: 200px;
}
</style>
<div id="container">
<div id="child"></div>
</div>
<script>
let container = document.getElementById("container");
let child = document.getElementById("child");
let InspectorUtils = SpecialPowers.wrap(window).InspectorUtils;
promise_test(async function(t) {
await SpecialPowers.pushPrefEnv({
set: [
["ui.useOverlayScrollbars", 1],
["ui.scrollbarFadeDuration", 200],
]
});
for (let type of ["transitionstart", "transitionend"]) {
container.addEventListener(type, t.unreached_func(`Shouldn't see ${type} event on #container`));
}
// This creates scrollbars and triggers activation.
container.style.overflow = "scroll";
container.getBoundingClientRect();
let scrollbars = InspectorUtils.getChildrenForNode(container, true, true).filter(child => SpecialPowers.wrap(child).nodeName.toLowerCase() == "scrollbar");
assert_equals(scrollbars.length, 2, "Should have two scrollbars");
let {resolve, promise} = Promise.withResolvers();
{
let expectedEvents = 2;
for (let scrollbar of scrollbars) {
SpecialPowers.wrap(scrollbar).addEventListener("transitionend", function() {
assert_true(expectedEvents > 0, "Should see an expected transition");
if (--expectedEvents) {
resolve();
}
});
}
}
await promise;
await new Promise(r => requestAnimationFrame(r));
// FIXME: This doesn't seem to be done automatically by the test harness in WPT
await SpecialPowers.popPrefEnv();
});
</script>