summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_hittest_bug1730606-2.html
blob: 8cd33885346baee500a0d411684304943875a8a2 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE HTML>
<html>
<head>
  <title>A more involved hit testing test that involves css and async 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;
      top: 20px;
      left: 20px;
      width: 100px;
      height: 100px;
      background: red;
      overflow: auto;
    }
    #layer2 {
      position: absolute;
      top: 140px;
      left: 40px;
      width: 100px;
      height: 100px;
      background: green;
      transform: scale(2.0, 1.0);
      transform-origin: 0 0;
    }
    #layer3 {
      position: absolute;
      top: 0px;
      left: 0px;
      width: 100px;
      height: 100px;
      background: yellow;
      overflow: auto;
    }
  </style>
</head>
<body>
  <div id="layer1">
    <div class="scrollable-content"></div>
  </div>
  <div id="layer2">
    <div id="layer3">
      <div class="scrollable-content"></div>
    </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;
  }

  // Hit an area that's clearly on the root and not any of the child layers.
  checkHitResult(hitTest({x: 150, y: 70}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "root scroller");

  // Hit an area on the root that would be on layer3 if layer2 weren't transformed.
  checkHitResult(hitTest({x: 30, y: 190}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "root scroller (area revealed by transform)");

  // Hit an area on layer1.
  checkHitResult(hitTest({x: 70, y: 70}),
                 subframeHitInfo,
                 (config.activateAllScrollFrames ? utils.getViewId(layer1)
                                                 : utils.getViewId(document.scrollingElement)),
                 utils.getLayersId(),
                 "layer1");

  // Hit an area on layer3.
  checkHitResult(hitTest({x: 60, y: 190}),
                 subframeHitInfo,
                 (config.activateAllScrollFrames ? utils.getViewId(layer3)
                                                 : utils.getViewId(document.scrollingElement)),
                 utils.getLayersId(),
                 "layer3");

  // Hit an area on layer3 that would be on the root if layer2 weren't transformed.
  checkHitResult(hitTest({x: 150, y: 190}),
                 subframeHitInfo,
                 (config.activateAllScrollFrames ? utils.getViewId(layer3)
                                                 : utils.getViewId(document.scrollingElement)),
                 utils.getLayersId(),
                 "layer3");

  // Scroll the root upwards by 120 pixels. This scrolls layer1 out of view.
  utils.setAsyncScrollOffset(document.scrollingElement, 0, 120);
  // Give WebRender a chance to sample the test async scroll offset.
  utils.advanceTimeAndRefresh(16);
  utils.restoreNormalRefresh();

  // Hit where layers3 used to be. It should now hit the root.
  checkHitResult(hitTest({x: 60, y: 190}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "root scroller (after async scroll)");

  // Hit where layers1 used to be and where layers3 should now be.
  checkHitResult(hitTest({x: 70, y: 70}),
                 subframeHitInfo,
                 (config.activateAllScrollFrames ? utils.getViewId(layer3)
                                                 : utils.getViewId(document.scrollingElement)),
                 utils.getLayersId(),
                 "layer3 (after async scroll)");

  // Scroll the root upwards by an additional 120 pixels.
  utils.setAsyncScrollOffset(document.scrollingElement, 0, 240);
  // Give WebRender a chance to sample the test async scroll offset.
  utils.advanceTimeAndRefresh(16);
  utils.restoreNormalRefresh();

  // Hit where layers3 used to be. It should now hit the root.
  checkHitResult(hitTest({x: 60, y: 190}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "root scroller (after second async scroll)");

  // Hit where layers2 used to be. It should now hit the root.
  checkHitResult(hitTest({x: 70, y: 70}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "root scroller (after second async scroll)");
}

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

</script>
</html>