summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-contain/container-queries/container-size-invalidation-after-load.html
blob: cf5687aa39dfa7794422059ae72d5cf9e61d2cad (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
<!DOCTYPE html>
<title>@container: invalidation of container size after load event</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>
  #container {
    container-type: size;
    width: 200px;
    height: 4em;
    border: 1px solid black;
  }
  @container (width > 300px) {
    #child { color: green; }
  }
</style>
<div id=container>
  <div id=child>
    Green
  </div>
</div>
<script>
  setup(() => assert_implements_container_queries());

  function waitForLoad(w) {
    return new Promise(resolve => w.addEventListener('load', resolve));
  }

  promise_test(async () => {
    await waitForLoad(window);
    container.offsetTop;

    container.style.width = '400px';
    container.style.setProperty('--x', 'x'); // crbug.com/1321010

    assert_equals(getComputedStyle(child).color, 'rgb(0, 128, 0)');
  });
</script>