summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_hittest_bug1730606-1.html
blob: b84cb6b63426d0c0f5ec409466292e218044a633 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE HTML>
<html>
<head>
  <title>A simple hit testing test that doesn't involve any transforms</title>
  <script type="application/javascript" src="apz_test_utils.js"></script>
  <script type="application/javascript" src="apz_test_native_event_utils.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <meta name="viewport" content="width=device-width"/>
  <style>
    body, html {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
    }
    .scrollable-content {
      width: 200%;
      height: 200%;
    }
    #layer1 {
      position: absolute;
      width: 100vw;
      height: 100vh;
      background: blue;
    }
    #layer2 {
      position: absolute;
      top: 100px;
      left: 100px;
      width: 100px;
      height: 100px;
      background: red;
    }
    #layer3 {
      position: absolute;
      top: 100px;
      left: 100px;
      width: 100px;
      height: 100px;
      background: green;
      overflow: hidden;
    }
    #layer4 {
      position: absolute;
      top: 50px;
      left: 50px;
      width: 100px;
      height: 100px;
      background: yellow;
      overflow: hidden;
    }
  </style>
</head>
<body>
 <div id="layer1"></div>
 <div id="layer2"></div>
 <div id="layer3">
   <div class="scrollable-content"></div>
 </div>
 <div id="layer4">
  <div class="scrollable-content"></div>
 </div>
 <div class="scrollable-content"></div>
</body>
<script type="application/javascript">

async function test() {
  var config = getHitTestConfig();
  var utils = config.utils;

  let subframeHitInfo = APZHitResultFlags.VISIBLE;
  if (!config.activateAllScrollFrames) {
    subframeHitInfo |= APZHitResultFlags.INACTIVE_SCROLLFRAME;
  }

  // Initially, the only thing scrollable is the root.
  checkHitResult(hitTest({x: 175, y: 175}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "root scroller");

  // Make layer3 scrollable.
  layer3.style.overflow = "auto";
  await promiseApzFlushedRepaints();
  checkHitResult(hitTest({x: 175, y: 175}),
                 subframeHitInfo,
                 (config.activateAllScrollFrames ? utils.getViewId(layer3)
                                                 : utils.getViewId(document.scrollingElement)),
                 utils.getLayersId(),
                 "subframe layer3");

  // At (125, 125), layer4 obscures layer3. layer4 is not scrollable yet,
  // so we hit the root.
  checkHitResult(hitTest({x: 125, y: 125}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "root scroller");

  // Make layer4 scrollable as well. Now (125, 125) should hit it.
  layer4.style.overflow = "auto";
  await promiseApzFlushedRepaints();
  checkHitResult(hitTest({x: 125, y: 125}),
                 subframeHitInfo,
                 (config.activateAllScrollFrames ? utils.getViewId(layer4)
                                                 : utils.getViewId(document.scrollingElement)),
                 utils.getLayersId(),
                 "subframe layer4");

  // Hit-test outside the reach of layer[3,4] but inside root.
  checkHitResult(hitTest({x: 225, y: 225}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "root scroller");
}

waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);

</script>
</html>