summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_transform_end_on_keyboard_scroll.html
blob: 20bee3cefdd18fa619c172471146b4b5f5615d06 (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
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/NativeKeyCodes.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
html, body { margin: 0; }

body {
  height: 10000px;
}
</style>

<script>
async function test() {
  // Send a native key event which doesn't cause any scroll, so that now
  // subsequent native key events will be able to be handled by APZ.  See bug
  // 1774519 about what happens without this event.
  const UpArrowKeyCode = nativeArrowUpKey();
  await new Promise(resolve => {
    synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US,
      UpArrowKeyCode, {}  /* no modifier */,
      "", "", resolve); });

  // On test verify runs there's still a race condition where the next key event
  // isn't handled by APZ since the focus sequence number hasn't yet been
  // reflected to APZ, so we explicitly flush APZ state here.
  await promiseApzFlushedRepaints();

  const transformEndPromise = promiseTransformEnd();
  const DownArrowKeyCode = nativeArrowDownKey();
  await new Promise(resolve => {
    synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US,
      DownArrowKeyCode, {}  /* no modifier */,
      "", "", resolve); });
  await transformEndPromise;
  ok(true, "Got an APZ:TransformEnd ");
}

function isOnChaosMode() {
  return SpecialPowers.Services.env.get("MOZ_CHAOSMODE");
}

if ((getPlatform() == "mac" || getPlatform() == "windows") &&
    !isOnChaosMode()) {
  waitUntilApzStable()
  .then(test)
  .then(subtestDone, subtestFailed);
} else {
  ok(true, "Skipping test because native key events are not supported on " +
     getPlatform());
  subtestDone();
}
</script>