Commit 46166484 authored by Hiroyuki Ikezoe's avatar Hiroyuki Ikezoe
Browse files

Bug 1754129 - Factor out a function to collect APZTestData for the given element. r=botond

parent a9f82139
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1242,3 +1242,17 @@ async function cancelScrollAnimation(aElement, aWindow = window) {
  aElement.style.display = originalStyle;
  await aWindow.promiseApzFlushedRepaints();
}

function collectSampledScrollOffsets(aElement) {
  let data = SpecialPowers.DOMWindowUtils.getCompositorAPZTestData();
  let sampledResults = data.sampledResults;

  const layersId = SpecialPowers.DOMWindowUtils.getLayersId();
  const scrollId = SpecialPowers.DOMWindowUtils.getViewId(aElement);

  return sampledResults.filter(
    result =>
      SpecialPowers.wrap(result).layersId == layersId &&
      SpecialPowers.wrap(result).scrollId == scrollId
  );
}
+1 −14
Original line number Diff line number Diff line
@@ -68,19 +68,6 @@ window.addEventListener("scroll", () => {
}, { once: true });


function collectRootScrollOffsets() {
  let data = SpecialPowers.DOMWindowUtils.getCompositorAPZTestData();
  let sampledResults = data.sampledResults;

  const layersId = SpecialPowers.DOMWindowUtils.getLayersId();
  const scrollId = SpecialPowers.DOMWindowUtils.getViewId(document.scrollingElement);

  return sampledResults.filter(
    result => SpecialPowers.wrap(result).layersId == layersId &&
              SpecialPowers.wrap(result).scrollId == scrollId
  );
}

async function test() {
  // Once this content starts scrolling, it triggers a 100ms jank every 300ms so
  // sending arrow down keys for 1500ms will cause some jank.
@@ -110,7 +97,7 @@ async function test() {
  // Stop the periodic expansions.
  clearInterval(intervalId);

  const records = collectRootScrollOffsets();
  const records = collectSampledScrollOffsets(document.scrollingElement);

  let previousRecord = { scrollOffsetY: 0, sampledTimeStamp: 0 };
  for (const record of records) {