summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-transitions/starting-style-name-defining-rules.html
blob: 3d1b0b3c83c5dedac9bef993ee80951e2e2d6ef3 (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>
<title>CSS Transitions Test: Name defining @-rules in @starting-style</title>
<link rel="help" href="https://drafts.csswg.org/css-transitions-2/#defining-before-change-style-the-starting-style-rule">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
  @starting-style {
    @keyframes anim {
      from { color: green; }
      to { color: red; }
    }
    @font-face {
      font-family: web-font;
      src: url('/fonts/Ahem.ttf');
    }
    @layer first;
  }

  @layer second {
    #target.not_start {
      background-color: green;
    }
  }
  @layer first {
    #target.not_start {
      background-color: red;
    }
  }

  #target.not_start {
    animation-name: anim;
    animation-duration: 60s;
    animation-timing-function: step-end;
    font-family: web-font;
    font-size: 20px;
  }

  #target {
    /* For measuring text width */
    display: inline-block;
  }
</style>
<span id="target">XXXX</span>
<script>
  test(() => {
    // Force style update to ensure before-change style is defined.
    target.offsetTop;
    target.className = "not_start";
    let target_style = getComputedStyle(target);
    assert_equals(target_style.color, "rgb(0, 128, 0)", "@keyframes applied");
    assert_equals(target_style.backgroundColor, "rgb(0, 128, 0)", "@layer applied");
  }, "@keyframes and @layer in @starting-style apply");

  promise_test(async () => {
    await document.fonts.load("20px/1 web-font");
    assert_equals(getComputedStyle(target).width, "80px");
  }, "Load @font-face from @starting-style rule");
</script>