summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/layout-instability/sources-enclosure.html
blob: 8d1596ad498393ee8f6ea62b5da4c41cc943741c (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
<!DOCTYPE html>
<title>Layout Instability: source attribution with redundant enclosure</title>
<link rel="help" href="https://wicg.github.io/layout-instability/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-adapter.js"></script>
<script src="resources/util.js"></script>
<style>
body { margin: 0; }
#shifter {
  position: relative; background: #def;
  width: 300px; height: 200px;
}
#inner {
  position: relative; background: #f97;
  width: 100px; height: 100px;
}
#absfollow {
  position: absolute; background: #ffd; opacity: 50%;
  width: 350px; height: 200px; left: 0; top: 160px;
}
.stateB { top: 160px; }
.stateB #inner { left: 100px; }
.stateC ~ #absfollow { top: 0; }
</style>
<div id="shifter" class="stateA">
  <div id="inner"></div>
</div>
<div id="absfollow"></div>
<script>

promise_test(async () => {
  const watcher = new ScoreWatcher;
  let shifter = document.querySelector("#shifter");
  let absfollow = document.querySelector("#absfollow");

  // Wait for the initial render to complete.
  await waitForAnimationFrames(2);

  shifter.className = "stateB";
  await watcher.promise;

  // Shift of #inner ignored as redundant, fully enclosed by #shifter.
  cls_expect(watcher, {sources: [{
    node: shifter,
    previousRect: [0, 0, 300, 200],
    currentRect: [0, 160, 300, 200]
  }]});

  shifter.className = "stateC";
  await watcher.promise;

  // Shift of #shifter ignored as redundant, fully enclosed by #absfollow.
  cls_expect(watcher, {sources: [{
    node: absfollow,
    previousRect: [0, 160, 350, 200],
    currentRect: [0, 0, 350, 200]
  }]});

}, "Sources with redundant enclosure.");

</script>