summaryrefslogtreecommitdiffstats
path: root/layout/generic/test/test_bug784410.html
blob: efaf6f943071b3942082db8c59c703c24d04e2e8 (plain)
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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test bug 784410</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="outer" style="overflow:auto; height:200px; border:2px dotted black; transform: translateY(1px)" onscroll="doneScroll()">
  <div id="d" style="overflow:auto; height:102px;" onscroll="doneScroll()">
    <div id="inner" style="height:100.1px; border:1px solid black; background:yellow;">Hello</div>
  </div>
  <div style="height:500px;"></div>
</div>
<pre id="test">
<script class="testbody" type="text/javascript;version=1.7">
var sel = window.getSelection();
var outer = document.getElementById("outer");
var d = document.getElementById("d");
var inner = document.getElementById("inner");
var smoothScrollPref = "general.smoothScroll";

function innerScrollOffset() {
  return inner.getBoundingClientRect().top - d.getBoundingClientRect().top;
}
var innerStartScrollOffset = innerScrollOffset();

var step = 0;
function doneScroll() {
  ++step;
  switch (step) {
  case 1:
    is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
    ok(outer.scrollTop > 0, "Outer element should have scrolled down");

    outer.scrollTop = 0;
    break;
  case 2:
    // Wait for paints to flush, so APZ is notified of the new scroll offset.
    sendWheelAndPaint(inner, 4, 4,
      { deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 1 },
      function() {});
    break;
  case 3:
    is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
    ok(outer.scrollTop > 0, "Outer element should have scrolled down");
    
    SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
    SimpleTest.finish();
    break;
  }
}

function test() {
  sel.collapse(inner.firstChild, 2);
  synthesizeKey("VK_PAGE_DOWN", {});
}

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
  SpecialPowers.pushPrefEnv({"set":[[smoothScrollPref, false]]}, test);
});
</script>
</pre>
</body>
</html>