summaryrefslogtreecommitdiffstats
path: root/gfx/layers/apz/test/mochitest/helper_fission_inactivescroller_positionedcontent.html
blob: fc43ace0f17d7eda08aaa94b6efe12517d3ca3fb (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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Ensure positioned content inside inactive scollframes but on top of OOPIFs hit-test properly</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/paint_listener.js"></script>
  <script src="helper_fission_utils.js"></script>
  <script src="apz_test_utils.js"></script>
  <script src="apz_test_native_event_utils.js"></script>
  <script>

fission_subtest_init();

FissionTestHelper.startTestPromise
  .then(waitUntilApzStable)
  .then(loadOOPIFrame("testframe", "helper_fission_empty.html"))
  .then(waitUntilApzStable)
  .then(test)
  .then(FissionTestHelper.subtestDone, FissionTestHelper.subtestFailed);

let make_oopif_scrollable = function() {
  // ensure the oopif is scrollable, and wait for the paint so that the
  // compositor also knows it's scrollable.
  document.body.style.height = "200vh";
  promiseApzFlushedRepaints().then(() => {
    let utils = SpecialPowers.getDOMWindowUtils(window);
    let result = {
      layersId: utils.getLayersId(),
      viewId: utils.getViewId(document.scrollingElement)
    };
    dump(`OOPIF computed IDs ${JSON.stringify(result)}\n`);
    FissionTestHelper.fireEventInEmbedder("OOPIF:Scrollable", result);
  });
  return true;
};

async function test() {
  let iframe = document.getElementById("testframe");

  let oopifScrollerIdsPromise = promiseOneEvent(window, "OOPIF:Scrollable", null);
  ok(await FissionTestHelper.sendToOopif(iframe, `(${make_oopif_scrollable})()`),
     "Ran code to make OOPIF scrollable");
  let oopifScrollerIds = (await oopifScrollerIdsPromise).data;

  let config = getHitTestConfig();
  let utils = config.utils;

  // The #scroller div is (a) inactive, and (b) under the OOPIF. However, it
  // also contains a positioned element with a high z-index (#abspos). #abspos
  // therefore sits on top of the OOPIF. Hit-testing on #abspos should hit
  // #scroller, but anywhere else within the OOPIF box should hit the OOPIF.

  checkHitResult(await fissionHitTest(centerOf("abspos"), iframe),
                 APZHitResultFlags.VISIBLE |
                 (config.activateAllScrollFrames ? 0 : APZHitResultFlags.INACTIVE_SCROLLFRAME),
                 config.activateAllScrollFrames ?
                   utils.getViewId(document.getElementById("scroller")) :
                   utils.getViewId(document.scrollingElement),
                 utils.getLayersId(),
                 "abspos element on top of OOPIF should hit parent doc hosting the OOPIF");

  // If the fix for the bug this test is for is not active (as indicated by
  // config.activateAllScrollFrames) then we just accept the wrong answer. As
  // of writing this comment the fix will only be active if fission is pref'ed
  // on, not just enabled for this window, ie the test suite is run in fission
  // mode.
  checkHitResult(await fissionHitTest(centerOf("scroller"), iframe),
                 APZHitResultFlags.VISIBLE |
                 (config.activateAllScrollFrames ? 0 : APZHitResultFlags.INACTIVE_SCROLLFRAME),
                 config.activateAllScrollFrames ?
                   oopifScrollerIds.viewId :
                   utils.getViewId(document.scrollingElement),
                 config.activateAllScrollFrames ?
                   oopifScrollerIds.layersId :
                   utils.getLayersId(),
                 "Part of OOPIF sitting on top of the inactive scrollframe should hit OOPIF");

  checkHitResult(await fissionHitTest({x: 250, y: 100}, iframe),
                 APZHitResultFlags.VISIBLE,
                 oopifScrollerIds.viewId,
                 oopifScrollerIds.layersId,
                 "part of OOPIF outside the inactive scfollframe rect should hit the OOPIF");
}

  </script>
</head>
<body>
<style>
html, body {
    margin: 0;
}
body {
    /* Ensure root document is scrollable so that #scroller is inactive by
      default */
    height: 200vh;
}
iframe {
    position: absolute;
    width: 300px;
    height: 200px;
}

#scroller {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
    background-color: transparent;
    overflow-y: scroll;
}
</style>
<div id="scroller">
  <div style="height:500px">inside scroller</div>
  <div id="abspos" style="position: absolute; z-index: 5; left: 0; width: 80px; top: 20px; height: 80px; background-color: green">abspos inside scroller</div>
</div>
<iframe id="testframe"></iframe>
</body>
</html>