Blame devtools/client/debugger/new/test/mochitest/browser_dbg-pause-ux.js

Packit f0b94e
/* Any copyright is dedicated to the Public Domain.
Packit f0b94e
 * http://creativecommons.org/publicdomain/zero/1.0/ */
Packit f0b94e
Packit f0b94e
function getScrollTop(dbg) {
Packit f0b94e
  return getCM(dbg).doc.scrollTop;
Packit f0b94e
}
Packit f0b94e
Packit f0b94e
async function waitForMatch(dbg, { matchIndex, count }) {
Packit f0b94e
  await waitForState(
Packit f0b94e
    dbg,
Packit f0b94e
    state => {
Packit f0b94e
      const result = dbg.selectors.getFileSearchResults(state);
Packit f0b94e
      return result.matchIndex == matchIndex && result.count == count;
Packit f0b94e
    },
Packit f0b94e
    "wait for match"
Packit f0b94e
  );
Packit f0b94e
}
Packit f0b94e
Packit f0b94e
add_task(async function() {
Packit f0b94e
  const dbg = await initDebugger("doc-scripts.html");
Packit f0b94e
Packit f0b94e
  // Make sure that we can set a breakpoint on a line out of the
Packit f0b94e
  // viewport, and that pausing there scrolls the editor to it.
Packit f0b94e
  let longSrc = findSource(dbg, "long.js");
Packit f0b94e
  await addBreakpoint(dbg, longSrc, 66);
Packit f0b94e
  invokeInTab("testModel");
Packit f0b94e
  await waitForPaused(dbg);
Packit f0b94e
Packit f0b94e
  const pauseScrollTop = getScrollTop(dbg);
Packit f0b94e
Packit f0b94e
  log("1. adding a breakpoint should not scroll the editor");
Packit f0b94e
  getCM(dbg).scrollTo(0, 0);
Packit f0b94e
  await addBreakpoint(dbg, longSrc, 11);
Packit f0b94e
  is(getScrollTop(dbg), 0, "scroll position");
Packit f0b94e
Packit f0b94e
  log("2. searching should jump to the match");
Packit f0b94e
  pressKey(dbg, "fileSearch");
Packit f0b94e
  type(dbg, "check");
Packit f0b94e
  await waitForMatch(dbg, { matchIndex: 0, count: 2 });
Packit f0b94e
  const matchScrollTop = getScrollTop(dbg);
Packit f0b94e
  ok(pauseScrollTop != matchScrollTop, "did not jump to debug line");
Packit f0b94e
});