summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_zoomToFocusedInput_touch-action.html
blob: bdb49f4b843ad4d9cfca382a9379464931712fa1 (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
<!DOCTYPE>
<html>
  <head>
  <title>Checking zoomToFocusedInput zooms if touch-action allows it</title>
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=0.5 minimum-scale=0.5, maximum-scale=1" />
  <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>
  </head>
  <style type="text/css">
    .touch-none {
      touch-action: none;
    }
    .touch-auto {
      touch-action: auto;
    }
  </style>
<body>
  <div class="touch-none">
    <input id="input1" type="text" style="border: 5px solid black">
  </div>
  <br>
  <div class="touch-auto">
    <input id="input2" type="text" style="border: 5px solid black">
  </div>
<script type="application/javascript">
async function test() {
  let utils = SpecialPowers.getDOMWindowUtils(window);

  let resolution = await getResolution();
  ok(resolution > 0,
     "The initial_resolution is " + resolution + ", which is some sane value");

  document.getElementById('input1').focus();
  await waitToClearOutAnyPotentialScrolls(window);
  await promiseApzFlushedRepaints();
  let prev_resolution = resolution;
  resolution = await getResolution();
  ok(resolution == prev_resolution, "focusing input1 did not change resolution " + resolution);

  let transformEndPromise = promiseTransformEnd();
  utils.zoomToFocusedInput();
  await waitToClearOutAnyPotentialScrolls(window);
  await transformEndPromise;
  await promiseApzFlushedRepaints();
  resolution = await getResolution();
  ok(resolution == prev_resolution, "zoomToFocusedInput input1 did not change resolution " + resolution);

  document.getElementById('input2').focus();
  await waitToClearOutAnyPotentialScrolls(window);
  await promiseApzFlushedRepaints();
  resolution = await getResolution();
  ok(resolution == prev_resolution, "focusing input2 did not change resolution " + resolution);

  transformEndPromise = promiseTransformEnd();
  utils.zoomToFocusedInput();
  await waitToClearOutAnyPotentialScrolls(window);
  await transformEndPromise;
  await promiseApzFlushedRepaints();
  resolution = await getResolution();
  ok(resolution != prev_resolution, "zoomToFocusedInput input2 changed resolution " + resolution);
}

waitUntilApzStable().then(test).then(subtestDone, subtestFailed);
</script>
</body>
</html>