summaryrefslogtreecommitdiffstats
path: root/dom/events/test/test_wheel_zoom_on_form_controls.html
blob: 73fc13558cdacb81f9f3de780574fa258e3a9eb2 (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>
  <meta charset="utf-8">
  <title>Zoom using wheel should work on form controls</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
<button id="button" style="width:10px;height:10px;"></button><br>
<input id="input" style="border: 10px solid green;"><br>
<textarea id="textarea" style="border: 10px solid green;"></textarea><br>
<select id="select"><option></option></select>
<select id="list" size=4>
  <option>XXXXXXXXXX</option>
  <option>XXXXXXXXXX</option>
  <option>XXXXXXXXXX</option>
  <option>XXXXXXXXXX</option>
  <option>XXXXXXXXXX</option>
  <option>XXXXXXXXXX</option>
</select>
<script>

  async function testControl(id) {
    var initialZoom = SpecialPowers.getFullZoom(window);
    var element = document.getElementById(id);

    const zoomHasHappened = SimpleTest.promiseWaitForCondition(() => {
      const zoom = SpecialPowers.getFullZoom(window);
      return (zoom != initialZoom);
    }, id + ": wheel event changed the zoom.");

    let event = {
      deltaMode: WheelEvent.DOM_DELTA_LINE,
      deltaY: 3,
      ctrlKey: true
    };
    synthesizeWheel(element, 5, 5, event);

    await zoomHasHappened;
    isnot(SpecialPowers.getFullZoom(window), initialZoom, id + ": should have zoomed");
    SpecialPowers.setFullZoom(window, initialZoom);
  }

  async function test() {
    await testControl("button");
    await testControl("input");
    await testControl("textarea");
    await testControl("select");
    await testControl("list");
    SimpleTest.finish();
  }

  SimpleTest.waitForExplicitFinish();
  SimpleTest.waitForFocus(() => {
    SpecialPowers.pushPrefEnv({
      "set":[
        ["mousewheel.with_control.action", 3],  // Scroll on Ctrl + mousewheel
        ["test.events.async.enabled", true],
      ]
    }, test)
  });
</script>
</body>
</html>