DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (920bcf17a9e1)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=469613
-->
<window title="Mozilla Bug 469613"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <title>Test for Bug 469613</title>
  <script type="application/javascript" src="/MochiKit/packed.js" />
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
<body  xmlns="http://www.w3.org/1999/xhtml">
  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=469613">Mozilla Bug 469613</a>

  <p id="display"></p>
<div id="content" style="display: none">
</div>
</body>

<vbox style="height: 100px; overflow: auto;" id="scrollbox">
  <hbox style="height: 200px;"/>
</vbox>

<script class="testbody" type="application/javascript;version=1.7"><![CDATA[

/** Test for Bug 469613 **/

function doTest() {
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

  let scrollbox = document.getElementById("scrollbox");
  scrollbox.scrollTop = 0;

  // Make sure that the "scroll focus" is inside the scrollbox by moving the
  // mouse in the scrollbox.
  synthesizeMouse(scrollbox, 6, 6, { type: "mousemove" });
  synthesizeMouse(scrollbox, 8, 8, { type: "mousemove" });

  // Now scroll 10px down.
  synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:10, type:"MozMousePixelScroll"});

  // Send a 0-delta scroll.
  synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:0, type:"MozMousePixelScroll"});

  setTimeout(function() {
    // Check if the 10px were scrolled.
    is(scrollbox.scrollTop, 10, "Starting a 0-delta scroll shouldn't cancel a pending async scroll.");


    // Second test
    scrollbox.scrollTop = 20;

    // Start an async scroll to 30.
    synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:10, type:"MozMousePixelScroll"});

    // Start a sync scroll to 30.
    scrollbox.scrollTop = 30;

    is(scrollbox.scrollTop, 30, "Setting scrollTop should have immediate effect, even if there was a pending async scroll to the same position.");


    // Third test
    scrollbox.scrollTop = 40;

    // Start an async scroll to 50.
    synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:10, type:"MozMousePixelScroll"});
    
    // Cancel the async scroll.
    scrollbox.scrollTop = 40;

    // Send a 0-delta scroll.
    synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:0, type:"MozMousePixelScroll"});

    setTimeout(function() {
      is(scrollbox.scrollTop, 40, "Canceling an async scroll should reset the point of reference for relative scrolls (mDestinationX/Y).");

      SimpleTest.finish();
    }, 0);
  }, 0);
}

SimpleTest.waitForExplicitFinish();
addLoadEvent(function() setTimeout(doTest, 0));

]]></script>

</window>