summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_hittest_bug1730606-4.html
blob: 26ec487b3ef787cccb6ea1d034c89f88634f5e58 (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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE HTML>
<html>
<head>
  <title>A hit testing test involving a scenario with a scale transform</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>
    /*
     * This test tries to approximate the layer structure of
     * APZHitTestingTester.ComplexMultiLayerTree from TestHitTesting.cpp.
     *
     * Notes:
     *   - The elements are named after the layers in the testcase
     *     (e.g. "layer1"), but where multiple elements share an APZC,
     *     new elements named "scroller1" etc. are introduced to be
     *     the scroll containers.
     *   - overflow: hidden is used to avoid spurious scrollbar layers.
     *     To trigger APZC creation, the test code explicitly sets display
     *     port margins.
     *   - Perspective transforms are used to force an element to be
     *     layerized if it otherwise wouldn't.
     *   - One difference is that the entire contents of the APZC that
     *     scrolls layer{4,6,8} is shifted to the right by 100px.
     *     Otherwise, the dimensions of the layers make it such that
     *     this APZC's composition bounds covers up layers{1,2,3}
     *     and those cannot be hit.
     */
    body, html {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
    }
    #scroller1 {
      position: absolute;
      left: 0;
      top: 0;
      width: 250px;
      height: 350px;
      overflow: hidden;
    }
    #layer1 {
      position: absolute;
      left: 0px;
      top: 0px;
      width: 100px;
      height: 100px;
      background: red;
    }
    #layer2 {
      position: absolute;
      left: 50px;
      top: 50px;
      width: 200px;
      height: 300px;
      background: yellow;
      transform: scale(1.0);
      perspective: 10px;
    }
    #layer3 {
      position: absolute;
      left: 10px;
      top: 10px;
      width: 10px;
      height: 10px;
      background: green;
      transform: scale(1.0);
      perspective: 10px;
    }
    #scroller2 {
      position: absolute;
      left: 100px;
      top: 0px;
      width: 300px;
      height: 400px;
      overflow: hidden;
    }
    #layer4 {
      position: absolute;
      left: 0px;
      top: 200px;
      width: 100px;
      height: 100px;
      background: purple;
    }
    #layer5 {
      position: absolute;
      left: 200px;
      top: 0px;
      width: 100px;
      height: 400px;
      background: pink;
      transform: scale(1.0);
      perspective: 10px;
    }
    #layer6 {
      position: absolute;
      left: 0px;
      top: 0px;
      width: 100px;
      height: 200px;
      background: orange;
    }
    #layer7 {
      position: absolute;
      left: 0px;
      top: 0px;
      width: 100px;
      height: 200px;
      background: navy;
      overflow: hidden;
    }
    #layer8 {
      position: absolute;
      left: 0px;
      top: 200px;
      width: 100px;
      height: 100px;
      background: lightgreen;
      transform: scale(1.0);
      perspective: 10px;
    }
    #layer9 {
      position: absolute;
      left: 0px;
      top: 300px;
      width: 100px;
      height: 100px;
      background: turquoise;
      overflow: hidden;
    }
  </style>
</head>
<body>
  <div id="scroller1">
    <div id="layer1"></div>
    <div id="layer2">
      <div id="layer3"></div>
    </div>
  </div>
  <div id="scroller2">
    <div id="layer4"></div>
    <div id="layer5">
      <div id="layer6">
        <div id="layer7"></div>
      </div>
      <div id="layer8"></div>
      <div id="layer9"></div>
    </div>
  </div>
</body>
<script type="application/javascript">

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

  // Trigger APZC creation.
  utils.setDisplayPortForElement(0, 0, 250, 350, scroller1, 1);
  await promiseApzFlushedRepaints();
  utils.setDisplayPortForElement(0, 0, 300, 400, scroller2, 1);
  await promiseApzFlushedRepaints();
  utils.setDisplayPortForElement(0, 0, 100, 200, layer7, 1);
  await promiseApzFlushedRepaints();
  utils.setDisplayPortForElement(0, 0, 100, 200, layer9, 1);
  await promiseApzFlushedRepaints();

  checkHitResult(hitTest({x: 25, y: 25}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(scroller1),
                 utils.getLayersId(),
                 "scroller1");

  checkHitResult(hitTest({x: 350, y: 100}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(layer7),
                 utils.getLayersId(),
                 "layer7");

  checkHitResult(hitTest({x: 375, y: 375}),
                 APZHitResultFlags.VISIBLE,
                 utils.getViewId(layer9),
                 utils.getLayersId(),
                 "layer7");
}

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

</script>
</html>