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;
const kDuration = 200;
promise_test(async function(t) {
  await SpecialPowers.pushPrefEnv({
    set: [
      ["ui.useOverlayScrollbars", 1],
      ["ui.scrollbarFadeDuration", kDuration],
    ]
  });
  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");
  await new Promise(r => t.step_timeout(r, kDuration));
  await new Promise(r => requestAnimationFrame(r));
  assert_true(true, "No scrollbar event should've happened by now");
  // FIXME: This doesn't seem to be done automatically by the test harness in WPT
  await SpecialPowers.popPrefEnv();
});
</script>