tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_markup_dragdrop_autoscroll_01.js (1586B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that dragging a node near the top or bottom edge of the markup-view
      7 // auto-scrolls the view on a large toolbox.
      8 
      9 const TEST_URL = URL_ROOT + "doc_markup_dragdrop_autoscroll_01.html";
     10 
     11 add_task(async function () {
     12  // Set the toolbox as large as it would get. The toolbox automatically shrinks
     13  // to not overflow to window.
     14  await pushPref("devtools.toolbox.footer.height", 10000);
     15 
     16  const { inspector } = await openInspectorForURL(TEST_URL);
     17  const markup = inspector.markup;
     18  const viewHeight = markup.doc.documentElement.clientHeight;
     19 
     20  info("Pretend the markup-view is dragging");
     21  markup.isDragging = true;
     22 
     23  info("Simulate a mousemove on the view, at the bottom, and expect scrolling");
     24 
     25  markup._onMouseMove({
     26    preventDefault: () => {},
     27    target: markup.doc.body,
     28    pageY: viewHeight + markup.doc.defaultView.scrollY,
     29  });
     30 
     31  const bottomScrollPos = await waitForScrollStop(markup.doc);
     32  Assert.greater(bottomScrollPos, 0, "The view was scrolled down");
     33 
     34  info("Simulate a mousemove at the top and expect more scrolling");
     35 
     36  markup._onMouseMove({
     37    preventDefault: () => {},
     38    target: markup.doc.body,
     39    pageY: markup.doc.defaultView.scrollY,
     40  });
     41 
     42  const topScrollPos = await waitForScrollStop(markup.doc);
     43  Assert.less(topScrollPos, bottomScrollPos, "The view was scrolled up");
     44  is(topScrollPos, 0, "The view was scrolled up to the top");
     45 
     46  info("Simulate a mouseup to stop dragging");
     47  markup._onMouseUp();
     48 });