tor-browser

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

browser_markup_dragdrop_autoscroll_02.js (1514B)


      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 small toolbox.
      8 
      9 const TEST_URL = URL_ROOT + "doc_markup_dragdrop_autoscroll_02.html";
     10 
     11 add_task(async function () {
     12  // Set the toolbox to very small in size.
     13  await pushPref("devtools.toolbox.footer.height", 150);
     14 
     15  const { inspector } = await openInspectorForURL(TEST_URL);
     16  const markup = inspector.markup;
     17  const viewHeight = markup.doc.documentElement.clientHeight;
     18 
     19  info("Pretend the markup-view is dragging");
     20  markup.isDragging = true;
     21 
     22  info("Simulate a mousemove on the view, at the bottom, and expect scrolling");
     23 
     24  markup._onMouseMove({
     25    preventDefault: () => {},
     26    target: markup.doc.body,
     27    pageY: viewHeight + markup.doc.defaultView.scrollY,
     28  });
     29 
     30  const bottomScrollPos = await waitForScrollStop(markup.doc);
     31  Assert.greater(bottomScrollPos, 0, "The view was scrolled down");
     32  info("Simulate a mousemove at the top and expect more scrolling");
     33 
     34  markup._onMouseMove({
     35    preventDefault: () => {},
     36    target: markup.doc.body,
     37    pageY: markup.doc.defaultView.scrollY,
     38  });
     39 
     40  const topScrollPos = await waitForScrollStop(markup.doc);
     41  Assert.less(topScrollPos, bottomScrollPos, "The view was scrolled up");
     42  is(topScrollPos, 0, "The view was scrolled up to the top");
     43 
     44  info("Simulate a mouseup to stop dragging");
     45  markup._onMouseUp();
     46 });