tor-browser

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

browser_test_scroll_thumb_dragging.js (2382B)


      1 add_task(async function () {
      2  function httpURL(filename) {
      3    let chromeURL = getRootDirectory(gTestPath) + filename;
      4    return chromeURL.replace(
      5      "chrome://mochitests/content/",
      6      "http://mochi.test:8888/"
      7    );
      8  }
      9 
     10  const newWin = await BrowserTestUtils.openNewBrowserWindow();
     11 
     12  const pageUrl = httpURL("helper_scroll_thumb_dragging.html");
     13  const tab = await BrowserTestUtils.openNewForegroundTab(
     14    newWin.gBrowser,
     15    pageUrl
     16  );
     17 
     18  await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
     19    await content.wrappedJSObject.promiseApzFlushedRepaints();
     20    await content.wrappedJSObject.waitUntilApzStable();
     21  });
     22 
     23  // Send an explicit click event to make sure the new window accidentally
     24  // doesn't get an "enter-notify-event" on Linux during dragging, the event
     25  // forcibly cancels the dragging state.
     26  await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
     27    // Creating an object in this content privilege so that the object
     28    // properties can be accessed in below
     29    // promiseNativeMouseEventWithAPZAndWaitForEvent function.
     30    const moveParams = content.window.eval(`({
     31      target: window,
     32      type: "mousemove",
     33      offsetX: 10,
     34      offsetY: 10
     35    })`);
     36    const clickParams = content.window.eval(`({
     37      target: window,
     38      type: "click",
     39      offsetX: 10,
     40      offsetY: 10
     41    })`);
     42    // Send a mouse move event first to make sure the "enter-notify-event"
     43    // happens.
     44    await content.wrappedJSObject.promiseNativeMouseEventWithAPZAndWaitForEvent(
     45      moveParams
     46    );
     47    await content.wrappedJSObject.promiseNativeMouseEventWithAPZAndWaitForEvent(
     48      clickParams
     49    );
     50  });
     51 
     52  await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
     53    const scrollPromise = new Promise(resolve => {
     54      content.window.addEventListener("scroll", resolve, { once: true });
     55    });
     56    const dragFinisher =
     57      await content.wrappedJSObject.promiseVerticalScrollbarDrag(
     58        content.window,
     59        10,
     60        10
     61      );
     62 
     63    await scrollPromise;
     64    await dragFinisher();
     65 
     66    await content.wrappedJSObject.promiseApzFlushedRepaints();
     67  });
     68 
     69  await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
     70    ok(
     71      content.window.scrollY < 100,
     72      "The root scrollable content shouldn't be scrolled too much"
     73    );
     74  });
     75 
     76  await BrowserTestUtils.closeWindow(newWin);
     77 });