summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-contain/container-queries/deep-nested-inline-size-containers.html
blob: 00bc8b0a6b2deae05e980a6c8cd7ddbab286906f (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
<!doctype html>
<title>CSS Container Queries Test: Deeply nested inline-size container queries</title>
<link rel="help" href="https://drafts.csswg.org/css-contain-3/#size-container">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/cq-testcommon.js"></script>
<style id="test_style">
  .container { container-type: inline-size; }
  #outer { width: 200px; }
</style>
<div id="outer" class="container"></div>
<script>
  setup(() => {
    assert_implements_container_queries();

    // Create 50 nested inline-size containers where a child container is 1px
    // narrower than its parent
    let sheet = test_style.sheet;
    let container = outer;
    for (let width = 200; width > 150; --width) {
      sheet.insertRule(`
        @container (width = ${width}px) {
          .container { max-width: ${width-1}px; }
        }
      `);
      let child = document.createElement("div");
      child.className = "container";
      container.appendChild(child);
      container = child;
    }
  });

  test(() => {
    let expected_width = 200;
    for (let container of document.querySelectorAll(".container"))
      assert_equals(container.offsetWidth, expected_width--);
  }, "Test that all container widths match");
</script>